save and load project overrides
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 28 May 2008 14:02:21 +0000 (16:02 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 28 May 2008 14:02:21 +0000 (16:02 +0200)
src/net/pterodactylus/jsite/project/ProjectManager.java

index 69b0522..d6fc591 100644 (file)
@@ -30,6 +30,7 @@ import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Random;
 import java.util.logging.Logger;
@@ -146,6 +147,13 @@ public class ProjectManager implements PropertyChangeListener {
                        project.setPrivateKey(projectPrivateKey);
                        project.setPublicKey(projectPublicKey);
                        project.setBasePath(projectBasePath);
+                       int overrideIndex = 0;
+                       while (projectProperties.containsKey(projectPrefix + ".overrides." + overrideIndex)) {
+                               String filePath = projectProperties.getProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath");
+                               Override override = Override.valueOf(projectProperties.getProperty(projectPrefix + ".overrides." + overrideIndex + ".override"));
+                               project.addOverride(filePath, override);
+                               overrideIndex++;
+                       }
                        projects.add(project);
                        logger.fine("loaded project “" + project.getName() + "”.");
                        projectIndex++;
@@ -175,6 +183,12 @@ public class ProjectManager implements PropertyChangeListener {
                        projectProperties.setProperty(projectPrefix + ".privateKey", project.getPrivateKey());
                        projectProperties.setProperty(projectPrefix + ".publicKey", project.getPublicKey());
                        projectProperties.setProperty(projectPrefix + ".basePath", project.getBasePath());
+                       int overrideIndex = 0;
+                       for (Entry<String, Override> overrideEntry: project.getOverrides().entrySet()) {
+                               projectProperties.setProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath", overrideEntry.getKey());
+                               projectProperties.setProperty(projectPrefix + ".overrides." + overrideIndex + ".override", overrideEntry.getValue().toString());
+                               overrideIndex++;
+                       }
                        projectIndex++;
                }
                File projectFile = new File(directoryFile, "projects.properties");