Class AbstractActionModel

java.lang.Object
jmri.util.startup.AbstractActionModel
All Implemented Interfaces:
StartupModel
Direct Known Subclasses:
CreateButtonModel, PerformActionModel

public abstract class AbstractActionModel extends Object implements StartupModel
Provide services for invoking actions during configuration and startup.

The action classes and corresponding human-readable names are provided by StartupActionFactory instances.

See Also:
  • Constructor Details

  • Method Details

    • getClassName

      public String getClassName()
    • getName

      public String getName()
      Description copied from interface: StartupModel
      Return the name of of the model or its controlled object.
      Specified by:
      getName in interface StartupModel
      Returns:
      the name, an empty string, or null
    • setName

      public void setName(String n)
      Description copied from interface: StartupModel
      Set the name of the model.
      Specified by:
      setName in interface StartupModel
      Parameters:
      n - the name, an empty string, or null
    • setClassName

      public void setClassName(@Nonnull String n)
    • getSystemPrefix

    • setSystemPrefix

      public void setSystemPrefix(@CheckForNull String prefix)
    • isSystemConnectionAction

      public boolean isSystemConnectionAction()
      Check if the action needs a system connection.

      This is decided from the action class itself, not from the list of actions offered by the running connections, so an action belonging to a connection that is disabled, failed to start or has been removed is still recognised as a connection action.

      Returns:
      true if the action class implements SystemConnectionAction
    • isConnectionAvailable

      public boolean isConnectionAvailable()
      Check if the connection this action needs is available.
      Returns:
      true if the action does not need a connection, or its connection is currently registered
    • isValid

      public boolean isValid()
      Description copied from interface: StartupModel
      Test is model is a valid model. Invalid models will not be shown or saved by the Startup Actions Preferences panel.
      Specified by:
      isValid in interface StartupModel
      Returns:
      true if valid; false otherwise
    • setEnabled

      public void setEnabled(boolean value)
      Set whenether this action is enabled or not.
      Specified by:
      setEnabled in interface StartupModel
      Parameters:
      value - true if enabled, false otherwise
    • isEnabled

      public boolean isEnabled()
      Get whenether this action is enabled or not.
      Specified by:
      isEnabled in interface StartupModel
      Returns:
      true if enabled, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • performAction

      public void performAction() throws JmriException
      Description copied from interface: StartupModel
      Perform the startup action. The caller is responsible to ensure that this startup model is enabled before calling this method.
      Specified by:
      performAction in interface StartupModel
      Throws:
      JmriException - if there is an exception thrown initializing the startup item; the original exception should be available as Throwable.getCause()
    • getExceptions

      Description copied from interface: StartupModel
      Get the exceptions thrown by the startup model.
      Specified by:
      getExceptions in interface StartupModel
      Returns:
      the list of exceptions thrown during startup in order or an empty list if no exceptions were thrown
    • addException

      public void addException(Exception exception)
      Description copied from interface: StartupModel
      Add an exception to the list of exceptions thrown when loading the model or performing the action.
      Specified by:
      addException in interface StartupModel
      Parameters:
      exception - the exception to retain with the model
    • performAction

      protected abstract void performAction(Action action) throws JmriException
      Throws:
      JmriException