001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: Rife.java 3634 2007-01-08 21:42:24Z gbevin $
007: */
008: package com.uwyn.rife.gui;
009:
010: import com.uwyn.rife.config.Config;
011: import com.uwyn.rife.gui.old.MainFrame;
012: import com.uwyn.rife.rep.Rep;
013: import com.uwyn.rife.swing.JDialogSystemError;
014: import com.uwyn.rife.tools.ExceptionUtils;
015: import java.util.logging.Logger;
016: import javax.swing.SwingUtilities;
017: import javax.swing.UIManager;
018:
019: public class Rife {
020: private static MainFrame mMainFrame = null;
021:
022: /**
023: * This is the first method that is called when the
024: * Rife application launches.
025: * <p>
026: * It verifies if the correct arguments have been provided.
027: * If this is the case, the initialization procedure
028: * initiates.
029: *
030: * @param args the string array that contains the parameters that have
031: * been passed on the commandline
032: * @since 1.0
033: */
034: public static void main(String[] args) {
035: if (verifyArguments(args)) {
036: try {
037: Rep.initialize(System.getProperty("rep.path"));
038:
039: mMainFrame = new MainFrame();
040: mMainFrame.setVisible(true);
041: } catch (Throwable e) {
042: try {
043: (new JDialogSystemError(mMainFrame,
044: "main() : Unexpected system exception : "
045: + ExceptionUtils
046: .getExceptionStackTrace(e)))
047: .setVisible(true);
048: } catch (Throwable exception2) {
049: Logger.getLogger("com.uwyn.rife.gui").severe(
050: "main() : Unexpected system exception : "
051: + ExceptionUtils
052: .getExceptionStackTrace(e));
053: }
054: quit();
055: }
056: } else {
057: quit();
058: }
059: }
060:
061: /**
062: * Verifies if the commandline arguments are valid.
063: *
064: * @param args the string array that contains the parameters that have
065: * been passed on the commandline
066: * @return <code>true</code> if the arguments were valid
067: * <code>false</code> if the arguments were invalid
068: * @since 1.0
069: */
070: private static boolean verifyArguments(String[] args) {
071: return true;
072: }
073:
074: public static MainFrame getMainFrame() {
075: return mMainFrame;
076: }
077:
078: /**
079: * Allows easy changement of the application's look and feel
080: *
081: * @param className string containing the class name of the look and feel that should beset
082: * @since 1.0
083: */
084: public static void setLookAndFeel(String className) {
085: try {
086: UIManager.setLookAndFeel(className);
087: if (mMainFrame != null) {
088: SwingUtilities.updateComponentTreeUI(mMainFrame);
089: }
090: Config.getRepInstance().setParameter("LOOK_AND_FEEL",
091: className);
092: } catch (Throwable e) {
093: (new JDialogSystemError(Rife.getMainFrame(),
094: "setLookAndFeel() : Error while setting the look & feel to '"
095: + className + "' : "
096: + ExceptionUtils.getExceptionStackTrace(e)))
097: .setVisible(true);
098: }
099: }
100:
101: public static void quit() {
102: System.exit(1);
103: }
104: }
|