Class DefaultConditionalNGManager
java.lang.Object
jmri.beans.PropertyChangeSupport
jmri.beans.VetoableChangeSupport
jmri.managers.AbstractManager<ConditionalNG>
jmri.jmrit.logixng.implementation.DefaultConditionalNGManager
- All Implemented Interfaces:
PropertyChangeListener,VetoableChangeListener,EventListener,PropertyChangeFirer,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeFirer,VetoableChangeProvider,ConditionalNG_Manager,Manager<ConditionalNG>
public class DefaultConditionalNGManager
extends AbstractManager<ConditionalNG>
implements ConditionalNG_Manager
Class providing the basic logic of the ConditionalNG_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
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 TypeMethodDescriptioncreateConditionalNG(LogixNG logixNG, String userName) For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.createConditionalNG(LogixNG logixNG, String userName, int threadID) For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.createConditionalNG(LogixNG logixNG, String systemName, String userName) Create a new ConditionalNG if the ConditionalNG does not exist.createConditionalNG(LogixNG logixNG, String systemName, String userName, int threadID) Create a new ConditionalNG if the ConditionalNG does not exist.final voiddeleteBean(ConditionalNG conditionalNG, String property) Method for a UI to delete a bean.voidDelete ConditionalNG 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(LogixNG logixNG, String name) Find the ConditionalNG which is a member of the LogixNG with the supplied user name.getConditionalNG(LogixNG logixNG, String name) Locate via user name using the LogixNG, then system name if needed.Get the class of NamedBean supported by this Manager.getParentLogixNG(String systemName) Find the LogixNG which has the ConditionalNG system name in its ConditionalNG_Entry list.intDetermine the order that types should be written when storing panel files.static DefaultConditionalNGManagerinstance()voidsetLoadDisabled(boolean s) Support for loading ConditionalNGs in a disabled statevoidsetRunOnGUIDelayed(boolean value) Set whenether execute() should run on the GUI thread at once or should dispatch the call until later, for all ConditionalNGs registered in this manager.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, getByUserName, 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.ConditionalNG_Manager
getAutoSystemName, getByUserName, 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
-
DefaultConditionalNGManager
public DefaultConditionalNGManager()
-
-
Method Details
-
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<ConditionalNG>- Returns:
- write order for this Manager; larger is later.
-
typeLetter
- Specified by:
typeLetterin interfaceManager<ConditionalNG>- Returns:
- The type letter for a specific implementation
-
validSystemNameFormat
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<ConditionalNG>- Overrides:
validSystemNameFormatin classAbstractManager<ConditionalNG>- 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.
-
createConditionalNG
public ConditionalNG createConditionalNG(LogixNG logixNG, String systemName, String userName) throws IllegalArgumentException Create a new ConditionalNG if the ConditionalNG does not exist.- Specified by:
createConditionalNGin interfaceConditionalNG_Manager- Parameters:
logixNG- The parent LogixNGsystemName- The system nameuserName- The user name- Returns:
- a new ConditionalNG or null if unable to create
- Throws:
IllegalArgumentException- when needed
-
createConditionalNG
public ConditionalNG createConditionalNG(LogixNG logixNG, String systemName, String userName, int threadID) throws IllegalArgumentException Create a new ConditionalNG if the ConditionalNG does not exist.- Specified by:
createConditionalNGin interfaceConditionalNG_Manager- Parameters:
logixNG- The parent LogixNGsystemName- The system nameuserName- The user namethreadID- The thread ID that this ConditionalNG will execute on- Returns:
- a new ConditionalNG or null if unable to create
- Throws:
IllegalArgumentException- when needed
-
createConditionalNG
public ConditionalNG createConditionalNG(LogixNG logixNG, String userName) throws IllegalArgumentException For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.- Specified by:
createConditionalNGin interfaceConditionalNG_Manager- Parameters:
logixNG- The parent LogixNGuserName- The user name- Returns:
- a new ConditionalNG or null if unable to create
- Throws:
IllegalArgumentException- when needed
-
createConditionalNG
public ConditionalNG createConditionalNG(LogixNG logixNG, String userName, int threadID) throws IllegalArgumentException For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.- Specified by:
createConditionalNGin interfaceConditionalNG_Manager- Parameters:
logixNG- The parent LogixNGuserName- The user namethreadID- The thread ID that this ConditionalNG will execute on- Returns:
- a new ConditionalNG or null if unable to create
- Throws:
IllegalArgumentException- when needed
-
getConditionalNG
Locate via user name using the LogixNG, then system name if needed. Does not create a new one if nothing found- Specified by:
getConditionalNGin interfaceConditionalNG_Manager- Parameters:
logixNG- The LogixNG for the user name match. If null, only do a system name match.name- User name or system name to match- Returns:
- null if no match found
-
getParentLogixNG
Find the LogixNG which has the ConditionalNG system name in its ConditionalNG_Entry list.- Specified by:
getParentLogixNGin interfaceConditionalNG_Manager- Parameters:
systemName- The ConditionalNG system name.- Returns:
- the parent LogixNG or null if none found.
-
getByUserName
Find the ConditionalNG which is a member of the LogixNG with the supplied user name.- Specified by:
getByUserNamein interfaceConditionalNG_Manager- Parameters:
logixNG- The LogixNG that contains the requested ConditionalNG.name- The requested ConditionalNG user name.- Returns:
- the ConditionalNG or null if none found.
-
getBySystemName
Locate an existing instance based on a system name.- Specified by:
getBySystemNamein interfaceConditionalNG_Manager- Specified by:
getBySystemNamein interfaceManager<ConditionalNG>- Overrides:
getBySystemNamein classAbstractManager<ConditionalNG>- 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<ConditionalNG>- 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
-
deleteConditionalNG
Delete ConditionalNG by removing it from the manager. The ConditionalNG must first be deactivated so it stops processing.- Specified by:
deleteConditionalNGin interfaceConditionalNG_Manager- Parameters:
x- the ConditionalNG to delete
-
setLoadDisabled
Support for loading ConditionalNGs in a disabled state- Specified by:
setLoadDisabledin interfaceConditionalNG_Manager- Parameters:
s- true if ConditionalNG should be disabled when loaded
-
setRunOnGUIDelayed
Set whenether execute() should run on the GUI thread at once or should dispatch the call until later, for all ConditionalNGs registered in this manager. Most tests turns off the delay to simplify the tests.- Specified by:
setRunOnGUIDelayedin interfaceConditionalNG_Manager- Parameters:
value- true if execute() should run on GUI thread delayed, false otherwise.
-
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<ConditionalNG>- 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 ConditionalNG conditionalNG, @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<ConditionalNG>- Overrides:
deleteBeanin classAbstractManager<ConditionalNG>- Parameters:
conditionalNG- 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)
-