Add and show preferences page.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 21 Dec 2009 20:49:24 +0000 (21:49 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 21 Dec 2009 20:49:24 +0000 (21:49 +0100)
src/de/todesbaum/jsite/gui/PreferencesPage.java [new file with mode: 0644]
src/de/todesbaum/jsite/main/Main.java

diff --git a/src/de/todesbaum/jsite/gui/PreferencesPage.java b/src/de/todesbaum/jsite/gui/PreferencesPage.java
new file mode 100644 (file)
index 0000000..791c139
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * jSite - PreferencesPage.java -
+ * Copyright © 2009 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package de.todesbaum.jsite.gui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+
+import de.todesbaum.jsite.i18n.I18n;
+import de.todesbaum.jsite.i18n.I18nContainer;
+import de.todesbaum.util.swing.TWizard;
+import de.todesbaum.util.swing.TWizardPage;
+
+/**
+ * Page that shows some preferences that are valid for the complete application.
+ *
+ * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
+ */
+public class PreferencesPage extends TWizardPage {
+
+       /** Action that chooses a new temp directory. */
+       private Action chooseTempDirectoryAction;
+
+       /**
+        * Creates a new “preferences” page.
+        *
+        * @param wizard
+        *            The wizard this page belongs to
+        */
+       public PreferencesPage(TWizard wizard) {
+               super(wizard);
+               pageInit();
+               setHeading(I18n.getMessage("jsite.preferences.heading"));
+               setDescription(I18n.getMessage("jsite.preferences.description"));
+               I18nContainer.getInstance().registerRunnable(new Runnable() {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @Override
+                       public void run() {
+                               setHeading(I18n.getMessage("jsite.preferences.heading"));
+                               setDescription(I18n.getMessage("jsite.preferences.description"));
+                       }
+               });
+       }
+
+       /**
+        * Initializes this page.
+        */
+       private void pageInit() {
+               createActions();
+       }
+
+       /**
+        * Creates all actions.
+        */
+       private void createActions() {
+               chooseTempDirectoryAction = new AbstractAction(I18n.getMessage("jsite.preferences.choose-temp-directory")) {
+
+                       @Override
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent e) {
+                               chooseTempDirectory();
+                       }
+               };
+
+               I18nContainer.getInstance().registerRunnable(new Runnable() {
+
+                       @Override
+                       @SuppressWarnings("synthetic-access")
+                       public void run() {
+                               chooseTempDirectoryAction.putValue(Action.NAME, I18n.getMessage("jsite.preferences.choose-temp-directory"));
+                       }
+               });
+       }
+
+       /**
+        * Lets the user choose a new temp directory.
+        */
+       private void chooseTempDirectory() {
+               /* TODO */
+       }
+
+}
index 6773eee..5a836f3 100644 (file)
@@ -56,6 +56,7 @@ import de.todesbaum.jsite.application.UpdateChecker;
 import de.todesbaum.jsite.application.UpdateListener;
 import de.todesbaum.jsite.gui.NodeManagerListener;
 import de.todesbaum.jsite.gui.NodeManagerPage;
+import de.todesbaum.jsite.gui.PreferencesPage;
 import de.todesbaum.jsite.gui.ProjectFilesPage;
 import de.todesbaum.jsite.gui.ProjectInsertPage;
 import de.todesbaum.jsite.gui.ProjectPage;
@@ -105,7 +106,10 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
                PAGE_PROJECT_FILES,
 
                /** The project insert page. */
-               PAGE_INSERT_PROJECT
+               PAGE_INSERT_PROJECT,
+
+               /** The preferences page. */
+               PAGE_PREFERENCES
 
        }
 
@@ -329,6 +333,10 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
                projectInsertPage.setName("page.project.insert");
                projectInsertPage.setFreenetInterface(freenetInterface);
                pages.put(PageType.PAGE_INSERT_PROJECT, projectInsertPage);
+
+               PreferencesPage preferencesPage = new PreferencesPage(wizard);
+               preferencesPage.setName("page.preferences");
+               pages.put(PageType.PAGE_PREFERENCES, preferencesPage);
        }
 
        /**
@@ -430,7 +438,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
         * Shows a dialog with general preferences.
         */
        private void optionsPreferences() {
-
+               showPage(PageType.PAGE_PREFERENCES);
        }
 
        /**