add texts for project description
[jSite2.git] / src / net / pterodactylus / jsite / core / Project.java
index 71eba5f..b651d4c 100644 (file)
 
 package net.pterodactylus.jsite.core;
 
+import java.beans.PropertyChangeListener;
+
+import net.pterodactylus.util.beans.AbstractBean;
+
 /**
- * Container for project information.
+ * Container for project information. A Project is capable of notifying
+ * {@link PropertyChangeListener}s if any of the contained properties change.
  * 
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
  * @version $Id$
  */
-public class Project {
+public class Project extends 
+AbstractBean {
+
+       /** Name of the “name” property. */
+       public static final String PROPERTY_NAME = "name";
+
+       /** Name of the “description” property. */
+       public static final String PROPERTY_DESCRIPTION = "description";
+
+       /** Name of the “public key” property. */
+       public static final String PROPERTY_PUBLIC_KEY = "publicKey";
+
+       /** Name of the “private key” property. */
+       public static final String PROPERTY_PRIVATE_KEY = "privateKey";
+
+       /** Name of the “local path” property. */
+       public static final String PROPERTY_LOCAL_PATH = "localPath";
 
        /** The name of the project. */
        private String name;
 
-       /** The local path of the project. */
-       private String localPath;
+       /** The description of the project. */
+       private String description;
 
        /** The public key. */
        private String publicKey;
@@ -39,6 +60,13 @@ public class Project {
        /** The private key. */
        private String privateKey;
 
+       /** The local path of the project. */
+       private String localPath;
+
+       //
+       // EVENT MANAGEMENT
+       //
+
        /**
         * Returns the name of the project.
         * 
@@ -55,26 +83,34 @@ public class Project {
         *            The name of the project
         */
        public void setName(String name) {
+               String oldName = this.name;
                this.name = name;
+               if (!equal(oldName, name)) {
+                       firePropertyChange(PROPERTY_NAME, oldName, name);
+               }
        }
 
        /**
-        * Returns the local path of the project.
+        * Returns the description of the project.
         * 
-        * @return The local path of the project
+        * @return The description of the project
         */
-       public String getLocalPath() {
-               return localPath;
+       public String getDescription() {
+               return description;
        }
 
        /**
-        * Sets the local path of the project.
+        * Sets the description of the project
         * 
-        * @param localPath
-        *            The local path of the project
+        * @param description
+        *            The description of the project
         */
-       public void setLocalPath(String localPath) {
-               this.localPath = localPath;
+       public void setDescription(String description) {
+               String oldDescription = this.description;
+               this.description = description;
+               if (!equal(oldDescription, description)) {
+                       firePropertyChange(PROPERTY_DESCRIPTION, oldDescription, description);
+               }
        }
 
        /**
@@ -93,7 +129,11 @@ public class Project {
         *            The public key of the project
         */
        public void setPublicKey(String publicKey) {
+               String oldPublicKey = this.publicKey;
                this.publicKey = publicKey;
+               if (!equal(oldPublicKey, publicKey)) {
+                       firePropertyChange(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
+               }
        }
 
        /**
@@ -112,7 +152,32 @@ public class Project {
         *            The private key of the project
         */
        public void setPrivateKey(String privateKey) {
+               String oldPrivateKey = this.privateKey;
                this.privateKey = privateKey;
+               if (!equal(oldPrivateKey, privateKey)) {
+                       firePropertyChange(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
+               }
+       }
+
+       /**
+        * Returns the local path of the project.
+        * 
+        * @return The local path of the project
+        */
+       public String getLocalPath() {
+               return localPath;
+       }
+
+       /**
+        * Sets the local path of the project.
+        * 
+        * @param localPath
+        *            The local path of the project
+        */
+       public void setLocalPath(String localPath) {
+               String oldLocalPath = this.localPath;
+               this.localPath = localPath;
+               firePropertyChange(PROPERTY_LOCAL_PATH, oldLocalPath, localPath);
        }
 
 }