Пример #1
0
  /**
   * Set and log some startup information. This is intended to be the central connection point for
   * common startup and logging.
   *
   * @param name Program/application name as known by the user
   */
  protected static void setStartupInfo(String name) {
    // Set the application name
    try {
      jmri.Application.setApplicationName(name);
    } catch (IllegalArgumentException ex) {
      log.warn("Unable to set application name", ex);
    } catch (IllegalAccessException ex) {
      log.warn("Unable to set application name", ex);
    }

    // Log the startup information
    log.info(Log4JUtil.startupInfo(name));
  }
Пример #2
0
  protected static void splash(boolean show, boolean debug) {
    Log4JUtil.initLog4J();
    if (debugListener == null && debug) {
      // set a global listener for debug options
      debugFired = false;
      Toolkit.getDefaultToolkit()
          .addAWTEventListener(
              debugListener =
                  new AWTEventListener() {
                    @Override
                    public void eventDispatched(AWTEvent e) {
                      if (!debugFired) {
                        /*We set the debugmsg flag on the first instance of the user pressing any button
                        and the if the debugFired hasn't been set, this allows us to ensure that we don't
                        miss the user pressing F8, while we are checking*/
                        debugmsg = true;
                        if (e.getID() == KeyEvent.KEY_PRESSED) {
                          KeyEvent ky = (KeyEvent) e;
                          if (ky.getKeyCode() == 119) {
                            startupDebug();
                          } else {
                            debugmsg = false;
                          }
                        } else {
                          debugmsg = false;
                        }
                      }
                    }
                  },
              AWTEvent.KEY_EVENT_MASK);
    }

    // bring up splash window for startup
    if (sp == null) {
      if (debug) {
        sp = new SplashWindow(splashDebugMsg());
      } else {
        sp = new SplashWindow();
      }
    }
    sp.setVisible(show);
    if (!show) {
      sp.dispose();
      Toolkit.getDefaultToolkit().removeAWTEventListener(debugListener);
      debugListener = null;
      sp = null;
    }
  }
Пример #3
0
 /**
  * Set, log and return some startup information.
  *
  * <p>This method needs to be refactored, but it's in use (2/2014) by CATS so can't easily be
  * changed right away.
  *
  * @deprecated Since 3.7.1, use {@link #setStartupInfo(java.lang.String) } plus {@link
  *     Log4JUtil#startupInfo(java.lang.String) }
  */
 @Deprecated
 protected static String startupInfo(String name) {
   setStartupInfo(name);
   return Log4JUtil.startupInfo(name);
 }
Пример #4
0
 /**
  * Invoke the standard Log4J logging initialization.
  *
  * <p>No longer used here. ({@link #splash} calls the initialization directly. Left as a
  * deprecated method because other code, e.g. CATS is still using in in JMRI 3.7 and perhaps 3.8
  *
  * @deprecated Since 3.7.2, use @{link jmri.util.Log4JUtil#initLog4J} directly.
  */
 @Deprecated
 protected static void initLog4J() {
   jmri.util.Log4JUtil.initLog4J();
 }