Add and show preferences page.
[jSite.git] / src / de / todesbaum / jsite / gui / PreferencesPage.java
1 /*
2  * jSite - PreferencesPage.java -
3  * Copyright © 2009 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package de.todesbaum.jsite.gui;
21
22 import java.awt.event.ActionEvent;
23
24 import javax.swing.AbstractAction;
25 import javax.swing.Action;
26
27 import de.todesbaum.jsite.i18n.I18n;
28 import de.todesbaum.jsite.i18n.I18nContainer;
29 import de.todesbaum.util.swing.TWizard;
30 import de.todesbaum.util.swing.TWizardPage;
31
32 /**
33  * Page that shows some preferences that are valid for the complete application.
34  *
35  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
36  */
37 public class PreferencesPage extends TWizardPage {
38
39         /** Action that chooses a new temp directory. */
40         private Action chooseTempDirectoryAction;
41
42         /**
43          * Creates a new “preferences” page.
44          *
45          * @param wizard
46          *            The wizard this page belongs to
47          */
48         public PreferencesPage(TWizard wizard) {
49                 super(wizard);
50                 pageInit();
51                 setHeading(I18n.getMessage("jsite.preferences.heading"));
52                 setDescription(I18n.getMessage("jsite.preferences.description"));
53                 I18nContainer.getInstance().registerRunnable(new Runnable() {
54
55                         /**
56                          * {@inheritDoc}
57                          */
58                         @Override
59                         public void run() {
60                                 setHeading(I18n.getMessage("jsite.preferences.heading"));
61                                 setDescription(I18n.getMessage("jsite.preferences.description"));
62                         }
63                 });
64         }
65
66         /**
67          * Initializes this page.
68          */
69         private void pageInit() {
70                 createActions();
71         }
72
73         /**
74          * Creates all actions.
75          */
76         private void createActions() {
77                 chooseTempDirectoryAction = new AbstractAction(I18n.getMessage("jsite.preferences.choose-temp-directory")) {
78
79                         @Override
80                         @SuppressWarnings("synthetic-access")
81                         public void actionPerformed(ActionEvent e) {
82                                 chooseTempDirectory();
83                         }
84                 };
85
86                 I18nContainer.getInstance().registerRunnable(new Runnable() {
87
88                         @Override
89                         @SuppressWarnings("synthetic-access")
90                         public void run() {
91                                 chooseTempDirectoryAction.putValue(Action.NAME, I18n.getMessage("jsite.preferences.choose-temp-directory"));
92                         }
93                 });
94         }
95
96         /**
97          * Lets the user choose a new temp directory.
98          */
99         private void chooseTempDirectory() {
100                 /* TODO */
101         }
102
103 }