2 * jSite - a tool for uploading websites into Freenet
3 * Copyright (C) 2006-2009 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;
26 import java.io.IOException;
27 import java.text.MessageFormat;
28 import java.util.Date;
29 import java.util.HashMap;
30 import java.util.Locale;
32 import java.util.logging.ConsoleHandler;
33 import java.util.logging.Handler;
34 import java.util.logging.Level;
35 import java.util.logging.Logger;
37 import javax.swing.AbstractAction;
38 import javax.swing.Action;
39 import javax.swing.ButtonGroup;
40 import javax.swing.Icon;
41 import javax.swing.JList;
42 import javax.swing.JMenu;
43 import javax.swing.JMenuBar;
44 import javax.swing.JMenuItem;
45 import javax.swing.JOptionPane;
46 import javax.swing.JPanel;
47 import javax.swing.JRadioButtonMenuItem;
48 import javax.swing.event.ListSelectionEvent;
49 import javax.swing.event.ListSelectionListener;
51 import de.todesbaum.jsite.application.Freenet7Interface;
52 import de.todesbaum.jsite.application.Node;
53 import de.todesbaum.jsite.application.Project;
54 import de.todesbaum.jsite.application.ProjectInserter;
55 import de.todesbaum.jsite.application.UpdateChecker;
56 import de.todesbaum.jsite.application.UpdateListener;
57 import de.todesbaum.jsite.application.ProjectInserter.CheckReport;
58 import de.todesbaum.jsite.application.ProjectInserter.Issue;
59 import de.todesbaum.jsite.gui.NodeManagerListener;
60 import de.todesbaum.jsite.gui.NodeManagerPage;
61 import de.todesbaum.jsite.gui.PreferencesPage;
62 import de.todesbaum.jsite.gui.ProjectFilesPage;
63 import de.todesbaum.jsite.gui.ProjectInsertPage;
64 import de.todesbaum.jsite.gui.ProjectPage;
65 import de.todesbaum.jsite.i18n.I18n;
66 import de.todesbaum.jsite.i18n.I18nContainer;
67 import de.todesbaum.jsite.main.Configuration.ConfigurationDirectory;
68 import de.todesbaum.util.image.IconLoader;
69 import de.todesbaum.util.swing.TWizard;
70 import de.todesbaum.util.swing.TWizardPage;
71 import de.todesbaum.util.swing.WizardListener;
74 * The main class that ties together everything.
76 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
78 public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener, UpdateListener {
81 private static final Logger logger = Logger.getLogger(Main.class.getName());
84 private static final Version VERSION = new Version(0, 9, 2);
86 /** The configuration. */
87 private Configuration configuration;
89 /** The freenet interface. */
90 private Freenet7Interface freenetInterface = new Freenet7Interface();
92 /** The update checker. */
93 private final UpdateChecker updateChecker;
95 /** The jSite icon. */
96 private Icon jSiteIcon;
99 * Enumeration for all possible pages.
101 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
103 private static enum PageType {
105 /** The node manager page. */
108 /** The project page. */
111 /** The project files page. */
114 /** The project insert page. */
117 /** The preferences page. */
122 /** The supported locales. */
123 private static final Locale[] SUPPORTED_LOCALES = new Locale[] { Locale.ENGLISH, Locale.GERMAN, Locale.FRENCH };
125 /** The actions that switch the language. */
126 private Map<Locale, Action> languageActions = new HashMap<Locale, Action>();
128 /** The “manage nodes” action. */
129 private Action manageNodeAction;
131 /** The “preferences” action. */
132 private Action optionsPreferencesAction;
134 /** The “check for updates” action. */
135 private Action checkForUpdatesAction;
137 /** The “about jSite” action. */
138 private Action aboutAction;
141 private TWizard wizard;
143 /** The node menu. */
144 private JMenu nodeMenu;
146 /** The currently selected node. */
147 private Node selectedNode;
149 /** Mapping from page type to page. */
150 private final Map<PageType, TWizardPage> pages = new HashMap<PageType, TWizardPage>();
153 * Creates a new core with the default configuration file.
160 * Creates a new core with the given configuration from the given file.
162 * @param configFilename
163 * The name of the configuration file
165 private Main(String configFilename) {
166 if (configFilename != null) {
167 configuration = new Configuration(configFilename);
169 /* are we executed from a JAR file? */
170 String resource = getClass().getResource("/de/todesbaum/jsite/i18n/jSite.properties").toString();
171 if (resource.startsWith("jar:")) {
172 String jarFileLocation = resource.substring(9, resource.indexOf(".jar!") + 4);
173 String jarFileDirectory = new File(jarFileLocation).getParent();
174 File configurationFile = new File(jarFileDirectory, "jSite.conf");
175 if (configurationFile.exists()) {
176 configuration = new Configuration(configurationFile.getAbsolutePath());
177 configuration.setConfigurationDirectory(ConfigurationDirectory.NEXT_TO_JAR_FILE);
180 if (configuration == null) {
181 configuration = new Configuration();
184 Locale.setDefault(configuration.getLocale());
185 I18n.setLocale(configuration.getLocale());
186 if (!configuration.createLockFile()) {
187 int option = JOptionPane.showOptionDialog(null, I18n.getMessage("jsite.main.already-running"), "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { I18n.getMessage("jsite.main.already-running.override"), I18n.getMessage("jsite.wizard.quit") }, I18n.getMessage("jsite.wizard.quit"));
189 throw new IllegalStateException("Lockfile override not active, refusing start.");
191 configuration.removeLockfileOnExit();
193 wizard = new TWizard();
195 wizard.setJMenuBar(createMenuBar());
196 wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
197 wizard.setPreviousEnabled(false);
198 wizard.setNextEnabled(true);
199 wizard.addWizardListener(this);
200 jSiteIcon = IconLoader.loadIcon("/jsite-icon.png");
201 wizard.setIcon(jSiteIcon);
203 updateChecker = new UpdateChecker(freenetInterface);
204 updateChecker.addUpdateListener(this);
205 updateChecker.start();
208 showPage(PageType.PAGE_PROJECTS);
212 * Creates all actions.
214 private void createActions() {
215 for (final Locale locale : SUPPORTED_LOCALES) {
216 languageActions.put(locale, new AbstractAction(I18n.getMessage("jsite.menu.language." + locale.getLanguage()), IconLoader.loadIcon("/flag-" + locale.getLanguage() + ".png")) {
218 @SuppressWarnings("synthetic-access")
219 public void actionPerformed(ActionEvent actionEvent) {
220 switchLanguage(locale);
224 manageNodeAction = new AbstractAction(I18n.getMessage("jsite.menu.nodes.manage-nodes")) {
226 @SuppressWarnings("synthetic-access")
227 public void actionPerformed(ActionEvent actionEvent) {
228 showPage(PageType.PAGE_NODE_MANAGER);
229 optionsPreferencesAction.setEnabled(true);
230 wizard.setPreviousName(I18n.getMessage("jsite.wizard.previous"));
231 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
234 optionsPreferencesAction = new AbstractAction(I18n.getMessage("jsite.menu.options.preferences")) {
239 @SuppressWarnings("synthetic-access")
240 public void actionPerformed(ActionEvent actionEvent) {
241 optionsPreferences();
244 checkForUpdatesAction = new AbstractAction(I18n.getMessage("jsite.menu.help.check-for-updates")) {
249 @SuppressWarnings("synthetic-access")
250 public void actionPerformed(ActionEvent actionEvent) {
254 aboutAction = new AbstractAction(I18n.getMessage("jsite.menu.help.about")) {
256 @SuppressWarnings("synthetic-access")
257 public void actionPerformed(ActionEvent e) {
258 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.about.message"), getVersion().toString()), null, JOptionPane.INFORMATION_MESSAGE, jSiteIcon);
262 I18nContainer.getInstance().registerRunnable(new Runnable() {
264 @SuppressWarnings("synthetic-access")
266 manageNodeAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.nodes.manage-nodes"));
267 optionsPreferencesAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.options.preferences"));
268 checkForUpdatesAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.help.check-for-updates"));
269 aboutAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.help.about"));
275 * Creates the menu bar.
277 * @return The menu bar
279 private JMenuBar createMenuBar() {
280 JMenuBar menuBar = new JMenuBar();
281 final JMenu languageMenu = new JMenu(I18n.getMessage("jsite.menu.languages"));
282 menuBar.add(languageMenu);
283 ButtonGroup languageButtonGroup = new ButtonGroup();
284 for (Locale locale : SUPPORTED_LOCALES) {
285 Action languageAction = languageActions.get(locale);
286 JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(languageActions.get(locale));
287 if (locale.equals(Locale.getDefault())) {
288 menuItem.setSelected(true);
290 languageAction.putValue("menuItem", menuItem);
291 languageButtonGroup.add(menuItem);
292 languageMenu.add(menuItem);
294 nodeMenu = new JMenu(I18n.getMessage("jsite.menu.nodes"));
295 menuBar.add(nodeMenu);
296 selectedNode = configuration.getSelectedNode();
297 nodesUpdated(configuration.getNodes());
299 final JMenu optionsMenu = new JMenu(I18n.getMessage("jsite.menu.options"));
300 menuBar.add(optionsMenu);
301 optionsMenu.add(optionsPreferencesAction);
303 /* evil hack to right-align the help menu */
304 JPanel panel = new JPanel();
305 panel.setOpaque(false);
308 final JMenu helpMenu = new JMenu(I18n.getMessage("jsite.menu.help"));
309 menuBar.add(helpMenu);
310 helpMenu.add(checkForUpdatesAction);
311 helpMenu.add(aboutAction);
313 I18nContainer.getInstance().registerRunnable(new Runnable() {
315 @SuppressWarnings("synthetic-access")
317 languageMenu.setText(I18n.getMessage("jsite.menu.languages"));
318 nodeMenu.setText(I18n.getMessage("jsite.menu.nodes"));
319 optionsMenu.setText(I18n.getMessage("jsite.menu.options"));
320 helpMenu.setText(I18n.getMessage("jsite.menu.help"));
321 for (Map.Entry<Locale, Action> languageActionEntry : languageActions.entrySet()) {
322 languageActionEntry.getValue().putValue(Action.NAME, I18n.getMessage("jsite.menu.language." + languageActionEntry.getKey().getLanguage()));
331 * Initializes all pages.
333 private void initPages() {
334 NodeManagerPage nodeManagerPage = new NodeManagerPage(wizard);
335 nodeManagerPage.setName("page.node-manager");
336 nodeManagerPage.addNodeManagerListener(this);
337 nodeManagerPage.setNodes(configuration.getNodes());
338 pages.put(PageType.PAGE_NODE_MANAGER, nodeManagerPage);
340 ProjectPage projectPage = new ProjectPage(wizard);
341 projectPage.setName("page.project");
342 projectPage.setProjects(configuration.getProjects());
343 projectPage.setFreenetInterface(freenetInterface);
344 projectPage.addListSelectionListener(this);
345 pages.put(PageType.PAGE_PROJECTS, projectPage);
347 ProjectFilesPage projectFilesPage = new ProjectFilesPage(wizard);
348 projectFilesPage.setName("page.project.files");
349 pages.put(PageType.PAGE_PROJECT_FILES, projectFilesPage);
351 ProjectInsertPage projectInsertPage = new ProjectInsertPage(wizard);
352 projectInsertPage.setName("page.project.insert");
353 projectInsertPage.setFreenetInterface(freenetInterface);
354 pages.put(PageType.PAGE_INSERT_PROJECT, projectInsertPage);
356 PreferencesPage preferencesPage = new PreferencesPage(wizard, configuration);
357 preferencesPage.setName("page.preferences");
358 preferencesPage.setTempDirectory(configuration.getTempDirectory());
359 pages.put(PageType.PAGE_PREFERENCES, preferencesPage);
363 * Shows the page with the given type.
366 * The page type to show
368 private void showPage(PageType pageType) {
369 wizard.setPreviousEnabled(pageType.ordinal() > 0);
370 wizard.setNextEnabled(pageType.ordinal() < (pages.size() - 1));
371 wizard.setPage(pages.get(pageType));
372 wizard.setTitle(pages.get(pageType).getHeading() + " - jSite");
376 * Saves the configuration.
378 * @return <code>true</code> if the configuration could be saved,
379 * <code>false</code> otherwise
381 private boolean saveConfiguration() {
382 NodeManagerPage nodeManagerPage = (NodeManagerPage) pages.get(PageType.PAGE_NODE_MANAGER);
383 configuration.setNodes(nodeManagerPage.getNodes());
384 if (selectedNode != null) {
385 configuration.setSelectedNode(selectedNode);
388 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
389 configuration.setProjects(projectPage.getProjects());
391 PreferencesPage preferencesPage = (PreferencesPage) pages.get(PageType.PAGE_PREFERENCES);
392 configuration.setTempDirectory(preferencesPage.getTempDirectory());
394 return configuration.save();
398 * Finds a supported locale for the given locale.
401 * The locale to find a supported locale for
402 * @return The supported locale that was found, or the default locale if no
403 * supported locale could be found
405 private Locale findSupportedLocale(Locale forLocale) {
406 for (Locale locale : SUPPORTED_LOCALES) {
407 if (locale.equals(forLocale)) {
411 for (Locale locale : SUPPORTED_LOCALES) {
412 if (locale.getCountry().equals(forLocale.getCountry()) && locale.getLanguage().equals(forLocale.getLanguage())) {
416 for (Locale locale : SUPPORTED_LOCALES) {
417 if (locale.getLanguage().equals(forLocale.getLanguage())) {
421 return SUPPORTED_LOCALES[0];
425 * Returns the version.
427 * @return The version
429 public static final Version getVersion() {
438 * Switches the language of the interface to the given locale.
441 * The locale to switch to
443 private void switchLanguage(Locale locale) {
444 Locale supportedLocale = findSupportedLocale(locale);
445 Action languageAction = languageActions.get(supportedLocale);
446 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) languageAction.getValue("menuItem");
447 menuItem.setSelected(true);
448 I18n.setLocale(supportedLocale);
449 for (Runnable i18nRunnable : I18nContainer.getInstance()) {
452 } catch (Throwable t) {
453 /* we probably shouldn't swallow this. */
456 wizard.setPage(wizard.getPage());
457 configuration.setLocale(supportedLocale);
461 * Shows a dialog with general preferences.
463 private void optionsPreferences() {
464 ((PreferencesPage) pages.get(PageType.PAGE_PREFERENCES)).setConfigurationDirectory(configuration.getConfigurationDirectory());
465 showPage(PageType.PAGE_PREFERENCES);
466 optionsPreferencesAction.setEnabled(false);
467 wizard.setNextEnabled(true);
468 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
472 * Shows a dialog box that shows the last version that was found by the
473 * {@link UpdateChecker}.
475 private void showLatestUpdate() {
476 Version latestVersion = updateChecker.getLatestVersion();
477 int versionDifference = latestVersion.compareTo(VERSION);
478 if (versionDifference > 0) {
479 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);
480 } else if (versionDifference < 0) {
481 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);
483 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);
488 // INTERFACE ListSelectionListener
494 public void valueChanged(ListSelectionEvent e) {
495 JList list = (JList) e.getSource();
496 int selectedRow = list.getSelectedIndex();
497 wizard.setNextEnabled(selectedRow > -1);
501 // INTERFACE WizardListener
507 public void wizardNextPressed(TWizard wizard) {
508 String pageName = wizard.getPage().getName();
509 if ("page.node-manager".equals(pageName)) {
510 showPage(PageType.PAGE_PROJECTS);
511 } else if ("page.project".equals(pageName)) {
512 ProjectPage projectPage = (ProjectPage) wizard.getPage();
513 Project project = projectPage.getSelectedProject();
514 if ((project.getLocalPath() == null) || (project.getLocalPath().trim().length() == 0)) {
515 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.warning.no-local-path"), null, JOptionPane.ERROR_MESSAGE);
518 if ((project.getPath() == null) || (project.getPath().trim().length() == 0)) {
519 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.warning.no-path"), null, JOptionPane.ERROR_MESSAGE);
522 ((ProjectFilesPage) pages.get(PageType.PAGE_PROJECT_FILES)).setProject(project);
523 ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).setProject(project);
524 showPage(PageType.PAGE_PROJECT_FILES);
525 } else if ("page.project.files".equals(pageName)) {
526 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
527 Project project = projectPage.getSelectedProject();
528 if (selectedNode == null) {
529 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.error.no-node-selected"), null, JOptionPane.ERROR_MESSAGE);
532 CheckReport checkReport = ProjectInserter.validateProject(project);
533 for (Issue issue : checkReport) {
534 if (issue.isFatal()) {
535 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite." + issue.getErrorKey()), (Object[]) issue.getParameters()), null, JOptionPane.ERROR_MESSAGE);
538 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) {
542 boolean nodeRunning = false;
544 nodeRunning = freenetInterface.isNodePresent();
545 } catch (IOException e) {
549 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.error.no-node-running"), null, JOptionPane.ERROR_MESSAGE);
552 configuration.save();
553 showPage(PageType.PAGE_INSERT_PROJECT);
554 ProjectInsertPage projectInsertPage = (ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT);
555 String tempDirectory = ((PreferencesPage) pages.get(PageType.PAGE_PREFERENCES)).getTempDirectory();
556 projectInsertPage.setTempDirectory(tempDirectory);
557 projectInsertPage.startInsert();
558 nodeMenu.setEnabled(false);
559 optionsPreferencesAction.setEnabled(false);
560 } else if ("page.project.insert".equals(pageName)) {
561 ProjectInsertPage projectInsertPage = (ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT);
562 if (projectInsertPage.isRunning()) {
563 projectInsertPage.stopInsert();
565 showPage(PageType.PAGE_PROJECTS);
566 nodeMenu.setEnabled(true);
567 optionsPreferencesAction.setEnabled(true);
569 } else if ("page.preferences".equals(pageName)) {
570 showPage(PageType.PAGE_PROJECTS);
571 optionsPreferencesAction.setEnabled(true);
578 public void wizardPreviousPressed(TWizard wizard) {
579 String pageName = wizard.getPage().getName();
580 if ("page.project".equals(pageName) || "page.preferences".equals(pageName)) {
581 showPage(PageType.PAGE_NODE_MANAGER);
582 optionsPreferencesAction.setEnabled(true);
583 } else if ("page.project.files".equals(pageName)) {
584 showPage(PageType.PAGE_PROJECTS);
585 } else if ("page.project.insert".equals(pageName)) {
586 showPage(PageType.PAGE_PROJECT_FILES);
593 public void wizardQuitPressed(TWizard wizard) {
594 if (((ProjectPage) pages.get(PageType.PAGE_PROJECTS)).wasUriCopied() || ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).wasUriCopied()) {
595 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.use-clipboard-now"));
597 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.question"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
598 if (saveConfiguration()) {
601 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.config-not-saved"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
608 // INTERFACE NodeManagerListener
614 public void nodesUpdated(Node[] nodes) {
615 nodeMenu.removeAll();
616 ButtonGroup nodeButtonGroup = new ButtonGroup();
617 Node newSelectedNode = null;
618 for (Node node : nodes) {
619 JRadioButtonMenuItem nodeMenuItem = new JRadioButtonMenuItem(node.getName());
620 nodeMenuItem.putClientProperty("Node", node);
621 nodeMenuItem.addActionListener(this);
622 nodeButtonGroup.add(nodeMenuItem);
623 if (node.equals(selectedNode)) {
624 newSelectedNode = node;
625 nodeMenuItem.setSelected(true);
627 nodeMenu.add(nodeMenuItem);
629 nodeMenu.addSeparator();
630 nodeMenu.add(manageNodeAction);
631 selectedNode = newSelectedNode;
632 freenetInterface.setNode(selectedNode);
638 public void nodeSelected(Node node) {
639 for (Component menuItem : nodeMenu.getMenuComponents()) {
640 if (menuItem instanceof JMenuItem) {
641 if (node.equals(((JMenuItem) menuItem).getClientProperty("Node"))) {
642 ((JMenuItem) menuItem).setSelected(true);
646 freenetInterface.setNode(node);
651 // INTERFACE ActionListener
657 public void actionPerformed(ActionEvent e) {
658 Object source = e.getSource();
659 if (source instanceof JRadioButtonMenuItem) {
660 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) source;
661 Node node = (Node) menuItem.getClientProperty("Node");
663 freenetInterface.setNode(selectedNode);
668 // INTERFACE UpdateListener
674 public void foundUpdateData(Version foundVersion, long versionTimestamp) {
675 logger.log(Level.FINEST, "Found version {0} from {1,date}.", new Object[] { foundVersion, versionTimestamp });
676 if (foundVersion.compareTo(VERSION) > 0) {
677 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);
686 * Main method that is called by the VM.
689 * The command-line arguments
691 public static void main(String[] args) {
692 /* initialize logger. */
693 Logger logger = Logger.getLogger("de.todesbaum");
694 Handler handler = new ConsoleHandler();
695 logger.addHandler(handler);
696 String configFilename = null;
697 boolean nextIsConfigFilename = false;
698 for (String argument : args) {
699 if (nextIsConfigFilename) {
700 configFilename = argument;
701 nextIsConfigFilename = false;
703 if ("--help".equals(argument)) {
706 } else if ("--debug".equals(argument)) {
707 logger.setLevel(Level.ALL);
708 handler.setLevel(Level.ALL);
709 } else if ("--config-file".equals(argument)) {
710 nextIsConfigFilename = true;
713 if (nextIsConfigFilename) {
714 System.out.println("--config-file needs parameter!");
717 new Main(configFilename);
721 * Prints a small syntax help.
723 private static void printHelp() {
724 System.out.println("--help\tshows this cruft");
725 System.out.println("--debug\tenables some debug output");
726 System.out.println("--config-file <file>\tuse specified configuration file");