Class DefaultConditionalNGManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.beans.VetoableChangeSupport
-
- jmri.managers.AbstractManager<ConditionalNG>
-
- jmri.jmrit.logixng.implementation.DefaultConditionalNGManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.beans.VetoableChangeListener
,java.util.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
Fields Modifier and Type Field Description (package private) static DefaultConditionalNGManager
_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, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, STRINGIOS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS
-
-
Constructor Summary
Constructors Constructor Description DefaultConditionalNGManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConditionalNG
createConditionalNG(LogixNG logixNG, java.lang.String userName)
For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.ConditionalNG
createConditionalNG(LogixNG logixNG, java.lang.String userName, int threadID)
For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.ConditionalNG
createConditionalNG(LogixNG logixNG, java.lang.String systemName, java.lang.String userName)
Create a new ConditionalNG if the ConditionalNG does not exist.ConditionalNG
createConditionalNG(LogixNG logixNG, java.lang.String systemName, java.lang.String userName, int threadID)
Create a new ConditionalNG if the ConditionalNG does not exist.void
deleteBean(ConditionalNG conditionalNG, java.lang.String property)
Method for a UI to delete a bean.void
deleteConditionalNG(ConditionalNG x)
Delete ConditionalNG by removing it from the manager.void
fireVetoableChange(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.String
getBeanTypeHandled(boolean plural)
Get the user-readable name of the type of NamedBean handled by this manager.ConditionalNG
getBySystemName(java.lang.String name)
Locate an existing instance based on a system name.ConditionalNG
getByUserName(LogixNG logixNG, java.lang.String name)
Find the ConditionalNG which is a member of the LogixNG with the supplied user name.ConditionalNG
getConditionalNG(LogixNG logixNG, java.lang.String name)
Locate via user name using the LogixNG, then system name if needed.java.lang.Class<ConditionalNG>
getNamedBeanClass()
Get the class of NamedBean supported by this Manager.LogixNG
getParentLogixNG(java.lang.String systemName)
Find the LogixNG which has the ConditionalNG system name in its ConditionalNG_Entry list.int
getXMLOrder()
Determine the order that types should be written when storing panel files.static DefaultConditionalNGManager
instance()
void
setLoadDisabled(boolean s)
Support for loading ConditionalNGs in a disabled statevoid
setRunOnGUIDelayed(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.char
typeLetter()
Manager.NameValidity
validSystemNameFormat(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, getByUserName, 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.jmrit.logixng.ConditionalNG_Manager
getAutoSystemName, getByUserName, getSubSystemNamePrefix
-
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.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 DefaultConditionalNGManager _instance
-
-
Constructor Detail
-
DefaultConditionalNGManager
public DefaultConditionalNGManager()
-
-
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:
getXMLOrder
in interfaceManager<ConditionalNG>
- Returns:
- write order for this Manager; larger is later.
-
typeLetter
public char typeLetter()
- Specified by:
typeLetter
in interfaceManager<ConditionalNG>
- 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:
validSystemNameFormat
in interfaceManager<ConditionalNG>
- Overrides:
validSystemNameFormat
in classAbstractManager<ConditionalNG>
- Parameters:
systemName
- the system name- Returns:
Manager.NameValidity.INVALID
if system name does not start withManager.getSystemNamePrefix()
;Manager.NameValidity.VALID_AS_PREFIX_ONLY
if system name equalsManager.getSystemNamePrefix()
; otherwiseManager.NameValidity.VALID
to allow Managers that do not perform more specific validation to be considered valid.
-
createConditionalNG
public ConditionalNG createConditionalNG(LogixNG logixNG, java.lang.String systemName, java.lang.String userName) throws java.lang.IllegalArgumentException
Create a new ConditionalNG if the ConditionalNG does not exist.- Specified by:
createConditionalNG
in interfaceConditionalNG_Manager
- Parameters:
logixNG
- The parent LogixNGsystemName
- The system nameuserName
- The user name- Returns:
- a new ConditionalNG or null if unable to create
- Throws:
java.lang.IllegalArgumentException
-
createConditionalNG
public ConditionalNG createConditionalNG(LogixNG logixNG, java.lang.String systemName, java.lang.String userName, int threadID) throws java.lang.IllegalArgumentException
Create a new ConditionalNG if the ConditionalNG does not exist.- Specified by:
createConditionalNG
in 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:
java.lang.IllegalArgumentException
-
createConditionalNG
public ConditionalNG createConditionalNG(LogixNG logixNG, java.lang.String userName) 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:
createConditionalNG
in interfaceConditionalNG_Manager
- Parameters:
logixNG
- The parent LogixNGuserName
- The user name- Returns:
- a new ConditionalNG or null if unable to create
- Throws:
java.lang.IllegalArgumentException
-
createConditionalNG
public ConditionalNG createConditionalNG(LogixNG logixNG, java.lang.String userName, int threadID) 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:
createConditionalNG
in 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:
java.lang.IllegalArgumentException
-
getConditionalNG
public ConditionalNG getConditionalNG(LogixNG logixNG, java.lang.String name)
Locate via user name using the LogixNG, then system name if needed. Does not create a new one if nothing found- Specified by:
getConditionalNG
in 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
public LogixNG getParentLogixNG(java.lang.String systemName)
Find the LogixNG which has the ConditionalNG system name in its ConditionalNG_Entry list.- Specified by:
getParentLogixNG
in interfaceConditionalNG_Manager
- Parameters:
systemName
- The ConditionalNG system name.- Returns:
- the parent LogixNG or null if none found.
-
getByUserName
public ConditionalNG getByUserName(LogixNG logixNG, java.lang.String name)
Find the ConditionalNG which is a member of the LogixNG with the supplied user name.- Specified by:
getByUserName
in 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
public ConditionalNG getBySystemName(java.lang.String name)
Locate an existing instance based on a system name.- Specified by:
getBySystemName
in interfaceConditionalNG_Manager
- Specified by:
getBySystemName
in interfaceManager<ConditionalNG>
- Overrides:
getBySystemName
in classAbstractManager<ConditionalNG>
- 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:
getBeanTypeHandled
in 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
public void deleteConditionalNG(ConditionalNG x)
Delete ConditionalNG by removing it from the manager. The ConditionalNG must first be deactivated so it stops processing.- Specified by:
deleteConditionalNG
in interfaceConditionalNG_Manager
- Parameters:
x
- the ConditionalNG to delete
-
setLoadDisabled
public void setLoadDisabled(boolean s)
Support for loading ConditionalNGs in a disabled state- Specified by:
setLoadDisabled
in interfaceConditionalNG_Manager
- Parameters:
s
- true if ConditionalNG should be disabled when loaded
-
setRunOnGUIDelayed
public void setRunOnGUIDelayed(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. Most tests turns off the delay to simplify the tests.- Specified by:
setRunOnGUIDelayed
in interfaceConditionalNG_Manager
- Parameters:
value
- true if execute() should run on GUI thread delayed, false otherwise.
-
instance
@InvokeOnGuiThread public static DefaultConditionalNGManager instance()
-
getNamedBeanClass
public java.lang.Class<ConditionalNG> 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:
getNamedBeanClass
in interfaceManager<ConditionalNG>
- 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 ConditionalNG conditionalNG, @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:
deleteBean
in interfaceManager<ConditionalNG>
- Overrides:
deleteBean
in 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:
java.beans.PropertyVetoException
- If the recipients wishes the delete to be aborted (see above)
-
-