2 * jSite - a tool for uploading websites into Freenet
3 * Copyright © 2006–2011 David Roden
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.
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.
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.
20 package de.todesbaum.jsite.main;
22 import java.awt.Component;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.io.IOException;
26 import java.text.MessageFormat;
27 import java.util.Date;
28 import java.util.HashMap;
29 import java.util.Locale;
31 import java.util.logging.ConsoleHandler;
32 import java.util.logging.Handler;
33 import java.util.logging.Level;
34 import java.util.logging.Logger;
36 import javax.swing.AbstractAction;
37 import javax.swing.Action;
38 import javax.swing.ButtonGroup;
39 import javax.swing.Icon;
40 import javax.swing.JList;
41 import javax.swing.JMenu;
42 import javax.swing.JMenuBar;
43 import javax.swing.JMenuItem;
44 import javax.swing.JOptionPane;
45 import javax.swing.JPanel;
46 import javax.swing.JRadioButtonMenuItem;
47 import javax.swing.event.ListSelectionEvent;
48 import javax.swing.event.ListSelectionListener;
50 import de.todesbaum.jsite.application.Freenet7Interface;
51 import de.todesbaum.jsite.application.Node;
52 import de.todesbaum.jsite.application.Project;
53 import de.todesbaum.jsite.application.ProjectInserter;
54 import de.todesbaum.jsite.application.UpdateChecker;
55 import de.todesbaum.jsite.application.UpdateListener;
56 import de.todesbaum.jsite.application.ProjectInserter.CheckReport;
57 import de.todesbaum.jsite.application.ProjectInserter.Issue;
58 import de.todesbaum.jsite.gui.NodeManagerListener;
59 import de.todesbaum.jsite.gui.NodeManagerPage;
60 import de.todesbaum.jsite.gui.PreferencesPage;
61 import de.todesbaum.jsite.gui.ProjectFilesPage;
62 import de.todesbaum.jsite.gui.ProjectInsertPage;
63 import de.todesbaum.jsite.gui.ProjectPage;
64 import de.todesbaum.jsite.i18n.I18n;
65 import de.todesbaum.jsite.i18n.I18nContainer;
66 import de.todesbaum.jsite.main.ConfigurationLocator.ConfigurationLocation;
67 import de.todesbaum.util.image.IconLoader;
68 import de.todesbaum.util.swing.TWizard;
69 import de.todesbaum.util.swing.TWizardPage;
70 import de.todesbaum.util.swing.WizardListener;
73 * The main class that ties together everything.
75 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
77 public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener, UpdateListener {
80 private static final Logger logger = Logger.getLogger(Main.class.getName());
83 private static final Version VERSION = new Version(0, 9, 2);
85 /** The configuration. */
86 private Configuration configuration;
88 /** The freenet interface. */
89 private Freenet7Interface freenetInterface = new Freenet7Interface();
91 /** The update checker. */
92 private final UpdateChecker updateChecker;
94 /** The jSite icon. */
95 private Icon jSiteIcon;
98 * Enumeration for all possible pages.
100 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
102 private static enum PageType {
104 /** The node manager page. */
107 /** The project page. */
110 /** The project files page. */
113 /** The project insert page. */
116 /** The preferences page. */
121 /** The supported locales. */
122 private static final Locale[] SUPPORTED_LOCALES = new Locale[] { Locale.ENGLISH, Locale.GERMAN, Locale.FRENCH };
124 /** The actions that switch the language. */
125 private Map<Locale, Action> languageActions = new HashMap<Locale, Action>();
127 /** The “manage nodes” action. */
128 private Action manageNodeAction;
130 /** The “preferences” action. */
131 private Action optionsPreferencesAction;
133 /** The “check for updates” action. */
134 private Action checkForUpdatesAction;
136 /** The “about jSite” action. */
137 private Action aboutAction;
140 private TWizard wizard;
142 /** The node menu. */
143 private JMenu nodeMenu;
145 /** The currently selected node. */
146 private Node selectedNode;
148 /** Mapping from page type to page. */
149 private final Map<PageType, TWizardPage> pages = new HashMap<PageType, TWizardPage>();
152 * Creates a new core with the default configuration file.
159 * Creates a new core with the given configuration from the given file.
161 * @param configFilename
162 * The name of the configuration file
164 private Main(String configFilename) {
165 /* collect all possible configuration file locations. */
166 ConfigurationLocator configurationLocator = new ConfigurationLocator();
167 if (configFilename != null) {
168 configurationLocator.setCustomLocation(configFilename);
171 ConfigurationLocation preferredLocation = configurationLocator.findPreferredLocation();
172 logger.log(Level.CONFIG, "Using configuration from " + preferredLocation + ".");
173 configuration = new Configuration(configurationLocator, preferredLocation);
175 Locale.setDefault(configuration.getLocale());
176 I18n.setLocale(configuration.getLocale());
177 wizard = new TWizard();
179 wizard.setJMenuBar(createMenuBar());
180 wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
181 wizard.setPreviousEnabled(false);
182 wizard.setNextEnabled(true);
183 wizard.addWizardListener(this);
184 jSiteIcon = IconLoader.loadIcon("/jsite-icon.png");
185 wizard.setIcon(jSiteIcon);
187 updateChecker = new UpdateChecker(freenetInterface);
188 updateChecker.addUpdateListener(this);
189 updateChecker.start();
192 showPage(PageType.PAGE_PROJECTS);
196 * Creates all actions.
198 private void createActions() {
199 for (final Locale locale : SUPPORTED_LOCALES) {
200 languageActions.put(locale, new AbstractAction(I18n.getMessage("jsite.menu.language." + locale.getLanguage()), IconLoader.loadIcon("/flag-" + locale.getLanguage() + ".png")) {
202 @SuppressWarnings("synthetic-access")
203 public void actionPerformed(ActionEvent actionEvent) {
204 switchLanguage(locale);
208 manageNodeAction = new AbstractAction(I18n.getMessage("jsite.menu.nodes.manage-nodes")) {
210 @SuppressWarnings("synthetic-access")
211 public void actionPerformed(ActionEvent actionEvent) {
212 showPage(PageType.PAGE_NODE_MANAGER);
213 optionsPreferencesAction.setEnabled(true);
214 wizard.setPreviousName(I18n.getMessage("jsite.wizard.previous"));
215 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
218 optionsPreferencesAction = new AbstractAction(I18n.getMessage("jsite.menu.options.preferences")) {
223 @SuppressWarnings("synthetic-access")
224 public void actionPerformed(ActionEvent actionEvent) {
225 optionsPreferences();
228 checkForUpdatesAction = new AbstractAction(I18n.getMessage("jsite.menu.help.check-for-updates")) {
233 @SuppressWarnings("synthetic-access")
234 public void actionPerformed(ActionEvent actionEvent) {
238 aboutAction = new AbstractAction(I18n.getMessage("jsite.menu.help.about")) {
240 @SuppressWarnings("synthetic-access")
241 public void actionPerformed(ActionEvent e) {
242 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.about.message"), getVersion().toString()), null, JOptionPane.INFORMATION_MESSAGE, jSiteIcon);
246 I18nContainer.getInstance().registerRunnable(new Runnable() {
248 @SuppressWarnings("synthetic-access")
250 manageNodeAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.nodes.manage-nodes"));
251 optionsPreferencesAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.options.preferences"));
252 checkForUpdatesAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.help.check-for-updates"));
253 aboutAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.help.about"));
259 * Creates the menu bar.
261 * @return The menu bar
263 private JMenuBar createMenuBar() {
264 JMenuBar menuBar = new JMenuBar();
265 final JMenu languageMenu = new JMenu(I18n.getMessage("jsite.menu.languages"));
266 menuBar.add(languageMenu);
267 ButtonGroup languageButtonGroup = new ButtonGroup();
268 for (Locale locale : SUPPORTED_LOCALES) {
269 Action languageAction = languageActions.get(locale);
270 JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(languageActions.get(locale));
271 if (locale.equals(Locale.getDefault())) {
272 menuItem.setSelected(true);
274 languageAction.putValue("menuItem", menuItem);
275 languageButtonGroup.add(menuItem);
276 languageMenu.add(menuItem);
278 nodeMenu = new JMenu(I18n.getMessage("jsite.menu.nodes"));
279 menuBar.add(nodeMenu);
280 selectedNode = configuration.getSelectedNode();
281 nodesUpdated(configuration.getNodes());
283 final JMenu optionsMenu = new JMenu(I18n.getMessage("jsite.menu.options"));
284 menuBar.add(optionsMenu);
285 optionsMenu.add(optionsPreferencesAction);
287 /* evil hack to right-align the help menu */
288 JPanel panel = new JPanel();
289 panel.setOpaque(false);
292 final JMenu helpMenu = new JMenu(I18n.getMessage("jsite.menu.help"));
293 menuBar.add(helpMenu);
294 helpMenu.add(checkForUpdatesAction);
295 helpMenu.add(aboutAction);
297 I18nContainer.getInstance().registerRunnable(new Runnable() {
299 @SuppressWarnings("synthetic-access")
301 languageMenu.setText(I18n.getMessage("jsite.menu.languages"));
302 nodeMenu.setText(I18n.getMessage("jsite.menu.nodes"));
303 optionsMenu.setText(I18n.getMessage("jsite.menu.options"));
304 helpMenu.setText(I18n.getMessage("jsite.menu.help"));
305 for (Map.Entry<Locale, Action> languageActionEntry : languageActions.entrySet()) {
306 languageActionEntry.getValue().putValue(Action.NAME, I18n.getMessage("jsite.menu.language." + languageActionEntry.getKey().getLanguage()));
315 * Initializes all pages.
317 private void initPages() {
318 NodeManagerPage nodeManagerPage = new NodeManagerPage(wizard);
319 nodeManagerPage.setName("page.node-manager");
320 nodeManagerPage.addNodeManagerListener(this);
321 nodeManagerPage.setNodes(configuration.getNodes());
322 pages.put(PageType.PAGE_NODE_MANAGER, nodeManagerPage);
324 ProjectPage projectPage = new ProjectPage(wizard);
325 projectPage.setName("page.project");
326 projectPage.setProjects(configuration.getProjects());
327 projectPage.setFreenetInterface(freenetInterface);
328 projectPage.addListSelectionListener(this);
329 pages.put(PageType.PAGE_PROJECTS, projectPage);
331 ProjectFilesPage projectFilesPage = new ProjectFilesPage(wizard);
332 projectFilesPage.setName("page.project.files");
333 pages.put(PageType.PAGE_PROJECT_FILES, projectFilesPage);
335 ProjectInsertPage projectInsertPage = new ProjectInsertPage(wizard);
336 projectInsertPage.setName("page.project.insert");
337 projectInsertPage.setFreenetInterface(freenetInterface);
338 pages.put(PageType.PAGE_INSERT_PROJECT, projectInsertPage);
340 PreferencesPage preferencesPage = new PreferencesPage(wizard);
341 preferencesPage.setName("page.preferences");
342 preferencesPage.setTempDirectory(configuration.getTempDirectory());
343 pages.put(PageType.PAGE_PREFERENCES, preferencesPage);
347 * Shows the page with the given type.
350 * The page type to show
352 private void showPage(PageType pageType) {
353 wizard.setPreviousEnabled(pageType.ordinal() > 0);
354 wizard.setNextEnabled(pageType.ordinal() < (pages.size() - 1));
355 wizard.setPage(pages.get(pageType));
356 wizard.setTitle(pages.get(pageType).getHeading() + " - jSite");
360 * Returns whether a configuration file would be overwritten when calling
361 * {@link #saveConfiguration()}.
363 * @return {@code true} if {@link #saveConfiguration()} would overwrite an
364 * existing file, {@code false} otherwise
366 private boolean isOverwritingConfiguration() {
367 return configuration.getConfigurationLocator().hasFile(configuration.getConfigurationDirectory());
371 * Saves the configuration.
373 * @return <code>true</code> if the configuration could be saved,
374 * <code>false</code> otherwise
376 private boolean saveConfiguration() {
377 NodeManagerPage nodeManagerPage = (NodeManagerPage) pages.get(PageType.PAGE_NODE_MANAGER);
378 configuration.setNodes(nodeManagerPage.getNodes());
379 if (selectedNode != null) {
380 configuration.setSelectedNode(selectedNode);
383 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
384 configuration.setProjects(projectPage.getProjects());
386 PreferencesPage preferencesPage = (PreferencesPage) pages.get(PageType.PAGE_PREFERENCES);
387 configuration.setTempDirectory(preferencesPage.getTempDirectory());
389 return configuration.save();
393 * Finds a supported locale for the given locale.
396 * The locale to find a supported locale for
397 * @return The supported locale that was found, or the default locale if no
398 * supported locale could be found
400 private Locale findSupportedLocale(Locale forLocale) {
401 for (Locale locale : SUPPORTED_LOCALES) {
402 if (locale.equals(forLocale)) {
406 for (Locale locale : SUPPORTED_LOCALES) {
407 if (locale.getCountry().equals(forLocale.getCountry()) && locale.getLanguage().equals(forLocale.getLanguage())) {
411 for (Locale locale : SUPPORTED_LOCALES) {
412 if (locale.getLanguage().equals(forLocale.getLanguage())) {
416 return SUPPORTED_LOCALES[0];
420 * Returns the version.
422 * @return The version
424 public static final Version getVersion() {
433 * Switches the language of the interface to the given locale.
436 * The locale to switch to
438 private void switchLanguage(Locale locale) {
439 Locale supportedLocale = findSupportedLocale(locale);
440 Action languageAction = languageActions.get(supportedLocale);
441 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) languageAction.getValue("menuItem");
442 menuItem.setSelected(true);
443 I18n.setLocale(supportedLocale);
444 for (Runnable i18nRunnable : I18nContainer.getInstance()) {
447 } catch (Throwable t) {
448 /* we probably shouldn't swallow this. */
451 wizard.setPage(wizard.getPage());
452 configuration.setLocale(supportedLocale);
456 * Shows a dialog with general preferences.
458 private void optionsPreferences() {
459 ((PreferencesPage) pages.get(PageType.PAGE_PREFERENCES)).setConfigurationLocation(configuration.getConfigurationDirectory());
460 ((PreferencesPage) pages.get(PageType.PAGE_PREFERENCES)).setHasNextToJarConfiguration(configuration.getConfigurationLocator().isValidLocation(ConfigurationLocation.NEXT_TO_JAR_FILE));
461 ((PreferencesPage) pages.get(PageType.PAGE_PREFERENCES)).setHasCustomConfiguration(configuration.getConfigurationLocator().isValidLocation(ConfigurationLocation.CUSTOM));
462 showPage(PageType.PAGE_PREFERENCES);
463 optionsPreferencesAction.setEnabled(false);
464 wizard.setNextEnabled(true);
465 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
469 * Shows a dialog box that shows the last version that was found by the
470 * {@link UpdateChecker}.
472 private void showLatestUpdate() {
473 Version latestVersion = updateChecker.getLatestVersion();
474 int versionDifference = latestVersion.compareTo(VERSION);
475 if (versionDifference > 0) {
476 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.update-checker.latest-version.newer.message"), VERSION, latestVersion), I18n.getMessage("jsite.update-checker.latest-version.title"), JOptionPane.INFORMATION_MESSAGE);
477 } else if (versionDifference < 0) {
478 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.update-checker.latest-version.older.message"), VERSION, latestVersion), I18n.getMessage("jsite.update-checker.latest-version.title"), JOptionPane.INFORMATION_MESSAGE);
480 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.update-checker.latest-version.okay.message"), VERSION, latestVersion), I18n.getMessage("jsite.update-checker.latest-version.title"), JOptionPane.INFORMATION_MESSAGE);
485 // INTERFACE ListSelectionListener
491 public void valueChanged(ListSelectionEvent e) {
492 JList list = (JList) e.getSource();
493 int selectedRow = list.getSelectedIndex();
494 wizard.setNextEnabled(selectedRow > -1);
498 // INTERFACE WizardListener
504 public void wizardNextPressed(TWizard wizard) {
505 String pageName = wizard.getPage().getName();
506 if ("page.node-manager".equals(pageName)) {
507 showPage(PageType.PAGE_PROJECTS);
508 } else if ("page.project".equals(pageName)) {
509 ProjectPage projectPage = (ProjectPage) wizard.getPage();
510 Project project = projectPage.getSelectedProject();
511 if ((project.getLocalPath() == null) || (project.getLocalPath().trim().length() == 0)) {
512 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.warning.no-local-path"), null, JOptionPane.ERROR_MESSAGE);
515 if ((project.getPath() == null) || (project.getPath().trim().length() == 0)) {
516 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.warning.no-path"), null, JOptionPane.ERROR_MESSAGE);
519 ((ProjectFilesPage) pages.get(PageType.PAGE_PROJECT_FILES)).setProject(project);
520 ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).setProject(project);
521 showPage(PageType.PAGE_PROJECT_FILES);
522 } else if ("page.project.files".equals(pageName)) {
523 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
524 Project project = projectPage.getSelectedProject();
525 if (selectedNode == null) {
526 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.error.no-node-selected"), null, JOptionPane.ERROR_MESSAGE);
529 CheckReport checkReport = ProjectInserter.validateProject(project);
530 for (Issue issue : checkReport) {
531 if (issue.isFatal()) {
532 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite." + issue.getErrorKey()), (Object[]) issue.getParameters()), null, JOptionPane.ERROR_MESSAGE);
535 if (JOptionPane.showConfirmDialog(wizard, MessageFormat.format(I18n.getMessage("jsite." + issue.getErrorKey()), (Object[]) issue.getParameters()), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
539 boolean nodeRunning = false;
541 nodeRunning = freenetInterface.isNodePresent();
542 } catch (IOException e) {
546 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.error.no-node-running"), null, JOptionPane.ERROR_MESSAGE);
549 configuration.save();
550 showPage(PageType.PAGE_INSERT_PROJECT);
551 ProjectInsertPage projectInsertPage = (ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT);
552 String tempDirectory = ((PreferencesPage) pages.get(PageType.PAGE_PREFERENCES)).getTempDirectory();
553 projectInsertPage.setTempDirectory(tempDirectory);
554 projectInsertPage.startInsert();
555 nodeMenu.setEnabled(false);
556 optionsPreferencesAction.setEnabled(false);
557 } else if ("page.project.insert".equals(pageName)) {
558 ProjectInsertPage projectInsertPage = (ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT);
559 if (projectInsertPage.isRunning()) {
560 projectInsertPage.stopInsert();
562 showPage(PageType.PAGE_PROJECTS);
563 nodeMenu.setEnabled(true);
564 optionsPreferencesAction.setEnabled(true);
566 } else if ("page.preferences".equals(pageName)) {
567 PreferencesPage preferencesPage = (PreferencesPage) pages.get(PageType.PAGE_PREFERENCES);
568 showPage(PageType.PAGE_PROJECTS);
569 optionsPreferencesAction.setEnabled(true);
570 configuration.setConfigurationLocation(preferencesPage.getConfigurationLocation());
577 public void wizardPreviousPressed(TWizard wizard) {
578 String pageName = wizard.getPage().getName();
579 if ("page.project".equals(pageName) || "page.preferences".equals(pageName)) {
580 showPage(PageType.PAGE_NODE_MANAGER);
581 optionsPreferencesAction.setEnabled(true);
582 } else if ("page.project.files".equals(pageName)) {
583 showPage(PageType.PAGE_PROJECTS);
584 } else if ("page.project.insert".equals(pageName)) {
585 showPage(PageType.PAGE_PROJECT_FILES);
592 public void wizardQuitPressed(TWizard wizard) {
593 if (((ProjectPage) pages.get(PageType.PAGE_PROJECTS)).wasUriCopied() || ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).wasUriCopied()) {
594 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.use-clipboard-now"));
596 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.question"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
597 if (isOverwritingConfiguration()) {
598 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quite.overwrite-configuration"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
599 if (saveConfiguration()) {
604 if (saveConfiguration()) {
608 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.config-not-saved"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
615 // INTERFACE NodeManagerListener
621 public void nodesUpdated(Node[] nodes) {
622 nodeMenu.removeAll();
623 ButtonGroup nodeButtonGroup = new ButtonGroup();
624 Node newSelectedNode = null;
625 for (Node node : nodes) {
626 JRadioButtonMenuItem nodeMenuItem = new JRadioButtonMenuItem(node.getName());
627 nodeMenuItem.putClientProperty("Node", node);
628 nodeMenuItem.addActionListener(this);
629 nodeButtonGroup.add(nodeMenuItem);
630 if (node.equals(selectedNode)) {
631 newSelectedNode = node;
632 nodeMenuItem.setSelected(true);
634 nodeMenu.add(nodeMenuItem);
636 nodeMenu.addSeparator();
637 nodeMenu.add(manageNodeAction);
638 selectedNode = newSelectedNode;
639 freenetInterface.setNode(selectedNode);
645 public void nodeSelected(Node node) {
646 for (Component menuItem : nodeMenu.getMenuComponents()) {
647 if (menuItem instanceof JMenuItem) {
648 if (node.equals(((JMenuItem) menuItem).getClientProperty("Node"))) {
649 ((JMenuItem) menuItem).setSelected(true);
653 freenetInterface.setNode(node);
658 // INTERFACE ActionListener
664 public void actionPerformed(ActionEvent e) {
665 Object source = e.getSource();
666 if (source instanceof JRadioButtonMenuItem) {
667 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) source;
668 Node node = (Node) menuItem.getClientProperty("Node");
670 freenetInterface.setNode(selectedNode);
675 // INTERFACE UpdateListener
681 public void foundUpdateData(Version foundVersion, long versionTimestamp) {
682 logger.log(Level.FINEST, "Found version {0} from {1,date}.", new Object[] { foundVersion, versionTimestamp });
683 if (foundVersion.compareTo(VERSION) > 0) {
684 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.update-checker.found-version.message"), foundVersion.toString(), new Date(versionTimestamp)), I18n.getMessage("jsite.update-checker.found-version.title"), JOptionPane.INFORMATION_MESSAGE);
693 * Main method that is called by the VM.
696 * The command-line arguments
698 public static void main(String[] args) {
699 /* initialize logger. */
700 Logger logger = Logger.getLogger("de.todesbaum");
701 Handler handler = new ConsoleHandler();
702 logger.addHandler(handler);
703 String configFilename = null;
704 boolean nextIsConfigFilename = false;
705 for (String argument : args) {
706 if (nextIsConfigFilename) {
707 configFilename = argument;
708 nextIsConfigFilename = false;
710 if ("--help".equals(argument)) {
713 } else if ("--debug".equals(argument)) {
714 logger.setLevel(Level.ALL);
715 handler.setLevel(Level.ALL);
716 } else if ("--config-file".equals(argument)) {
717 nextIsConfigFilename = true;
720 if (nextIsConfigFilename) {
721 System.out.println("--config-file needs parameter!");
724 new Main(configFilename);
728 * Prints a small syntax help.
730 private static void printHelp() {
731 System.out.println("--help\tshows this cruft");
732 System.out.println("--debug\tenables some debug output");
733 System.out.println("--config-file <file>\tuse specified configuration file");