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.event.ActionEvent;
23 import java.awt.event.ActionListener;
25 import java.io.IOException;
26 import java.text.MessageFormat;
27 import java.util.Arrays;
28 import java.util.Date;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Locale;
34 import java.util.Map.Entry;
35 import java.util.logging.ConsoleHandler;
36 import java.util.logging.Handler;
37 import java.util.logging.Level;
38 import java.util.logging.Logger;
40 import javax.swing.AbstractAction;
41 import javax.swing.Action;
42 import javax.swing.ButtonGroup;
43 import javax.swing.Icon;
44 import javax.swing.JList;
45 import javax.swing.JMenu;
46 import javax.swing.JMenuBar;
47 import javax.swing.JOptionPane;
48 import javax.swing.JPanel;
49 import javax.swing.JRadioButtonMenuItem;
50 import javax.swing.event.ListSelectionEvent;
51 import javax.swing.event.ListSelectionListener;
53 import de.todesbaum.jsite.application.FileOption;
54 import de.todesbaum.jsite.application.Freenet7Interface;
55 import de.todesbaum.jsite.application.Node;
56 import de.todesbaum.jsite.application.Project;
57 import de.todesbaum.jsite.application.UpdateChecker;
58 import de.todesbaum.jsite.application.UpdateListener;
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.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, 8);
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, Locale.ITALIAN, new Locale("pl") };
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 if (configFilename != null) {
166 configuration = new Configuration(configFilename);
168 configuration = new Configuration();
170 Locale.setDefault(configuration.getLocale());
171 I18n.setLocale(configuration.getLocale());
172 if (!configuration.createLockFile()) {
173 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"));
175 throw new IllegalStateException("Lockfile override not active, refusing start.");
177 configuration.removeLockfileOnExit();
179 wizard = new TWizard();
181 wizard.setJMenuBar(createMenuBar());
182 wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
183 wizard.setPreviousEnabled(false);
184 wizard.setNextEnabled(true);
185 wizard.addWizardListener(this);
186 jSiteIcon = IconLoader.loadIcon("/jsite-icon.png");
187 wizard.setIcon(jSiteIcon);
189 updateChecker = new UpdateChecker(freenetInterface);
190 updateChecker.addUpdateListener(this);
191 updateChecker.start();
194 showPage(PageType.PAGE_PROJECTS);
198 * Creates all actions.
200 private void createActions() {
201 for (final Locale locale : SUPPORTED_LOCALES) {
202 languageActions.put(locale, new AbstractAction(I18n.getMessage("jsite.menu.language." + locale.getLanguage()), IconLoader.loadIcon("/flag-" + locale.getLanguage() + ".png")) {
204 @SuppressWarnings("synthetic-access")
205 public void actionPerformed(ActionEvent actionEvent) {
206 switchLanguage(locale);
210 manageNodeAction = new AbstractAction(I18n.getMessage("jsite.menu.nodes.manage-nodes")) {
212 @SuppressWarnings("synthetic-access")
213 public void actionPerformed(ActionEvent actionEvent) {
214 showPage(PageType.PAGE_NODE_MANAGER);
215 wizard.setPreviousName(I18n.getMessage("jsite.wizard.previous"));
216 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
219 optionsPreferencesAction = new AbstractAction(I18n.getMessage("jsite.menu.options.preferences")) {
225 @SuppressWarnings("synthetic-access")
226 public void actionPerformed(ActionEvent actionEvent) {
227 optionsPreferences();
230 checkForUpdatesAction = new AbstractAction(I18n.getMessage("jsite.menu.help.check-for-updates")) {
235 @SuppressWarnings("synthetic-access")
236 public void actionPerformed(ActionEvent actionEvent) {
240 aboutAction = new AbstractAction(I18n.getMessage("jsite.menu.help.about")) {
242 @SuppressWarnings("synthetic-access")
243 public void actionPerformed(ActionEvent e) {
244 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.about.message"), getVersion().toString()), null, JOptionPane.INFORMATION_MESSAGE, jSiteIcon);
248 I18nContainer.getInstance().registerRunnable(new Runnable() {
250 @SuppressWarnings("synthetic-access")
252 manageNodeAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.nodes.manage-nodes"));
253 optionsPreferencesAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.options.preferences"));
254 checkForUpdatesAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.help.check-for-updates"));
255 aboutAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.help.about"));
261 * Creates the menu bar.
263 * @return The menu bar
265 private JMenuBar createMenuBar() {
266 JMenuBar menuBar = new JMenuBar();
267 final JMenu languageMenu = new JMenu(I18n.getMessage("jsite.menu.languages"));
268 menuBar.add(languageMenu);
269 ButtonGroup languageButtonGroup = new ButtonGroup();
270 for (Locale locale : SUPPORTED_LOCALES) {
271 Action languageAction = languageActions.get(locale);
272 JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(languageActions.get(locale));
273 if (locale.equals(Locale.getDefault())) {
274 menuItem.setSelected(true);
276 languageAction.putValue("menuItem", menuItem);
277 languageButtonGroup.add(menuItem);
278 languageMenu.add(menuItem);
280 nodeMenu = new JMenu(I18n.getMessage("jsite.menu.nodes"));
281 menuBar.add(nodeMenu);
282 selectedNode = configuration.getSelectedNode();
283 nodesUpdated(configuration.getNodes());
285 final JMenu optionsMenu = new JMenu(I18n.getMessage("jsite.menu.options"));
286 menuBar.add(optionsMenu);
287 optionsMenu.add(optionsPreferencesAction);
289 /* evil hack to right-align the help menu */
290 JPanel panel = new JPanel();
291 panel.setOpaque(false);
294 final JMenu helpMenu = new JMenu(I18n.getMessage("jsite.menu.help"));
295 menuBar.add(helpMenu);
296 helpMenu.add(checkForUpdatesAction);
297 helpMenu.add(aboutAction);
299 I18nContainer.getInstance().registerRunnable(new Runnable() {
301 @SuppressWarnings("synthetic-access")
303 languageMenu.setText(I18n.getMessage("jsite.menu.languages"));
304 nodeMenu.setText(I18n.getMessage("jsite.menu.nodes"));
305 optionsMenu.setText(I18n.getMessage("jsite.menu.options"));
306 helpMenu.setText(I18n.getMessage("jsite.menu.help"));
307 for (Map.Entry<Locale, Action> languageActionEntry : languageActions.entrySet()) {
308 languageActionEntry.getValue().putValue(Action.NAME, I18n.getMessage("jsite.menu.language." + languageActionEntry.getKey().getLanguage()));
317 * Initializes all pages.
319 private void initPages() {
320 NodeManagerPage nodeManagerPage = new NodeManagerPage(wizard);
321 nodeManagerPage.setName("page.node-manager");
322 nodeManagerPage.addNodeManagerListener(this);
323 nodeManagerPage.setNodes(configuration.getNodes());
324 pages.put(PageType.PAGE_NODE_MANAGER, nodeManagerPage);
326 ProjectPage projectPage = new ProjectPage(wizard);
327 projectPage.setName("page.project");
328 projectPage.setProjects(configuration.getProjects());
329 projectPage.setFreenetInterface(freenetInterface);
330 projectPage.addListSelectionListener(this);
331 pages.put(PageType.PAGE_PROJECTS, projectPage);
333 ProjectFilesPage projectFilesPage = new ProjectFilesPage(wizard);
334 projectFilesPage.setName("page.project.files");
335 pages.put(PageType.PAGE_PROJECT_FILES, projectFilesPage);
337 ProjectInsertPage projectInsertPage = new ProjectInsertPage(wizard);
338 projectInsertPage.setName("page.project.insert");
339 projectInsertPage.setFreenetInterface(freenetInterface);
340 pages.put(PageType.PAGE_INSERT_PROJECT, projectInsertPage);
342 PreferencesPage preferencesPage = new PreferencesPage(wizard);
343 preferencesPage.setName("page.preferences");
344 preferencesPage.setTempDirectory(configuration.getTempDirectory());
345 pages.put(PageType.PAGE_PREFERENCES, preferencesPage);
349 * Shows the page with the given type.
352 * The page type to show
354 private void showPage(PageType pageType) {
355 wizard.setPreviousEnabled(pageType.ordinal() > 0);
356 wizard.setNextEnabled(pageType.ordinal() < (pages.size() - 1));
357 wizard.setPage(pages.get(pageType));
358 wizard.setTitle(pages.get(pageType).getHeading() + " - jSite");
362 * Saves the configuration.
364 * @return <code>true</code> if the configuration could be saved,
365 * <code>false</code> otherwise
367 private boolean saveConfiguration() {
368 NodeManagerPage nodeManagerPage = (NodeManagerPage) pages.get(PageType.PAGE_NODE_MANAGER);
369 configuration.setNodes(nodeManagerPage.getNodes());
370 if (selectedNode != null) {
371 configuration.setSelectedNode(selectedNode);
374 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
375 configuration.setProjects(projectPage.getProjects());
377 PreferencesPage preferencesPage = (PreferencesPage) pages.get(PageType.PAGE_PREFERENCES);
378 configuration.setTempDirectory(preferencesPage.getTempDirectory());
380 return configuration.save();
384 * Finds a supported locale for the given locale.
387 * The locale to find a supported locale for
388 * @return The supported locale that was found, or the default locale if no
389 * supported locale could be found
391 private Locale findSupportedLocale(Locale forLocale) {
392 for (Locale locale : SUPPORTED_LOCALES) {
393 if (locale.equals(forLocale)) {
397 for (Locale locale : SUPPORTED_LOCALES) {
398 if (locale.getCountry().equals(forLocale.getCountry()) && locale.getLanguage().equals(forLocale.getLanguage())) {
402 for (Locale locale : SUPPORTED_LOCALES) {
403 if (locale.getLanguage().equals(forLocale.getLanguage())) {
407 return SUPPORTED_LOCALES[0];
411 * Returns the version.
413 * @return The version
415 public static final Version getVersion() {
424 * Switches the language of the interface to the given locale.
427 * The locale to switch to
429 private void switchLanguage(Locale locale) {
430 Locale supportedLocale = findSupportedLocale(locale);
431 Action languageAction = languageActions.get(supportedLocale);
432 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) languageAction.getValue("menuItem");
433 menuItem.setSelected(true);
434 I18n.setLocale(supportedLocale);
435 for (Runnable i18nRunnable : I18nContainer.getInstance()) {
438 } catch (Throwable t) {
439 /* we probably shouldn't swallow this. */
442 wizard.setPage(wizard.getPage());
443 configuration.setLocale(supportedLocale);
447 * Shows a dialog with general preferences.
449 private void optionsPreferences() {
450 showPage(PageType.PAGE_PREFERENCES);
451 optionsPreferencesAction.setEnabled(false);
452 wizard.setNextEnabled(true);
453 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
457 * Shows a dialog box that shows the last version that was found by the
458 * {@link UpdateChecker}.
460 private void showLatestUpdate() {
461 Version latestVersion = updateChecker.getLatestVersion();
462 int versionDifference = latestVersion.compareTo(VERSION);
463 if (versionDifference > 0) {
464 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);
465 } else if (versionDifference < 0) {
466 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);
468 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);
473 // INTERFACE ListSelectionListener
479 public void valueChanged(ListSelectionEvent e) {
480 JList list = (JList) e.getSource();
481 int selectedRow = list.getSelectedIndex();
482 wizard.setNextEnabled(selectedRow > -1);
486 // INTERFACE WizardListener
492 public void wizardNextPressed(TWizard wizard) {
493 String pageName = wizard.getPage().getName();
494 if ("page.node-manager".equals(pageName)) {
495 showPage(PageType.PAGE_PROJECTS);
496 } else if ("page.project".equals(pageName)) {
497 ProjectPage projectPage = (ProjectPage) wizard.getPage();
498 Project project = projectPage.getSelectedProject();
499 if ((project.getLocalPath() == null) || (project.getLocalPath().trim().length() == 0)) {
500 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.no-local-path"), null, JOptionPane.ERROR_MESSAGE);
503 if ((project.getPath() == null) || (project.getPath().trim().length() == 0)) {
504 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.no-path"), null, JOptionPane.ERROR_MESSAGE);
507 ((ProjectFilesPage) pages.get(PageType.PAGE_PROJECT_FILES)).setProject(project);
508 ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).setProject(project);
509 showPage(PageType.PAGE_PROJECT_FILES);
510 } else if ("page.project.files".equals(pageName)) {
511 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
512 Project project = projectPage.getSelectedProject();
513 if (selectedNode == null) {
514 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-node-selected"), null, JOptionPane.ERROR_MESSAGE);
517 if ((project.getIndexFile() == null) || (project.getIndexFile().length() == 0)) {
518 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.empty-index"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
522 File indexFile = new File(project.getLocalPath(), project.getIndexFile());
523 if (!indexFile.exists()) {
524 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.index-missing"), null, JOptionPane.ERROR_MESSAGE);
528 String indexFile = project.getIndexFile();
529 boolean hasIndexFile = (indexFile != null);
530 if (hasIndexFile && !project.getFileOption(indexFile).getContainer().equals("")) {
531 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.container-index"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
535 List<String> allowedIndexContentTypes = Arrays.asList("text/html", "application/xhtml+xml");
536 if (hasIndexFile && !allowedIndexContentTypes.contains(project.getFileOption(indexFile).getMimeType())) {
537 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.index-not-html"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
541 Map<String, FileOption> fileOptions = project.getFileOptions();
542 Set<Entry<String, FileOption>> fileOptionEntries = fileOptions.entrySet();
543 for (Entry<String, FileOption> fileOptionEntry : fileOptionEntries) {
544 FileOption fileOption = fileOptionEntry.getValue();
545 if (!fileOption.isInsert() && ((fileOption.getCustomKey().length() == 0) || "CHK@".equals(fileOption.getCustomKey()))) {
546 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.project-files.no-custom-key"), fileOptionEntry.getKey()), null, JOptionPane.ERROR_MESSAGE);
550 boolean nodeRunning = false;
552 nodeRunning = freenetInterface.isNodePresent();
553 } catch (IOException e) {
557 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-node-running"), null, JOptionPane.ERROR_MESSAGE);
560 configuration.save();
561 showPage(PageType.PAGE_INSERT_PROJECT);
562 ProjectInsertPage projectInsertPage = (ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT);
563 String tempDirectory = ((PreferencesPage) pages.get(PageType.PAGE_PREFERENCES)).getTempDirectory();
564 projectInsertPage.setTempDirectory(tempDirectory);
565 projectInsertPage.startInsert();
566 nodeMenu.setEnabled(false);
567 optionsPreferencesAction.setEnabled(false);
568 } else if ("page.project.insert".equals(pageName)) {
569 showPage(PageType.PAGE_PROJECTS);
570 nodeMenu.setEnabled(true);
571 optionsPreferencesAction.setEnabled(true);
572 } else if ("page.preferences".equals(pageName)) {
573 showPage(PageType.PAGE_PROJECTS);
574 optionsPreferencesAction.setEnabled(true);
581 public void wizardPreviousPressed(TWizard wizard) {
582 String pageName = wizard.getPage().getName();
583 if ("page.project".equals(pageName)) {
584 showPage(PageType.PAGE_NODE_MANAGER);
585 } else if ("page.project.files".equals(pageName)) {
586 showPage(PageType.PAGE_PROJECTS);
587 } else if ("page.project.insert".equals(pageName)) {
588 showPage(PageType.PAGE_PROJECT_FILES);
595 public void wizardQuitPressed(TWizard wizard) {
596 if (((ProjectPage) pages.get(PageType.PAGE_PROJECTS)).wasUriCopied() || ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).wasUriCopied()) {
597 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.use-clipboard-now"));
599 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.question"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
600 if (saveConfiguration()) {
603 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.config-not-saved"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
610 // INTERFACE NodeManagerListener
616 public void nodesUpdated(Node[] nodes) {
617 nodeMenu.removeAll();
618 ButtonGroup nodeButtonGroup = new ButtonGroup();
619 Node newSelectedNode = null;
620 for (Node node : nodes) {
621 JRadioButtonMenuItem nodeMenuItem = new JRadioButtonMenuItem(node.getName());
622 nodeMenuItem.putClientProperty("Node", node);
623 nodeMenuItem.addActionListener(this);
624 nodeButtonGroup.add(nodeMenuItem);
625 if (node.equals(selectedNode)) {
626 newSelectedNode = node;
627 nodeMenuItem.setSelected(true);
629 nodeMenu.add(nodeMenuItem);
631 nodeMenu.addSeparator();
632 nodeMenu.add(manageNodeAction);
633 selectedNode = newSelectedNode;
634 freenetInterface.setNode(selectedNode);
640 public void actionPerformed(ActionEvent e) {
641 Object source = e.getSource();
642 if (source instanceof JRadioButtonMenuItem) {
643 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) source;
644 Node node = (Node) menuItem.getClientProperty("Node");
646 freenetInterface.setNode(selectedNode);
651 // INTERFACE UpdateListener
657 public void foundUpdateData(Version foundVersion, long versionTimestamp) {
658 logger.log(Level.FINEST, "Found version {0} from {1,date}.", new Object[] { foundVersion, versionTimestamp });
659 if (foundVersion.compareTo(VERSION) > 0) {
660 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);
669 * Main method that is called by the VM.
672 * The command-line arguments
674 public static void main(String[] args) {
675 /* initialize logger. */
676 Logger logger = Logger.getLogger("de.todesbaum");
677 Handler handler = new ConsoleHandler();
678 logger.addHandler(handler);
679 String configFilename = null;
680 boolean nextIsConfigFilename = false;
681 for (String argument : args) {
682 if (nextIsConfigFilename) {
683 configFilename = argument;
684 nextIsConfigFilename = false;
686 if ("--help".equals(argument)) {
689 } else if ("--debug".equals(argument)) {
690 logger.setLevel(Level.ALL);
691 handler.setLevel(Level.ALL);
692 } else if ("--config-file".equals(argument)) {
693 nextIsConfigFilename = true;
696 if (nextIsConfigFilename) {
697 System.out.println("--config-file needs parameter!");
700 new Main(configFilename);
704 * Prints a small syntax help.
706 private static void printHelp() {
707 System.out.println("--help\tshows this cruft");
708 System.out.println("--debug\tenables some debug output");
709 System.out.println("--config-file <file>\tuse specified configuration file");