Class DefaultGlobalVariableManager
- All Implemented Interfaces:
PropertyChangeListener,VetoableChangeListener,EventListener,PropertyChangeFirer,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeFirer,VetoableChangeProvider,GlobalVariableManager,Manager<GlobalVariable>
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.Manager
Manager.ManagerDataEvent<E extends NamedBean>, Manager.ManagerDataListener<E extends NamedBean>, Manager.NameValidity -
Field Summary
FieldsFields inherited from class jmri.managers.AbstractManager
_beans, _tsys, _tuser, memo, silenceableProperties, silencedPropertiesFields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupportFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupportFields inherited from interface jmri.Manager
ANALOGIOS, AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, CTCDATA, ENTRYEXIT, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXNG_ANALOG_ACTIONS, LOGIXNG_ANALOG_EXPRESSIONS, LOGIXNG_CONDITIONALNGS, LOGIXNG_DIGITAL_ACTIONS, LOGIXNG_DIGITAL_BOOLEAN_ACTIONS, LOGIXNG_DIGITAL_EXPRESSIONS, LOGIXNG_GLOBAL_VARIABLES, LOGIXNG_MODULES, LOGIXNG_STRING_ACTIONS, LOGIXNG_STRING_EXPRESSIONS, LOGIXNG_TABLES, LOGIXNGS, LOGIXS, MEMORIES, METERFRAMES, METERS, OBLOCKS, PANELFILES, PROPERTY_BEANS, PROPERTY_CAN_DELETE, PROPERTY_DISPLAY_LIST_NAME, PROPERTY_DO_DELETE, PROPERTY_DO_NOT_DELETE, PROPERTY_LENGTH, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, STRINGIOS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateGlobalVariable(String userName) For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.createGlobalVariable(String systemName, String userName) Method to create a new GlobalVariable if the GlobalVariable does not exist.final voiddeleteBean(GlobalVariable globalVariable, String property) Method for a UI to delete a bean.voidDelete GlobalVariable by removing it from the manager.voidfireVetoableChange(String p, Object old) Inform all registered listeners of a vetoable change.If the propertyName is "CanDelete" ALL listeners with an interest in the bean will throw an exception, which is recorded returned back to the invoking method, so that it can be presented back to the user.However if a listener decides that the bean can not be deleted then it should throw an exception with a property name of "DoNotDelete", this is thrown back up to the user and the delete process should be aborted.getBeanTypeHandled(boolean plural) Get the user-readable name of the type of NamedBean handled by this manager.getBySystemName(String name) Locate an existing instance based on a system name.getByUserName(String name) Locate an existing instance based on a user name.getGlobalVariable(String name) Locate via user name, then system name if needed.Get the class of NamedBean supported by this Manager.intDetermine the order that types should be written when storing panel files.static DefaultGlobalVariableManagerinstance()voidprintTree(Locale locale, PrintWriter writer, String indent) Print the tree to a stream.charvalidSystemNameFormat(String systemName) Test if parameter is a properly formatted system name.Methods inherited from class jmri.managers.AbstractManager
addDataListener, checkNumeric, createSystemName, deregister, dispose, fireDataListenersAdded, fireDataListenersRemoved, fireVetoableChange, getAutoSystemName, getBySystemName, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanSet, getObjectCount, getOuterBean, getSystemPrefix, handleUserNameUniqueness, makeSystemName, propertyChange, register, registerSelf, registerUserName, removeDataListener, setDataListenerMute, setPropertyChangesSilenced, updateAutoNumber, vetoableChangeMethods inherited from class jmri.beans.VetoableChangeSupport
addVetoableChangeListener, addVetoableChangeListener, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListenerMethods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.jmrit.logixng.GlobalVariableManager
getAutoSystemName, getSubSystemNamePrefixMethods inherited from interface jmri.Manager
addDataListener, deregister, dispose, getBeanTypeHandled, getEntryToolTip, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanSet, getObjectCount, getSystemNamePrefix, getSystemPrefix, isValidSystemNameFormat, makeSystemName, makeSystemName, makeSystemName, register, removeDataListener, setDataListenerMute, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormatMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.beans.SilenceablePropertyChangeProvider
setPropertyChangesSilencedMethods inherited from interface jmri.beans.VetoableChangeProvider
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
Field Details
-
_instance
-
-
Constructor Details
-
DefaultGlobalVariableManager
public DefaultGlobalVariableManager()
-
-
Method Details
-
getXMLOrder
Description copied from interface:ManagerDetermine the order that types should be written when storing panel files. Uses one of the constants defined in this class.Yes, that's an overly-centralized methodology, but it works for now.
- Specified by:
getXMLOrderin interfaceManager<GlobalVariable>- Returns:
- write order for this Manager; larger is later.
-
typeLetter
- Specified by:
typeLetterin interfaceManager<GlobalVariable>- Returns:
- The type letter for a specific implementation
-
validSystemNameFormat
Test if parameter is a properly formatted system name.- Specified by:
validSystemNameFormatin interfaceManager<GlobalVariable>- Overrides:
validSystemNameFormatin classAbstractManager<GlobalVariable>- Parameters:
systemName- the system name- Returns:
- enum indicating current validity, which might be just as a prefix
-
createGlobalVariable
public GlobalVariable createGlobalVariable(String systemName, String userName) throws IllegalArgumentException Method to create a new GlobalVariable if the GlobalVariable does not exist.Returns null if a GlobalVariable with the same systemName or userName already exists, or if there is trouble creating a new GlobalVariable.
- Specified by:
createGlobalVariablein interfaceGlobalVariableManager- Parameters:
systemName- the system nameuserName- the user name- Returns:
- a new GlobalVariable or null if unable to create
- Throws:
IllegalArgumentException- when needed
-
createGlobalVariable
Description copied from interface:GlobalVariableManagerFor use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.- Specified by:
createGlobalVariablein interfaceGlobalVariableManager- Parameters:
userName- the user name- Returns:
- a new GlobalVariable or null if unable to create
- Throws:
IllegalArgumentException- when needed
-
getGlobalVariable
Description copied from interface:GlobalVariableManagerLocate via user name, then system name if needed. Does not create a new one if nothing found- Specified by:
getGlobalVariablein interfaceGlobalVariableManager- Parameters:
name- User name or system name to match- Returns:
- null if no match found
-
getByUserName
Description copied from class:AbstractManagerLocate an existing instance based on a user name.- Specified by:
getByUserNamein interfaceGlobalVariableManager- Specified by:
getByUserNamein interfaceManager<GlobalVariable>- Overrides:
getByUserNamein classAbstractManager<GlobalVariable>- Parameters:
name- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getBySystemName
Description copied from class:AbstractManagerLocate an existing instance based on a system name.- Specified by:
getBySystemNamein interfaceGlobalVariableManager- Specified by:
getBySystemNamein interfaceManager<GlobalVariable>- Overrides:
getBySystemNamein classAbstractManager<GlobalVariable>- Parameters:
name- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getBeanTypeHandled
Get the user-readable name of the type of NamedBean handled by this manager.For instance, in the code where we are dealing with just a bean and a message that needs to be passed to the user or in a log.
- Specified by:
getBeanTypeHandledin interfaceManager<GlobalVariable>- Parameters:
plural- true to return plural form of the type; false to return singular form- Returns:
- a string of the bean type that the manager handles, eg Turnout, Sensor etc
-
deleteGlobalVariable
Delete GlobalVariable by removing it from the manager. The GlobalVariable must first be deactivated so it stops processing.- Specified by:
deleteGlobalVariablein interfaceGlobalVariableManager- Parameters:
x- the GlobalVariable to delete
-
printTree
Print the tree to a stream.- Specified by:
printTreein interfaceGlobalVariableManager- Parameters:
locale- The locale to be usedwriter- the stream to print the tree toindent- the indentation of each level
-
instance
-
getNamedBeanClass
Get the class of NamedBean supported by this Manager. This should be the generic class used in the Manager's class declaration.- Specified by:
getNamedBeanClassin interfaceManager<GlobalVariable>- Returns:
- the class supported by this Manager.
-
fireVetoableChange
@OverridingMethodsMustInvokeSuper public void fireVetoableChange(String p, Object old) throws PropertyVetoException Inform all registered listeners of a vetoable change.If the propertyName is "CanDelete" ALL listeners with an interest in the bean will throw an exception, which is recorded returned back to the invoking method, so that it can be presented back to the user.However if a listener decides that the bean can not be deleted then it should throw an exception with a property name of "DoNotDelete", this is thrown back up to the user and the delete process should be aborted.- Parameters:
p- The programmatic name of the property that is to be changed. "CanDelete" will inquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item.old- The old value of the property.- Throws:
PropertyVetoException- If the recipients wishes the delete to be aborted (see above)
-
deleteBean
public final void deleteBean(@Nonnull GlobalVariable globalVariable, @Nonnull String property) throws PropertyVetoException Method for a UI to delete a bean.The UI should first request a "CanDelete", this will return a list of locations (and descriptions) where the bean is in use via throwing a VetoException, then if that comes back clear, or the user agrees with the actions, then a "DoDelete" can be called which inform the listeners to delete the bean, then it will be deregistered and disposed of.
If a property name of "DoNotDelete" is thrown back in the VetoException then the delete process should be aborted.
- Specified by:
deleteBeanin interfaceManager<GlobalVariable>- Overrides:
deleteBeanin classAbstractManager<GlobalVariable>- Parameters:
globalVariable- The NamedBean to be deletedproperty- The programmatic name of the request. "CanDelete" will enquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item- Throws:
PropertyVetoException- If the recipients wishes the delete to be aborted (see above)
-