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.Date;
28 import java.util.HashMap;
29 import java.util.Locale;
32 import java.util.Map.Entry;
33 import java.util.logging.ConsoleHandler;
34 import java.util.logging.Handler;
35 import java.util.logging.Level;
36 import java.util.logging.Logger;
38 import javax.swing.AbstractAction;
39 import javax.swing.Action;
40 import javax.swing.ButtonGroup;
41 import javax.swing.Icon;
42 import javax.swing.JList;
43 import javax.swing.JMenu;
44 import javax.swing.JMenuBar;
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.FileOption;
52 import de.todesbaum.jsite.application.Freenet7Interface;
53 import de.todesbaum.jsite.application.Node;
54 import de.todesbaum.jsite.application.Project;
55 import de.todesbaum.jsite.application.UpdateChecker;
56 import de.todesbaum.jsite.application.UpdateListener;
57 import de.todesbaum.jsite.gui.NodeManagerListener;
58 import de.todesbaum.jsite.gui.NodeManagerPage;
59 import de.todesbaum.jsite.gui.PreferencesPage;
60 import de.todesbaum.jsite.gui.ProjectFilesPage;
61 import de.todesbaum.jsite.gui.ProjectInsertPage;
62 import de.todesbaum.jsite.gui.ProjectPage;
63 import de.todesbaum.jsite.i18n.I18n;
64 import de.todesbaum.jsite.i18n.I18nContainer;
65 import de.todesbaum.util.image.IconLoader;
66 import de.todesbaum.util.swing.TWizard;
67 import de.todesbaum.util.swing.TWizardPage;
68 import de.todesbaum.util.swing.WizardListener;
71 * The main class that ties together everything.
73 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
75 public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener, UpdateListener {
78 private static final Logger logger = Logger.getLogger(Main.class.getName());
81 private static final Version VERSION = new Version(0, 8);
83 /** The configuration. */
84 private Configuration configuration;
86 /** The freenet interface. */
87 private Freenet7Interface freenetInterface = new Freenet7Interface();
89 /** The update checker. */
90 private final UpdateChecker updateChecker;
92 /** The jSite icon. */
93 private Icon jSiteIcon;
96 * Enumeration for all possible pages.
98 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
100 private static enum PageType {
102 /** The node manager page. */
105 /** The project page. */
108 /** The project files page. */
111 /** The project insert page. */
114 /** The preferences page. */
119 /** The supported locales. */
120 private static final Locale[] SUPPORTED_LOCALES = new Locale[] { Locale.ENGLISH, Locale.GERMAN, Locale.FRENCH, Locale.ITALIAN, new Locale("pl") };
122 /** The actions that switch the language. */
123 private Map<Locale, Action> languageActions = new HashMap<Locale, Action>();
125 /** The “manage nodes” action. */
126 private Action manageNodeAction;
128 /** The “preferences” action. */
129 private Action optionsPreferencesAction;
131 /** The “check for updates” action. */
132 private Action checkForUpdatesAction;
134 /** The “about jSite” action. */
135 private Action aboutAction;
138 private TWizard wizard;
140 /** The node menu. */
141 private JMenu nodeMenu;
143 /** The currently selected node. */
144 private Node selectedNode;
146 /** Mapping from page type to page. */
147 private final Map<PageType, TWizardPage> pages = new HashMap<PageType, TWizardPage>();
150 * Creates a new core with the default configuration file.
157 * Creates a new core with the given configuration from the given file.
159 * @param configFilename
160 * The name of the configuration file
162 private Main(String configFilename) {
163 if (configFilename != null) {
164 configuration = new Configuration(configFilename);
166 configuration = new Configuration();
168 Locale.setDefault(configuration.getLocale());
169 I18n.setLocale(configuration.getLocale());
170 if (!configuration.createLockFile()) {
171 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"));
173 throw new IllegalStateException("Lockfile override not active, refusing start.");
175 configuration.removeLockfileOnExit();
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 wizard.setPreviousName(I18n.getMessage("jsite.wizard.previous"));
214 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
217 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 * Saves the configuration.
362 * @return <code>true</code> if the configuration could be saved,
363 * <code>false</code> otherwise
365 private boolean saveConfiguration() {
366 NodeManagerPage nodeManagerPage = (NodeManagerPage) pages.get(PageType.PAGE_NODE_MANAGER);
367 configuration.setNodes(nodeManagerPage.getNodes());
368 if (selectedNode != null) {
369 configuration.setSelectedNode(selectedNode);
372 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
373 configuration.setProjects(projectPage.getProjects());
375 PreferencesPage preferencesPage = (PreferencesPage) pages.get(PageType.PAGE_PREFERENCES);
376 configuration.setTempDirectory(preferencesPage.getTempDirectory());
378 return configuration.save();
382 * Finds a supported locale for the given locale.
385 * The locale to find a supported locale for
386 * @return The supported locale that was found, or the default locale if no
387 * supported locale could be found
389 private Locale findSupportedLocale(Locale forLocale) {
390 for (Locale locale : SUPPORTED_LOCALES) {
391 if (locale.equals(forLocale)) {
395 for (Locale locale : SUPPORTED_LOCALES) {
396 if (locale.getCountry().equals(forLocale.getCountry()) && locale.getLanguage().equals(forLocale.getLanguage())) {
400 for (Locale locale : SUPPORTED_LOCALES) {
401 if (locale.getLanguage().equals(forLocale.getLanguage())) {
405 return SUPPORTED_LOCALES[0];
409 * Returns the version.
411 * @return The version
413 public static final Version getVersion() {
422 * Switches the language of the interface to the given locale.
425 * The locale to switch to
427 private void switchLanguage(Locale locale) {
428 Locale supportedLocale = findSupportedLocale(locale);
429 Action languageAction = languageActions.get(supportedLocale);
430 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) languageAction.getValue("menuItem");
431 menuItem.setSelected(true);
432 I18n.setLocale(supportedLocale);
433 for (Runnable i18nRunnable : I18nContainer.getInstance()) {
436 } catch (Throwable t) {
437 /* we probably shouldn't swallow this. */
440 wizard.setPage(wizard.getPage());
441 configuration.setLocale(supportedLocale);
445 * Shows a dialog with general preferences.
447 private void optionsPreferences() {
448 showPage(PageType.PAGE_PREFERENCES);
449 optionsPreferencesAction.setEnabled(false);
450 wizard.setNextEnabled(true);
451 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
455 * Shows a dialog box that shows the last version that was found by the
456 * {@link UpdateChecker}.
458 private void showLatestUpdate() {
459 Version latestVersion = updateChecker.getLatestVersion();
460 int versionDifference = latestVersion.compareTo(VERSION);
461 if (versionDifference > 0) {
462 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);
463 } else if (versionDifference < 0) {
464 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);
466 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);
471 // INTERFACE ListSelectionListener
477 public void valueChanged(ListSelectionEvent e) {
478 JList list = (JList) e.getSource();
479 int selectedRow = list.getSelectedIndex();
480 wizard.setNextEnabled(selectedRow > -1);
484 // INTERFACE WizardListener
490 public void wizardNextPressed(TWizard wizard) {
491 String pageName = wizard.getPage().getName();
492 if ("page.node-manager".equals(pageName)) {
493 showPage(PageType.PAGE_PROJECTS);
494 } else if ("page.project".equals(pageName)) {
495 ProjectPage projectPage = (ProjectPage) wizard.getPage();
496 Project project = projectPage.getSelectedProject();
497 if ((project.getLocalPath() == null) || (project.getLocalPath().trim().length() == 0)) {
498 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.no-local-path"), null, JOptionPane.ERROR_MESSAGE);
501 if ((project.getPath() == null) || (project.getPath().trim().length() == 0)) {
502 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.no-path"), null, JOptionPane.ERROR_MESSAGE);
505 ((ProjectFilesPage) pages.get(PageType.PAGE_PROJECT_FILES)).setProject(project);
506 ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).setProject(project);
507 showPage(PageType.PAGE_PROJECT_FILES);
508 } else if ("page.project.files".equals(pageName)) {
509 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
510 Project project = projectPage.getSelectedProject();
511 if (selectedNode == null) {
512 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-node-selected"), null, JOptionPane.ERROR_MESSAGE);
515 if ((project.getIndexFile() == null) || (project.getIndexFile().length() == 0)) {
516 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.empty-index"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
520 File indexFile = new File(project.getLocalPath(), project.getIndexFile());
521 if (!indexFile.exists()) {
522 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.index-missing"), null, JOptionPane.ERROR_MESSAGE);
526 String indexFile = project.getIndexFile();
527 boolean hasIndexFile = (indexFile != null);
528 if (hasIndexFile && !project.getFileOption(indexFile).getContainer().equals("")) {
529 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.container-index"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
533 if (hasIndexFile && !project.getFileOption(indexFile).getMimeType().equals("text/html")) {
534 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.index-not-html"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
538 Map<String, FileOption> fileOptions = project.getFileOptions();
539 Set<Entry<String, FileOption>> fileOptionEntries = fileOptions.entrySet();
540 for (Entry<String, FileOption> fileOptionEntry : fileOptionEntries) {
541 FileOption fileOption = fileOptionEntry.getValue();
542 if (!fileOption.isInsert() && ((fileOption.getCustomKey().length() == 0) || "CHK@".equals(fileOption.getCustomKey()))) {
543 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.project-files.no-custom-key"), fileOptionEntry.getKey()), null, JOptionPane.ERROR_MESSAGE);
547 boolean nodeRunning = false;
549 nodeRunning = freenetInterface.isNodePresent();
550 } catch (IOException e) {
554 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-node-running"), null, JOptionPane.ERROR_MESSAGE);
557 configuration.save();
558 showPage(PageType.PAGE_INSERT_PROJECT);
559 ProjectInsertPage projectInsertPage = (ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT);
560 String tempDirectory = ((PreferencesPage) pages.get(PageType.PAGE_PREFERENCES)).getTempDirectory();
561 projectInsertPage.setTempDirectory(tempDirectory);
562 projectInsertPage.startInsert();
563 nodeMenu.setEnabled(false);
564 optionsPreferencesAction.setEnabled(false);
565 } else if ("page.project.insert".equals(pageName)) {
566 showPage(PageType.PAGE_PROJECTS);
567 nodeMenu.setEnabled(true);
568 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)) {
581 showPage(PageType.PAGE_NODE_MANAGER);
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 (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.question"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
594 if (saveConfiguration()) {
597 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.config-not-saved"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
604 // INTERFACE NodeManagerListener
610 public void nodesUpdated(Node[] nodes) {
611 nodeMenu.removeAll();
612 ButtonGroup nodeButtonGroup = new ButtonGroup();
613 Node newSelectedNode = null;
614 for (Node node : nodes) {
615 JRadioButtonMenuItem nodeMenuItem = new JRadioButtonMenuItem(node.getName());
616 nodeMenuItem.putClientProperty("Node", node);
617 nodeMenuItem.addActionListener(this);
618 nodeButtonGroup.add(nodeMenuItem);
619 if (node.equals(selectedNode)) {
620 newSelectedNode = node;
621 nodeMenuItem.setSelected(true);
623 nodeMenu.add(nodeMenuItem);
625 nodeMenu.addSeparator();
626 nodeMenu.add(manageNodeAction);
627 selectedNode = newSelectedNode;
628 freenetInterface.setNode(selectedNode);
634 public void actionPerformed(ActionEvent e) {
635 Object source = e.getSource();
636 if (source instanceof JRadioButtonMenuItem) {
637 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) source;
638 Node node = (Node) menuItem.getClientProperty("Node");
640 freenetInterface.setNode(selectedNode);
645 // INTERFACE UpdateListener
651 public void foundUpdateData(Version foundVersion, long versionTimestamp) {
652 logger.log(Level.FINEST, "Found version {0} from {1,date}.", new Object[] { foundVersion, versionTimestamp });
653 if (foundVersion.compareTo(VERSION) > 0) {
654 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);
663 * Main method that is called by the VM.
666 * The command-line arguments
668 public static void main(String[] args) {
669 /* initialize logger. */
670 Logger logger = Logger.getLogger("de.todesbaum");
671 Handler handler = new ConsoleHandler();
672 logger.addHandler(handler);
673 String configFilename = null;
674 boolean nextIsConfigFilename = false;
675 for (String argument : args) {
676 if (nextIsConfigFilename) {
677 configFilename = argument;
678 nextIsConfigFilename = false;
680 if ("--help".equals(argument)) {
683 } else if ("--debug".equals(argument)) {
684 logger.setLevel(Level.ALL);
685 handler.setLevel(Level.ALL);
686 } else if ("--config-file".equals(argument)) {
687 nextIsConfigFilename = true;
690 if (nextIsConfigFilename) {
691 System.out.println("--config-file needs parameter!");
694 new Main(configFilename);
698 * Prints a small syntax help.
700 private static void printHelp() {
701 System.out.println("--help\tshows this cruft");
702 System.out.println("--debug\tenables some debug output");
703 System.out.println("--config-file <file>\tuse specified configuration file");