1 /*
2 * (C) 2002 David Carr david@carr.name
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package net.sourceforge.mflow;
20
21 import java.io.IOException;
22 import java.util.logging.ConsoleHandler;
23 import java.util.logging.FileHandler;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26
27 import javax.swing.JFrame;
28
29 import net.sourceforge.mflow.api.MFlowUI;
30 import net.sourceforge.mflow.api.MFlowUIManager;
31 import net.sourceforge.mflow.api.PluginManager;
32 import net.sourceforge.mflow.impl.PluginManagerImpl;
33
34 /***
35 * The master class for MFlow. To run MFlow, call this class' main method.
36 *
37 * @author <a href="mailto:david@carr.name">David Carr</a>
38 * @version $Revision: 1.2 $
39 * @see #main(String[])
40 */
41 public final class MFlow {
42 /***
43 * Constructs a new instance
44 *
45 * @param args the command-line arguments
46 */
47 private MFlow(final String[] args) {
48 ArgumentMaster am = new ArgumentMaster(args);
49 PluginManager pluginManager = new PluginManagerImpl();
50 MFlowUIManager uiManager = pluginManager.getUIManager();
51 MFlowUI ui = uiManager.getCurrentInstance();
52 if (ui != null && !am.containsParameter("config")) {
53 ui.init();
54 ui.getFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
55 ui.setVisible(true);
56 } else {
57 PluginManagerFrame frame = new PluginManagerFrame(pluginManager);
58 frame.pack();
59 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
60 frame.setVisible(true);
61 }
62 }
63
64 /***
65 * Runs the program Parses any command-line arguments, initializes the
66 * system, loads the configuration, and displays a UI.
67 *
68 * @param args the command-line arguments
69 */
70 public static void main(final String[] args) {
71 configureLogging();
72 new MFlow(args);
73 }
74
75 /***
76 * Configures logging for the application
77 */
78 private static void configureLogging() {
79 Logger logger = Logger.getLogger("");
80 ConsoleHandler ch = new ConsoleHandler();
81 ch.setLevel(Level.FINE);
82 logger.addHandler(ch);
83 try {
84 logger.addHandler(new FileHandler("mflow.log"));
85 } catch (IOException ioe) {
86 ioe.printStackTrace();
87 } catch (SecurityException se) {
88 se.printStackTrace();
89 }
90 logger.setLevel(Level.ALL);
91 }
92 }
This page was automatically generated by Maven