Class StartupActionsManager
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.util.prefs.AbstractPreferencesManager
-
- jmri.util.startup.StartupActionsManager
-
- All Implemented Interfaces:
BeanInterface,PropertyChangeFirer,PropertyChangeProvider,JmriServiceProviderInterface,PreferencesManager
public class StartupActionsManager extends AbstractPreferencesManager
Manager for Startup Actions. Reads preferences at startup and triggers actions, and is responsible for saving the preferences later.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNAMESPACEstatic java.lang.StringNAMESPACE_OLDstatic java.lang.StringSTARTUP-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description StartupActionsManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAction(StartupModel model)StartupModel[]getActions()StartupModelgetActions(int index)<T extends StartupModel>
java.util.List<T>getActions(java.lang.Class<T> type)java.util.HashMap<java.lang.Class<? extends StartupModel>,StartupModelFactory>getFactories()StartupModelFactorygetFactories(java.lang.Class<? extends StartupModel> model)java.util.Set<java.lang.Class<? extends PreferencesManager>>getRequires()Get the set of PreferencesManagers that must be initialized prior to initializing this PreferencesManager.voidinitialize(Profile profile)Initialize the PreferencesManager with preferences associated with the provided Profile.booleanisDirty()booleanisRestartRequired()Indicate if a restart is required for preferences to be applied.voidmoveAction(int start, int end)Move aStartupModelfrom position start to position end.voidremoveAction(StartupModel model)Remove aStartupModel.voidsavePreferences(Profile profile)Save the preferences that this provider manages for the provided Profile.voidsetActions(int index, StartupModel model)Insert aStartupModelat the given position.voidsetRestartRequired()Mark that a change requires a restart.-
Methods inherited from class jmri.util.prefs.AbstractPreferencesManager
addInitializationException, getInitializationExceptions, getProvides, isInitialized, isInitializedWithExceptions, isInitializing, requireAllOther, requiresNoInitializedWithExceptions, requiresNoInitializedWithExceptions, setInitialized, setInitializing
-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
-
-
-
Field Detail
-
STARTUP
public static final java.lang.String STARTUP
- See Also:
- Constant Field Values
-
NAMESPACE
public static final java.lang.String NAMESPACE
- See Also:
- Constant Field Values
-
NAMESPACE_OLD
public static final java.lang.String NAMESPACE_OLD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StartupActionsManager
public StartupActionsManager()
-
-
Method Detail
-
initialize
public void initialize(Profile profile) throws InitializationException
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)orPreferencesManager.isInitializedWithExceptions(jmri.profile.Profile)return true if throwing an InitializationException to ensure that the provider is not repeatedly initialized.Loads the startup action preferences and, if all required managers have initialized without exceptions, performs those actions. Startup actions are only performed if
StartupModel.isValid()is true for the action. It is assumed that the action has retained an Exception that can be used to explain why isValid() is false.- 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
-
getRequires
@Nonnull public java.util.Set<java.lang.Class<? extends PreferencesManager>> getRequires()
Description copied from class:AbstractPreferencesManagerGet the set of PreferencesManagers that must be initialized prior to initializing this PreferencesManager. It is generally preferable to require an Interface or an abstract Class instead of a concrete Class, since that allows all (or any) concrete implementations of the required class to be initialized to provide required services for the requiring PreferencesManager instance.Note that for any set of PreferencesManagers with the same requirements, or with a circular dependency between each other, the order in which the PreferencesManagers in that set are initialized should be considered non-deterministic.
This implementation includes a default dependency on the
ConnectionConfigManager.- Specified by:
getRequiresin interfacePreferencesManager- Overrides:
getRequiresin classAbstractPreferencesManager- Returns:
- An set of classes; if there are no dependencies, return an empty set instead of null; overriding implementations may add to this set directly
-
savePreferences
public void savePreferences(Profile profile)
Description copied from interface:PreferencesManagerSave 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
-
getActions
public StartupModel[] getActions()
-
getActions
public <T extends StartupModel> java.util.List<T> getActions(java.lang.Class<T> type)
-
getActions
public StartupModel getActions(int index)
-
setActions
public void setActions(int index, StartupModel model)
Insert aStartupModelat the given position. Triggers anIndexedPropertyChangeEventwhere the old value is null and the new value is the inserted model.- Parameters:
index- The position where the model will be insertedmodel- The model to be inserted
-
moveAction
public void moveAction(int start, int end)
Move aStartupModelfrom position start to position end. Triggers anIndexedPropertyChangeEventwhere the index is end, the old value is start and the new value is the moved model.- Parameters:
start- the original positionend- the new position
-
addAction
public void addAction(StartupModel model)
-
removeAction
public void removeAction(StartupModel model)
Remove aStartupModel. Triggers anIndexedPropertyChangeEventwhere the index is the position of the removed model, the old value is the model, and the new value is null.- Parameters:
model- The startup action to remove
-
getFactories
public java.util.HashMap<java.lang.Class<? extends StartupModel>,StartupModelFactory> getFactories()
-
getFactories
public StartupModelFactory getFactories(java.lang.Class<? extends StartupModel> model)
-
isDirty
public boolean isDirty()
-
setRestartRequired
public void setRestartRequired()
Mark that a change requires a restart. As a side effect, marks this manager dirty.
-
isRestartRequired
public boolean isRestartRequired()
Indicate if a restart is required for preferences to be applied.- Returns:
- true if a restart is required, false otherwise
-
-