From: David ‘Bombe’ Roden Date: Wed, 28 May 2008 14:02:21 +0000 (+0200) Subject: save and load project overrides X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7a6b057c132a7f90c06608d6f3a2f2138744f4c1;p=jSite2.git save and load project overrides --- 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");