Package jmri
Class TurnoutOperationManager
- java.lang.Object
-
- jmri.TurnoutOperationManager
-
- All Implemented Interfaces:
InstanceManagerAutoDefault
public class TurnoutOperationManager extends java.lang.Object implements InstanceManagerAutoDefault
class to look after the collection of TurnoutOperation subclasses Unlike the other xxxManager, this does not inherit from AbstractManager since the resources it deals with are not DCC system resources but rather purely internal state.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
doOperations
(package private) java.beans.PropertyChangeSupport
pcs
Property change support.
-
Constructor Summary
Constructors Constructor Description TurnoutOperationManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addOperation(TurnoutOperation op)
add a new operation Silently replaces any existing operation with the same namevoid
addPropertyChangeListener(java.beans.PropertyChangeListener l)
static java.lang.String[]
concatenateTypeLists(java.lang.String[] types)
Proxy support.void
dispose()
protected void
firePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
boolean
getDoOperations()
Get ( potentially update ) status of whether operations are in use.TurnoutOperation
getMatchingOperation(Turnout t, int apparentMode)
Find the correct operation for this turnout.TurnoutOperation
getMatchingOperationAlways(Turnout t)
TurnoutOperation
getMatchingOperationAlways(Turnout t, int apparentMode)
Find a suitable operation for this turnout, based on its feedback type.TurnoutOperation
getOperation(java.lang.String name)
Find a TurnoutOperation by its name.java.lang.String
getTooltipForOperator(java.lang.String operatorName, Turnout t)
Get a ToolTip or descriptive comment for the Operator.TurnoutOperation[]
getTurnoutOperations()
void
loadOperationTypes()
Load the operation types given by the current TurnoutManager instance, in the order given.protected void
removeOperation(TurnoutOperation op)
void
removePropertyChangeListener(java.beans.PropertyChangeListener l)
void
setDoOperations(boolean b)
Set that Turnout Operations are in use.
-
-
-
Field Detail
-
doOperations
boolean doOperations
-
pcs
java.beans.PropertyChangeSupport pcs
Property change support.
-
-
Constructor Detail
-
TurnoutOperationManager
public TurnoutOperationManager()
-
-
Method Detail
-
dispose
public void dispose()
-
getTurnoutOperations
public TurnoutOperation[] getTurnoutOperations()
-
addOperation
protected void addOperation(@Nonnull TurnoutOperation op)
add a new operation Silently replaces any existing operation with the same name- Parameters:
op
-TurnoutOperation
to add/replace
-
removeOperation
protected void removeOperation(@Nonnull TurnoutOperation op)
-
getOperation
public TurnoutOperation getOperation(@Nonnull java.lang.String name)
Find a TurnoutOperation by its name.- Parameters:
name
- name ofTurnoutOperation
to retrieve.- Returns:
- the operation
-
loadOperationTypes
public void loadOperationTypes()
Load the operation types given by the current TurnoutManager instance, in the order given.The order is important because the acceptable feedback modes may overlap. All we do is instantiate the classes. The constructors take care of putting everything in the right places. We allow multiple occurrences of the same name without complaining so the Proxy stuff works. There's a threading problem here, because this invokes gets the current turnout manager, often the proxy manager, which in turn invokes loadOperationTypes again. This is bad. It's not clear why it even works.
-
getMatchingOperationAlways
public TurnoutOperation getMatchingOperationAlways(@Nonnull Turnout t, int apparentMode)
Find a suitable operation for this turnout, based on its feedback type. The mode is passed separately so the caller can transform it- Parameters:
t
- turnoutapparentMode
- Turnout Feedback mode(s) to be used when finding a matching operation- Returns:
- the turnout operation
-
getMatchingOperation
public TurnoutOperation getMatchingOperation(@Nonnull Turnout t, int apparentMode)
Find the correct operation for this turnout. If operations are globally disabled, return null.- Parameters:
t
- turnoutapparentMode
- mode(s) to be used when finding a matching operation- Returns:
- operation
-
getMatchingOperationAlways
public TurnoutOperation getMatchingOperationAlways(@Nonnull Turnout t)
-
getDoOperations
public boolean getDoOperations()
Get ( potentially update ) status of whether operations are in use.- Returns:
- true if in use, else false.
-
setDoOperations
public void setDoOperations(boolean b)
Set that Turnout Operations are in use.- Parameters:
b
- true to use, else false to disable.
-
concatenateTypeLists
public static java.lang.String[] concatenateTypeLists(@Nonnull java.lang.String[] types)
Proxy support. Take a concatenation of operation type lists from multiple systems and turn it into a single list, by eliminating duplicates and ensuring that NoFeedback - which matches anything - comes at the end if it is present at all.- Parameters:
types
- list of types possibly containing duplicates- Returns:
- list reduced as described above
-
addPropertyChangeListener
public void addPropertyChangeListener(@Nonnull java.beans.PropertyChangeListener l)
-
removePropertyChangeListener
public void removePropertyChangeListener(@Nonnull java.beans.PropertyChangeListener l)
-
firePropertyChange
protected void firePropertyChange(@Nonnull java.lang.String p, java.lang.Object old, java.lang.Object n)
-
getTooltipForOperator
public java.lang.String getTooltipForOperator(java.lang.String operatorName, Turnout t)
Get a ToolTip or descriptive comment for the Operator.- Parameters:
operatorName
- name of the Turnout Operatort
- The Turnout that the Operator would operate- Returns:
- Descriptive String, or null.
-
-