add default file
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 29 May 2008 10:31:38 +0000 (12:31 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 29 May 2008 10:31:38 +0000 (12:31 +0200)
src/net/pterodactylus/jsite/project/Project.java
src/net/pterodactylus/jsite/project/ProjectManager.java

index b80c293..e6f732b 100644 (file)
@@ -48,6 +48,9 @@ public class Project extends AbstractBean {
        /** Name of the “base path” property. */
        public static final String PROPERTY_BASE_PATH = "basePath";
 
+       /** Name of the “default file” property. */
+       public static final String PROPERTY_DEFAULT_FILE = "defaultFile";
+
        /** Internal ID. */
        private String id;
 
@@ -66,6 +69,9 @@ public class Project extends AbstractBean {
        /** The base path of the project. */
        private String basePath;
 
+       /** The default file. */
+       private String defaultFile;
+
        /** The overrides. */
        private final Map<String, Override> overrides = new HashMap<String, Override>();
 
@@ -214,6 +220,27 @@ public class Project extends AbstractBean {
        }
 
        /**
+        * Returns the default file.
+        *
+        * @return The default file
+        */
+       public String getDefaultFile() {
+               return defaultFile;
+       }
+
+       /**
+        * Sets the default file.
+        *
+        * @param defaultFile
+        *            The default file
+        */
+       public void setDefaultFile(String defaultFile) {
+               String oldDefaultFile = this.defaultFile;
+               this.defaultFile = defaultFile;
+               fireIfPropertyChanged(PROPERTY_DEFAULT_FILE, oldDefaultFile, defaultFile);
+       }
+
+       /**
         * Adds an override for the given file.
         *
         * @param filePath
index d6fc591..b4f9fe0 100644 (file)
@@ -140,6 +140,7 @@ public class ProjectManager implements PropertyChangeListener {
                        String projectPrivateKey = projectProperties.getProperty(projectPrefix + ".privateKey");
                        String projectPublicKey = projectProperties.getProperty(projectPrefix + ".publicKey");
                        String projectBasePath = projectProperties.getProperty(projectPrefix + ".basePath");
+                       String projectDefaultFile = projectProperties.getProperty(projectPrefix + ".defaultFile");
                        Project project = new Project();
                        project.setId(projectId);
                        project.setName(projectName);
@@ -147,6 +148,7 @@ public class ProjectManager implements PropertyChangeListener {
                        project.setPrivateKey(projectPrivateKey);
                        project.setPublicKey(projectPublicKey);
                        project.setBasePath(projectBasePath);
+                       project.setDefaultFile(projectDefaultFile);
                        int overrideIndex = 0;
                        while (projectProperties.containsKey(projectPrefix + ".overrides." + overrideIndex)) {
                                String filePath = projectProperties.getProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath");
@@ -183,6 +185,7 @@ public class ProjectManager implements PropertyChangeListener {
                        projectProperties.setProperty(projectPrefix + ".privateKey", project.getPrivateKey());
                        projectProperties.setProperty(projectPrefix + ".publicKey", project.getPublicKey());
                        projectProperties.setProperty(projectPrefix + ".basePath", project.getBasePath());
+                       projectProperties.setProperty(projectPrefix + ".defaultFile", project.getDefaultFile());
                        int overrideIndex = 0;
                        for (Entry<String, Override> overrideEntry: project.getOverrides().entrySet()) {
                                projectProperties.setProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath", overrideEntry.getKey());
@@ -220,6 +223,7 @@ public class ProjectManager implements PropertyChangeListener {
                project.setPrivateKey(keyPair[0]);
                project.setPublicKey(keyPair[1]);
                project.setBasePath("");
+               project.setDefaultFile("");
                projects.add(project);
                project.addPropertyChangeListener(this);
                try {