Package jmri.managers

Class ManagerDefaultSelector

All Implemented Interfaces:
BeanInterface, PropertyChangeFirer, PropertyChangeProvider, JmriServiceProviderInterface, PreferencesManager

Records and executes a desired set of defaults for the JMRI InstanceManager and ProxyManagers.

Provided that a connection provides a default, this verifies, unless the per-profile property jmri-managers.allInternalDefaults is true, that a non-Internal connection (other than type None in the preferences window) is the default for at least one type of manager.

allInternalDefaults is preserved as a preference when set here, but setAllInternalDefaultsValid(boolean) is not (originally) invoked from the GUI.

Since:
2.9.4
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • removeConnectionAsDefault

      void removeConnectionAsDefault(String removedName)
    • getDefault

      public String getDefault(Class<?> managerClass)
      Return the userName of the system that provides the default instance for a specific class.
      Parameters:
      managerClass - the specific type, for example, TurnoutManager, for which a default system is desired
      Returns:
      userName of the system, or null if none set
    • setDefault

      public void setDefault(Class<?> managerClass, String userName)
      Record the userName of the system that provides the default instance for a specific class.

      To ensure compatibility of different preference versions, only classes that are current registered are preserved. This way, reading in an old file will just have irrelevant items ignored.

      Parameters:
      managerClass - the specific type, for example, TurnoutManager, for which a default system is desired
      userName - of the system, or null if none set
    • configure

      Load into InstanceManager
      Parameters:
      profile - the profile to configure against
      Returns:
      an exception that can be passed to the user or null if no errors occur
    • initialize

      public void initialize(Profile profile) throws InitializationException
      Description copied from interface: PreferencesManager
      Initialize the PreferencesManager with preferences associated with the provided Profile.

      Implementing classes should throw an InitializationException with a user readable localized message, since it most likely be displayed to the user. Implementing classes will still want to ensure that PreferencesManager.isInitialized(jmri.profile.Profile) or PreferencesManager.isInitializedWithExceptions(jmri.profile.Profile) return true if throwing an InitializationException to ensure that the provider is not repeatedly initialized.

      Parameters:
      profile - the configuration profile used for this initialization; may be null to initialize for this user regardless of profile
      Throws:
      InitializationException - if the user needs to be notified of an issue that prevents regular use of the application
    • savePreferences

      public void savePreferences(Profile profile)
      Description copied from interface: PreferencesManager
      Save the preferences that this provider manages for the provided Profile.
      Parameters:
      profile - the profile associated with the preferences to save; may be null to save preferences that apply to the current user regardless of profile
    • isPreferencesValid

      public boolean isPreferencesValid(Profile profile)
    • isAllInternalDefaultsValid

      public boolean isAllInternalDefaultsValid()
      Check if having all defaults assigned to internal connections should be considered is valid in the presence of an external System Connection.
      Returns:
      true if having all internal defaults should be valid; false otherwise
    • setAllInternalDefaultsValid

      public void setAllInternalDefaultsValid(boolean isAllInternalDefaultsValid)
      Set if having all defaults assigned to internal connections should be considered is valid in the presence of an external System Connection.
      Parameters:
      isAllInternalDefaultsValid - true if having all internal defaults should be valid; false otherwise