Class DefaultModuleManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.beans.VetoableChangeSupport
-
- jmri.managers.AbstractManager<Module>
-
- jmri.jmrit.logixng.implementation.DefaultModuleManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener,java.beans.VetoableChangeListener,java.util.EventListener,PropertyChangeFirer,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeFirer,VetoableChangeProvider,ModuleManager,Manager<Module>
public class DefaultModuleManager extends AbstractManager<Module> implements ModuleManager
Class providing the basic logic of the LogixNG_Manager interface.
-
-
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
Fields Modifier and Type Field Description (package private) static DefaultModuleManager_instance-
Fields inherited from class jmri.managers.AbstractManager
_beans, _tsys, _tuser, memo, silenceableProperties, silencedProperties
-
Fields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupport
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
Fields 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 Constructor Description DefaultModuleManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ModulecreateModule(java.lang.String systemName, java.lang.String userName, FemaleSocketManager.SocketType socketType)Create a new Module if the Module does not exist.ModulecreateModule(java.lang.String userName, FemaleSocketManager.SocketType socketType)For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.voiddeleteBean(Module module, java.lang.String property)Method for a UI to delete a bean.voiddeleteModule(Module x)Delete Module by removing it from the manager.voidfireVetoableChange(java.lang.String p, java.lang.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.java.lang.StringgetBeanTypeHandled(boolean plural)Get the user-readable name of the type of NamedBean handled by this manager.ModulegetBySystemName(java.lang.String name)Locate an existing instance based on a system name.ModulegetByUserName(java.lang.String name)Locate an existing instance based on a user name.ModulegetModule(java.lang.String name)Locate via user name, then system name if needed.java.lang.Class<Module>getNamedBeanClass()Get the class of NamedBean supported by this Manager.intgetXMLOrder()Determine the order that types should be written when storing panel files.static DefaultModuleManagerinstance()voidprintTree(Base.PrintTreeSettings settings, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)Print the tree to a stream.voidprintTree(Base.PrintTreeSettings settings, java.util.Locale locale, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)Print the tree to a stream.booleanresolveAllTrees(java.util.List<java.lang.String> errors)Resolve all the Module trees.voidsetupAllModules()Setup all Modules.chartypeLetter()Manager.NameValidityvalidSystemNameFormat(java.lang.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, vetoableChange
-
Methods inherited from class jmri.beans.VetoableChangeSupport
addVetoableChangeListener, addVetoableChangeListener, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods 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, validateUppercaseTrimmedSystemNameFormat
-
Methods inherited from interface jmri.jmrit.logixng.ModuleManager
getAutoSystemName, getSubSystemNamePrefix
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.beans.SilenceablePropertyChangeProvider
setPropertyChangesSilenced
-
Methods inherited from interface jmri.beans.VetoableChangeProvider
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Field Detail
-
_instance
static volatile DefaultModuleManager _instance
-
-
Constructor Detail
-
DefaultModuleManager
public DefaultModuleManager()
-
-
Method Detail
-
getXMLOrder
public int getXMLOrder()
Determine 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<Module>- Returns:
- write order for this Manager; larger is later.
-
typeLetter
public char typeLetter()
- Specified by:
typeLetterin interfaceManager<Module>- Returns:
- The type letter for a specific implementation
-
validSystemNameFormat
public Manager.NameValidity validSystemNameFormat(java.lang.String systemName)
Test if parameter is a properly formatted system name. Implementations of this method must not throw an exception, log an error, or otherwise disrupt the user.- Specified by:
validSystemNameFormatin interfaceManager<Module>- Overrides:
validSystemNameFormatin classAbstractManager<Module>- Parameters:
systemName- the system name- Returns:
Manager.NameValidity.INVALIDif system name does not start withManager.getSystemNamePrefix();Manager.NameValidity.VALID_AS_PREFIX_ONLYif system name equalsManager.getSystemNamePrefix(); otherwiseManager.NameValidity.VALIDto allow Managers that do not perform more specific validation to be considered valid.
-
createModule
public Module createModule(java.lang.String systemName, java.lang.String userName, FemaleSocketManager.SocketType socketType) throws java.lang.IllegalArgumentException
Create a new Module if the Module does not exist.- Specified by:
createModulein interfaceModuleManager- Parameters:
systemName- the system nameuserName- the user namesocketType- the socket type- Returns:
- a new Module or null if unable to create
- Throws:
java.lang.IllegalArgumentException- when needed
-
createModule
public Module createModule(java.lang.String userName, FemaleSocketManager.SocketType socketType) throws java.lang.IllegalArgumentException
For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.- Specified by:
createModulein interfaceModuleManager- Parameters:
userName- the user namesocketType- the socket type- Returns:
- a new Module or null if unable to create
- Throws:
java.lang.IllegalArgumentException- when needed
-
getModule
public Module getModule(java.lang.String name)
Locate via user name, then system name if needed. Does not create a new one if nothing found- Specified by:
getModulein interfaceModuleManager- Parameters:
name- User name or system name to match- Returns:
- null if no match found
-
getByUserName
public Module getByUserName(java.lang.String name)
Locate an existing instance based on a user name.- Specified by:
getByUserNamein interfaceManager<Module>- Specified by:
getByUserNamein interfaceModuleManager- Overrides:
getByUserNamein classAbstractManager<Module>- Parameters:
name- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getBySystemName
public Module getBySystemName(java.lang.String name)
Locate an existing instance based on a system name.- Specified by:
getBySystemNamein interfaceManager<Module>- Specified by:
getBySystemNamein interfaceModuleManager- Overrides:
getBySystemNamein classAbstractManager<Module>- Parameters:
name- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getBeanTypeHandled
public java.lang.String getBeanTypeHandled(boolean plural)
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<Module>- 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
-
resolveAllTrees
public boolean resolveAllTrees(java.util.List<java.lang.String> errors)
Resolve all the Module trees.This method ensures that everything in the Module tree has a pointer to its parent.
- Specified by:
resolveAllTreesin interfaceModuleManager- Parameters:
errors- a list of potential errors- Returns:
- true if success, false otherwise
-
setupAllModules
public void setupAllModules()
Setup all Modules. This method is called after a configuration file is loaded.- Specified by:
setupAllModulesin interfaceModuleManager
-
deleteModule
public void deleteModule(Module x)
Delete Module by removing it from the manager. The Module must first be deactivated so it stops processing.- Specified by:
deleteModulein interfaceModuleManager- Parameters:
x- the Module to delete
-
printTree
public void printTree(Base.PrintTreeSettings settings, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)
Print the tree to a stream.- Specified by:
printTreein interfaceModuleManager- Parameters:
settings- settings for what to printwriter- the stream to print the tree toindent- the indentation of each levellineNumber- the line number
-
printTree
public void printTree(Base.PrintTreeSettings settings, java.util.Locale locale, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)
Print the tree to a stream.- Specified by:
printTreein interfaceModuleManager- Parameters:
settings- settings for what to printlocale- The locale to be usedwriter- the stream to print the tree toindent- the indentation of each levellineNumber- the line number
-
instance
@InvokeOnGuiThread public static DefaultModuleManager instance()
-
getNamedBeanClass
public java.lang.Class<Module> 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<Module>- Returns:
- the class supported by this Manager.
-
fireVetoableChange
@OverridingMethodsMustInvokeSuper public void fireVetoableChange(java.lang.String p, java.lang.Object old) throws java.beans.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:
java.beans.PropertyVetoException- If the recipients wishes the delete to be aborted (see above)
-
deleteBean
public final void deleteBean(@Nonnull Module module, @Nonnull java.lang.String property) throws java.beans.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<Module>- Overrides:
deleteBeanin classAbstractManager<Module>- Parameters:
module- 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:
java.beans.PropertyVetoException- If the recipients wishes the delete to be aborted (see above)
-
-