Rife.java :  » Web-Framework » rife-1.6.1 » com » uwyn » rife » gui » Java Open Source

Java Open Source » Web Framework » rife 1.6.1 
rife 1.6.1 » com » uwyn » rife » gui » Rife.java
/*
 * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
 * Distributed under the terms of either:
 * - the common development and distribution license (CDDL), v1.0; or
 * - the GNU Lesser General Public License, v2.1 or later
 * $Id: Rife.java 3634 2007-01-08 21:42:24Z gbevin $
 */
package com.uwyn.rife.gui;

import com.uwyn.rife.config.Config;
import com.uwyn.rife.gui.old.MainFrame;
import com.uwyn.rife.rep.Rep;
import com.uwyn.rife.swing.JDialogSystemError;
import com.uwyn.rife.tools.ExceptionUtils;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class Rife
{
  private static MainFrame    mMainFrame = null;

  /**
   * This is the first method that is called when the
   * Rife application launches.
   * <p>
   * It verifies if the correct arguments have been provided.
   * If this is the case, the initialization procedure
   * initiates.
   *
   * @param args   the string array that contains the parameters that have
   *               been passed on the commandline
   * @since 1.0
   */
  public static void main(String[] args)
  {
        if(verifyArguments(args))
    {
      try
      {
        Rep.initialize(System.getProperty("rep.path"));

        mMainFrame = new MainFrame();
        mMainFrame.setVisible(true);
      }
      catch (Throwable e)
      {
        try
        {
          (new JDialogSystemError(mMainFrame, "main() : Unexpected system exception : "+ExceptionUtils.getExceptionStackTrace(e))).setVisible(true);
        }
        catch (Throwable exception2)
        {
          Logger.getLogger("com.uwyn.rife.gui").severe("main() : Unexpected system exception : "+ExceptionUtils.getExceptionStackTrace(e));
        }
        quit();
      }
    }
    else
    {
      quit();
    }
  }

  /**
   * Verifies if the commandline arguments are valid.
   *
   * @param args   the string array that contains the parameters that have
   *               been passed on the commandline
   * @return <code>true</code> if the arguments were valid
   *         <code>false</code> if the arguments were invalid
   * @since 1.0
   */
  private static boolean verifyArguments(String[] args)
  {
    return true;
  }

  public static MainFrame getMainFrame()
  {
    return mMainFrame;
  }

  /**
   * Allows easy changement of the application's look and feel
   *
   * @param className string containing the class name of the look and feel that should beset
   * @since 1.0
   */
  public static void setLookAndFeel(String className)
  {
    try
    {
      UIManager.setLookAndFeel(className);
      if(mMainFrame != null)
      {
        SwingUtilities.updateComponentTreeUI(mMainFrame);
      }
      Config.getRepInstance().setParameter("LOOK_AND_FEEL", className);
    }
    catch (Throwable e)
    {
      (new JDialogSystemError(Rife.getMainFrame(), "setLookAndFeel() : Error while setting the look & feel to '"+className+"' : "+ExceptionUtils.getExceptionStackTrace(e))).setVisible(true);
    }
  }

  public static void quit()
  {
    System.exit(1);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.