Package apps

Class AppsBase

  • Direct Known Subclasses:
    Apps3, JmriFaceless

    public abstract class AppsBase
    extends java.lang.Object
    Base class for the core of JMRI applications.

    This provides a non-GUI base for applications. Below this is the Apps3 subclass which provides basic Swing GUI support.

    There are a series of steps in the configuration:

    preInit
    Initialize log4j, invoked from the main()
    ctor
    Construct the basic application object
    • Constructor Summary

      Constructors 
      Constructor Description
      AppsBase​(java.lang.String applicationName, java.lang.String configFileDef, java.lang.String[] args)
      Create and initialize the application object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void configureProfile()
      Configure the Profile to use for this application.
      static java.lang.String getConfigFileName()  
      static boolean handleQuit()
      The application decided to quit, handle that.
      static void handleRestart()
      The application decided to restart, handle that.
      protected void installConfigurationManager()  
      protected void installManagers()  
      static void preInit​(java.lang.String applicationName)
      Initial actions before frame is created, invoked in the applications main() routine.
      protected void setAndLoadPreferenceFile()
      Invoked to load the preferences information, and in the process configure the system.
      protected static void setConfigFilename​(java.lang.String def, java.lang.String[] args)
      Set up the configuration file name at startup.
      protected static void setJmriSystemProperty​(java.lang.String key, java.lang.String value)  
      protected void start()
      Final actions before releasing control of the application to the user, invoked explicitly after object has been constructed in main().
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AppsBase

        public AppsBase​(java.lang.String applicationName,
                        java.lang.String configFileDef,
                        java.lang.String[] args)
        Create and initialize the application object.
        Parameters:
        applicationName - user-visible name of application
        configFileDef - default config filename
        args - arguments passed to application at launch
    • Method Detail

      • preInit

        public static void preInit​(java.lang.String applicationName)
        Initial actions before frame is created, invoked in the applications main() routine.
        • Initialize logging
        • Set application name
        Parameters:
        applicationName - The application name as presented to the user
      • configureProfile

        protected void configureProfile()
        Configure the Profile to use for this application.

        Note that GUI-based applications must override this method, since this method does not provide user feedback.

      • setAndLoadPreferenceFile

        protected void setAndLoadPreferenceFile()
        Invoked to load the preferences information, and in the process configure the system. The high-level steps are:
        • Locate the preferences file based through FileUtil.getFile(String)
        • See if the preferences file exists, and handle it if it doesn't
        • Obtain a ConfigureManager from the InstanceManager
        • Ask that ConfigureManager to load the file, in the process loading information into existing and new managers.
        • Do any deferred loads that are needed
        • If needed, migrate older formats
        (There's additional handling for shared configurations)
      • start

        protected void start()
        Final actions before releasing control of the application to the user, invoked explicitly after object has been constructed in main().
      • setConfigFilename

        protected static void setConfigFilename​(java.lang.String def,
                                                java.lang.String[] args)
        Set up the configuration file name at startup.

        The Configuration File name variable holds the name used to load the configuration file during later startup processing. Applications invoke this method to handle the usual startup hierarchy:

        • If an absolute filename was provided on the command line, use it
        • If a filename was provided that's not absolute, consider it to be in the preferences directory
        • If no filename provided, use a default name (that's application specific)
        This name will be used for reading and writing the preferences. It need not exist when the program first starts up. This name may be proceeded with config=.
        Parameters:
        def - Default value if no other is provided
        args - Argument array from the main routine
      • setJmriSystemProperty

        protected static void setJmriSystemProperty​(java.lang.String key,
                                                    java.lang.String value)
      • handleQuit

        public static boolean handleQuit()
        The application decided to quit, handle that.
        Returns:
        always returns false
      • handleRestart

        public static void handleRestart()
        The application decided to restart, handle that.