From e2e553c23e712178421dbedae7308466fc23c9c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 22 Dec 2009 21:06:29 +0100 Subject: [PATCH] Load and save temp directory in configuration. --- src/de/todesbaum/jsite/main/Configuration.java | 27 ++++++++++++++++++++++++++ src/de/todesbaum/jsite/main/Main.java | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 61803a6..9d288b5 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -523,4 +523,31 @@ public class Configuration { return new Node(hostname, port, name); } + /** + * Returns the temp directory to use. + * + * @return The temp directoy, or {@code null} to use the default temp + * directory + */ + public String getTempDirectory() { + return getNodeValue(new String[] { "temp-directory" }, null); + } + + /** + * Sets the temp directory to use. + * + * @param tempDirectory + * The temp directory to use, or {@code null} to use the default + * temp directory + */ + public void setTempDirectory(String tempDirectory) { + if (tempDirectory != null) { + SimpleXML tempDirectoryNode = new SimpleXML("temp-directory"); + tempDirectoryNode.setValue(tempDirectory); + rootNode.replace(tempDirectoryNode); + } else { + rootNode.remove("temp-directory"); + } + } + } diff --git a/src/de/todesbaum/jsite/main/Main.java b/src/de/todesbaum/jsite/main/Main.java index df64ff9..ddeb414 100644 --- a/src/de/todesbaum/jsite/main/Main.java +++ b/src/de/todesbaum/jsite/main/Main.java @@ -340,6 +340,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen PreferencesPage preferencesPage = new PreferencesPage(wizard); preferencesPage.setName("page.preferences"); + preferencesPage.setTempDirectory(configuration.getTempDirectory()); pages.put(PageType.PAGE_PREFERENCES, preferencesPage); } @@ -372,6 +373,9 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS); configuration.setProjects(projectPage.getProjects()); + PreferencesPage preferencesPage = (PreferencesPage) pages.get(PageType.PAGE_PREFERENCES); + configuration.setTempDirectory(preferencesPage.getTempDirectory()); + return configuration.save(); } -- 2.7.4