initialize all project files
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 23 May 2008 19:34:46 +0000 (19:34 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 23 May 2008 19:34:46 +0000 (19:34 +0000)
save on creation
save on property change

git-svn-id: http://trooper/svn/projects/jSite/trunk@944 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/project/ProjectManager.java

index e3529c6..ab5406d 100644 (file)
@@ -19,6 +19,8 @@
 
 package net.pterodactylus.jsite.project;
 
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -45,7 +47,7 @@ import net.pterodactylus.util.number.Hex;
  * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
  * @version $Id$
  */
-public class ProjectManager {
+public class ProjectManager implements PropertyChangeListener {
 
        /** Logger. */
        private static final Logger logger = Logging.getLogger(ProjectManager.class.getName());
@@ -199,9 +201,33 @@ public class ProjectManager {
                byte[] idBytes = new byte[16];
                random.nextBytes(idBytes);
                project.setId(Hex.toHex(idBytes));
+               project.setName("");
+               project.setDescription("");
                project.setPrivateKey(keyPair[0]);
                project.setPublicKey(keyPair[1]);
                projects.add(project);
+               project.addPropertyChangeListener(this);
+               try {
+                       save();
+               } catch (IOException ioe1) {
+                       /* ignore. */
+               }
                return project;
        }
+
+       //
+       // INTERFACE PropertyChangeListener
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
+               try {
+                       save();
+               } catch (IOException ioe1) {
+                       /* ignore. */
+               }
+       }
+
 }