From 7a6b057c132a7f90c06608d6f3a2f2138744f4c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 28 May 2008 16:02:21 +0200 Subject: [PATCH] save and load project overrides --- src/net/pterodactylus/jsite/project/ProjectManager.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/net/pterodactylus/jsite/project/ProjectManager.java b/src/net/pterodactylus/jsite/project/ProjectManager.java index 69b0522..d6fc591 100644 --- a/src/net/pterodactylus/jsite/project/ProjectManager.java +++ b/src/net/pterodactylus/jsite/project/ProjectManager.java @@ -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 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"); -- 2.7.4