From e8af906f00f16b5eeb0a7d24520ac048ee3a32fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 23 May 2008 19:34:46 +0000 Subject: [PATCH] initialize all project files save on creation save on property change git-svn-id: http://trooper/svn/projects/jSite/trunk@944 c3eda9e8-030b-0410-8277-bc7414b0a119 --- .../jsite/project/ProjectManager.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/net/pterodactylus/jsite/project/ProjectManager.java b/src/net/pterodactylus/jsite/project/ProjectManager.java index e3529c6..ab5406d 100644 --- a/src/net/pterodactylus/jsite/project/ProjectManager.java +++ b/src/net/pterodactylus/jsite/project/ProjectManager.java @@ -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 <bombe@freenetproject.org> * @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. */ + } + } + } -- 2.7.4