Class ConditionalEditBase
- java.lang.Object
-
- jmri.jmrit.conditional.ConditionalEditBase
-
- Direct Known Subclasses:
ConditionalList
,ConditionalTreeEdit
public class ConditionalEditBase extends java.lang.Object
This is the base class for the Conditional edit view classes. Contains shared variables and methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ConditionalEditBase.LogixEventListener
Create a custom listener event.(package private) static class
ConditionalEditBase.NameBoxListener
Listen for name combo box selection events.(package private) class
ConditionalEditBase.PickSingleListener
Listen for Pick Single table click events.static class
ConditionalEditBase.SelectionMode
Input selection names.
-
Field Summary
Fields Modifier and Type Field Description (package private) ConditionalManager
_conditionalManager
(package private) Logix
_curLogix
(package private) JmriJFrame
_editLogixFrame
(package private) boolean
_inEditMode
(package private) LogixManager
_logixManager
(package private) ConditionalEditBase.PickSingleListener
_pickListener
(package private) javax.swing.JFrame
_pickSingleFrame
(package private) javax.swing.JTable
_pickTable
(package private) PickFrame
_pickTables
(package private) javax.swing.JTabbedPane
_pickTabPane
(package private) ConditionalEditBase.SelectionMode
_selectionMode
(package private) boolean
_showReminder
(package private) boolean
_suppressIndirectRef
(package private) boolean
_suppressReminder
(package private) java.util.List<ConditionalEditBase.LogixEventListener>
listenerList
Maintain a list of listeners -- normally only one.java.util.HashMap<java.lang.String,java.lang.String>
logixData
This contains a list of commands to be processed by the listener recipient.
-
Constructor Summary
Constructors Constructor Description ConditionalEditBase()
ConditionalEditBase(java.lang.String sName)
Set the Logix and Conditional managers and set the selection mode.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLogixEventListener(ConditionalEditBase.LogixEventListener listener)
Add a listener.(package private) java.lang.String
appendToAntecedent(Conditional.AntecedentOperator logicType, int varListSize, java.lang.String antecedent)
Add a variable R# entry to the antecedent string.void
bringToFront()
(package private) boolean
checkConditionalReferences(java.lang.String logixName)
Check for conditional references.(package private) boolean
checkConditionalUserName(java.lang.String uName, Logix logix)
Verify that the user name is not a duplicate for the selected Logix.(package private) void
closeSinglePanelPickList()
Close a single panel picklist JFrame and related items.(package private) boolean
confirmActionAsVariable(java.lang.String actionName, java.lang.String variableName)
Check if user OK's the use of an item as both an action and a state variable.(package private) boolean
confirmIndirectMemory(java.lang.String memName)
Check if user will provide a valid item name in a Memory variable.(package private) NamedBeanComboBox<?>
createNameBox(Conditional.ItemType itemType)
Create a combo name box for Variable and Action name selection.(package private) void
createSinglePanelPickList(Conditional.ItemType itemType, ConditionalEditBase.PickSingleListener listener, boolean actionType)
Create a single panel picklist JFrame for choosing action and variable names.(package private) void
displayBadNumberReference(Conditional.Action actionType)
Display an error message to user when an invalid number is provided in Conditional setup.(package private) void
findPickListTabPane(java.awt.Component[] compList, int level)
Recursive search for the tab panel.(package private) void
fireLogixEvent()
Notify the listeners to check for new data.static java.lang.String
formatTime(int hour, int minute)
Format time to hh:mm given integer hour and minute.protected java.lang.String
getClassName()
(package private) Light
getLight(java.lang.String name)
Get Light instance.(package private) void
hidePickListTable()
Hide the drag-n-drop Pick List if the last detail edit is closing.(package private) void
loadReferenceNames(java.util.List<ConditionalVariable> varList, java.util.TreeSet<java.lang.String> treeSet)
Build a tree set from conditional references.(package private) void
loadSelectionMode()
Get the saved mode selection, default to the tranditional tabbed pick list.void
locateAt(java.awt.Component c)
(package private) java.lang.String
makeAntecedent(java.util.List<ConditionalVariable> variableList)
Create an antecedent string based on the current variables(package private) void
messageDuplicateConditionalUserName(java.lang.String svName)
Send a duplicate Conditional user name message for Edit Logix pane.(package private) void
messageInvalidActionItemName(java.lang.String name, java.lang.String itemType)
Send an Invalid Conditional Action name message for Edit Logix pane.(package private) void
messageInvalidSignalHeadAppearance(java.lang.String name, java.lang.String appearance)
Send an Invalid Conditional SignalHead state message for Edit Logix pane.(package private) void
openPickListTable()
Open a new drag-n-drop Pick List to drag Variable and Action names from to form Logix Conditionals.(package private) int
parseTime(java.lang.String s)
void
removeLogixEventListener(ConditionalEditBase.LogixEventListener listener)
Remove a listener -- not used.(package private) void
setPickListTab(Conditional.ItemType curType, boolean actionType)
Set the pick list tab based on the variable or action type.(package private) void
showSaveReminder()
Display reminder to save.static java.lang.String
translateAntecedent(java.lang.String antecedent, boolean isLocal)
Translate an antecedent string between English and the current language as determined by the Bundle classes.(package private) void
updateWhereUsed(java.util.TreeSet<java.lang.String> oldTargetNames, java.util.TreeSet<java.lang.String> newTargetNames, java.lang.String refName)
Update the conditional reference where used.(package private) boolean
validateAntecedent(Conditional.AntecedentOperator logicType, java.lang.String antecedentText, java.util.List<ConditionalVariable> variableList, Conditional curConditional)
Check the antecedent and logic type.(package private) java.lang.String
validateAudioReference(java.lang.String name)
Check an Audio reference of text.(package private) java.lang.String
validateConditionalReference(java.lang.String name)
Check Conditional reference of text.(package private) java.lang.String
validateEntryExitReference(java.lang.String name)
Check an EntryExit reference of text.(package private) boolean
validateIntensity(int time)
Check if text represents an integer is suitable for percentage w/o NumberFormatException.(package private) boolean
validateIntensityReference(Conditional.Action actionType, java.lang.String intReference)
Check if String is an integer or references an integer.(package private) java.lang.String
validateLightReference(java.lang.String name)
Check Light reference of text.(package private) java.lang.String
validateLogixReference(java.lang.String name)
Check Logix reference of text.(package private) java.lang.String
validateMemoryReference(java.lang.String name)
Check Memory reference of text.(package private) java.lang.String
validateOBlockReference(java.lang.String name)
Check OBlock reference of text.(package private) java.lang.String
validateRouteReference(java.lang.String name)
Check Route reference of text.(package private) java.lang.String
validateSensorReference(java.lang.String name)
Check Sensor reference of text.(package private) java.lang.String
validateSignalHeadReference(java.lang.String name)
Check SignalHead reference of text.(package private) java.lang.String
validateSignalMastReference(java.lang.String name)
Check SignalMast reference of text.(package private) boolean
validateTime(Conditional.Action actionType, float time)
Range check time entry (assumes seconds).(package private) boolean
validateTimeReference(Conditional.Action actionType, java.lang.String ref)
Check if a string is decimal or references a decimal.(package private) java.lang.String
validateTurnoutReference(java.lang.String name)
Check Turnout reference of text.(package private) java.lang.String
validateWarrantReference(java.lang.String name)
Check Warrant reference of text.
-
-
-
Field Detail
-
_conditionalManager
ConditionalManager _conditionalManager
-
_logixManager
LogixManager _logixManager
-
_editLogixFrame
JmriJFrame _editLogixFrame
-
_inEditMode
boolean _inEditMode
-
_showReminder
boolean _showReminder
-
_suppressReminder
boolean _suppressReminder
-
_suppressIndirectRef
boolean _suppressIndirectRef
-
_selectionMode
ConditionalEditBase.SelectionMode _selectionMode
-
_pickTable
javax.swing.JTable _pickTable
-
_pickTabPane
javax.swing.JTabbedPane _pickTabPane
-
_pickTables
PickFrame _pickTables
-
_pickSingleFrame
javax.swing.JFrame _pickSingleFrame
-
_pickListener
ConditionalEditBase.PickSingleListener _pickListener
-
listenerList
java.util.List<ConditionalEditBase.LogixEventListener> listenerList
Maintain a list of listeners -- normally only one.
-
logixData
public java.util.HashMap<java.lang.String,java.lang.String> logixData
This contains a list of commands to be processed by the listener recipient.
-
-
Constructor Detail
-
ConditionalEditBase
public ConditionalEditBase(java.lang.String sName)
Set the Logix and Conditional managers and set the selection mode.- Parameters:
sName
- the Logix system name being edited
-
ConditionalEditBase
public ConditionalEditBase()
-
-
Method Detail
-
loadSelectionMode
void loadSelectionMode()
Get the saved mode selection, default to the tranditional tabbed pick list.During the menu build process, the corresponding menu item is set to selected.
- Since:
- 4.7.3
-
addLogixEventListener
public void addLogixEventListener(ConditionalEditBase.LogixEventListener listener)
Add a listener.- Parameters:
listener
- The recipient
-
removeLogixEventListener
public void removeLogixEventListener(ConditionalEditBase.LogixEventListener listener)
Remove a listener -- not used.- Parameters:
listener
- The recipient
-
fireLogixEvent
void fireLogixEvent()
Notify the listeners to check for new data.
-
makeAntecedent
java.lang.String makeAntecedent(java.util.List<ConditionalVariable> variableList)
Create an antecedent string based on the current variablesThe antecedent consists of all of the variables "in order" combined with the current operator.
- Parameters:
variableList
- The current variable list- Returns:
- the resulting antecedent string
- Since:
- 4.11.5
-
appendToAntecedent
java.lang.String appendToAntecedent(Conditional.AntecedentOperator logicType, int varListSize, java.lang.String antecedent)
Add a variable R# entry to the antecedent string. If not the first one, include and or or depending on the logic type- Parameters:
logicType
- The current logic type.varListSize
- The current size of the variable list.antecedent
- The current antecedent- Returns:
- an extended antecedent
- Since:
- 4.11.5
-
validateAntecedent
boolean validateAntecedent(Conditional.AntecedentOperator logicType, java.lang.String antecedentText, java.util.List<ConditionalVariable> variableList, Conditional curConditional)
Check the antecedent and logic type.The antecedent text is translated and verified. A new one is created if necessary.
- Parameters:
logicType
- The current logic type. Types other than Mixed are ignored.antecedentText
- The proposed antecedent string using the local language.variableList
- The current variable list.curConditional
- The current conditional.- Returns:
- false if antecedent can't be validated
- Since:
- 4.11.5
-
translateAntecedent
public static java.lang.String translateAntecedent(java.lang.String antecedent, boolean isLocal)
Translate an antecedent string between English and the current language as determined by the Bundle classes.The property files have Logic??? keys for translating to the target language.
- Parameters:
antecedent
- The antecedent string which can either local or EnglishisLocal
- True if the antecedent string has local words.- Returns:
- the translated antecedent string.
- Since:
- 4.11.5
-
checkConditionalUserName
boolean checkConditionalUserName(java.lang.String uName, Logix logix)
Verify that the user name is not a duplicate for the selected Logix.- Parameters:
uName
- is the user name to be checkedlogix
- is the Logix that is being updated- Returns:
- true if the name is unique
-
createNameBox
NamedBeanComboBox<?> createNameBox(Conditional.ItemType itemType)
Create a combo name box for Variable and Action name selection.- Parameters:
itemType
- The selected variable or action type- Returns:
- nameBox A combo box based on the item type
-
createSinglePanelPickList
void createSinglePanelPickList(Conditional.ItemType itemType, ConditionalEditBase.PickSingleListener listener, boolean actionType)
Create a single panel picklist JFrame for choosing action and variable names.- Parameters:
itemType
- The selected variable or action typelistener
- The listener to be assigned to the picklistactionType
- True if Action, false if Variable.- Since:
- 4.7.3
-
closeSinglePanelPickList
void closeSinglePanelPickList()
Close a single panel picklist JFrame and related items.- Since:
- 4.7.3
-
openPickListTable
void openPickListTable()
Open a new drag-n-drop Pick List to drag Variable and Action names from to form Logix Conditionals.
-
hidePickListTable
void hidePickListTable()
Hide the drag-n-drop Pick List if the last detail edit is closing.
-
setPickListTab
void setPickListTab(Conditional.ItemType curType, boolean actionType)
Set the pick list tab based on the variable or action type. If there is not a corresponding tab, hide the picklist.- Parameters:
curType
- is the current typeactionType
- True if Action, false if Variable.
-
findPickListTabPane
void findPickListTabPane(java.awt.Component[] compList, int level)
Recursive search for the tab panel.- Parameters:
compList
- The components for the current Levellevel
- The current level in the structure
-
loadReferenceNames
void loadReferenceNames(java.util.List<ConditionalVariable> varList, java.util.TreeSet<java.lang.String> treeSet)
Build a tree set from conditional references.- Parameters:
varList
- The ConditionalVariable list that might contain conditional referencestreeSet
- A tree set to be built from the varList data- Since:
- 4.7.4
-
checkConditionalReferences
boolean checkConditionalReferences(java.lang.String logixName)
Check for conditional references.- Parameters:
logixName
- The Logix under consideration- Returns:
- true if no references
- Since:
- 4.7.4
-
updateWhereUsed
void updateWhereUsed(java.util.TreeSet<java.lang.String> oldTargetNames, java.util.TreeSet<java.lang.String> newTargetNames, java.lang.String refName)
Update the conditional reference where used.The difference between the saved target names and new target names is used to add/remove where used references.
- Parameters:
oldTargetNames
- The conditional target names before updatingnewTargetNames
- The conditional target names after updatingrefName
- The system name for the referencing conditional- Since:
- 4.7.4
-
showSaveReminder
void showSaveReminder()
Display reminder to save. The class is set to LogixTableAction.
-
validateIntensityReference
boolean validateIntensityReference(Conditional.Action actionType, java.lang.String intReference)
Check if String is an integer or references an integer.- Parameters:
actionType
- Conditional action to check for, i.e. ACTION_SET_LIGHT_INTENSITYintReference
- string referencing a decimal for light intensity or the name of a memory- Returns:
- true if either correct decimal format or a memory with the given name is present
-
validateIntensity
boolean validateIntensity(int time)
Check if text represents an integer is suitable for percentage w/o NumberFormatException.- Parameters:
time
- value to use as light intensity percentage- Returns:
- true if time is an integer in range 0 - 100
-
validateTimeReference
boolean validateTimeReference(Conditional.Action actionType, java.lang.String ref)
Check if a string is decimal or references a decimal.- Parameters:
actionType
- enum representing the Conditional action type being checked, i.e. ACTION_DELAYED_TURNOUTref
- entry to check- Returns:
- true if ref is itself a decimal or user will provide one from a Memory at run time
-
validateTime
boolean validateTime(Conditional.Action actionType, float time)
Range check time entry (assumes seconds).- Parameters:
actionType
- integer representing the Conditional action type being checked, i.e. ACTION_DELAYED_TURNOUTtime
- value to be checked- Returns:
- false if time > 3600 (seconds) or too small
-
displayBadNumberReference
void displayBadNumberReference(Conditional.Action actionType)
Display an error message to user when an invalid number is provided in Conditional setup.- Parameters:
actionType
- integer representing the Conditional action type being checked, i.e. ACTION_DELAYED_TURNOUT
-
validateMemoryReference
java.lang.String validateMemoryReference(java.lang.String name)
Check Memory reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Memory, null if not found
-
confirmIndirectMemory
boolean confirmIndirectMemory(java.lang.String memName)
Check if user will provide a valid item name in a Memory variable.- Parameters:
memName
- Memory location to provide item name at run time- Returns:
- false if user replies No
-
confirmActionAsVariable
boolean confirmActionAsVariable(java.lang.String actionName, java.lang.String variableName)
Check if user OK's the use of an item as both an action and a state variable.- Parameters:
actionName
- name of ConditionalActionvariableName
- name of ConditionalVariable- Returns:
- false if user replies No
-
validateTurnoutReference
java.lang.String validateTurnoutReference(java.lang.String name)
Check Turnout reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Turnout, null if not found
-
validateSignalHeadReference
java.lang.String validateSignalHeadReference(java.lang.String name)
Check SignalHead reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding SignalHead, null if not found
-
validateSignalMastReference
java.lang.String validateSignalMastReference(java.lang.String name)
Check SignalMast reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Signal Mast, null if not found
-
validateWarrantReference
java.lang.String validateWarrantReference(java.lang.String name)
Check Warrant reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Warrant, null if not found
-
validateOBlockReference
java.lang.String validateOBlockReference(java.lang.String name)
Check OBlock reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding OBlock, null if not found
-
validateSensorReference
java.lang.String validateSensorReference(java.lang.String name)
Check Sensor reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Sensor, null if not found
-
validateLightReference
java.lang.String validateLightReference(java.lang.String name)
Check Light reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Light, null if not found
-
validateConditionalReference
java.lang.String validateConditionalReference(java.lang.String name)
Check Conditional reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Conditional, null if not found
-
validateLogixReference
java.lang.String validateLogixReference(java.lang.String name)
Check Logix reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Logix, null if not found
-
validateRouteReference
java.lang.String validateRouteReference(java.lang.String name)
Check Route reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding Route, null if not found
-
validateAudioReference
java.lang.String validateAudioReference(java.lang.String name)
Check an Audio reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system or user name of the corresponding AudioManager, null if not found
-
validateEntryExitReference
java.lang.String validateEntryExitReference(java.lang.String name)
Check an EntryExit reference of text.Show a message if not found.
- Parameters:
name
- the name to look for- Returns:
- the system name of the corresponding EntryExit pair, null if not found
-
getLight
Light getLight(java.lang.String name)
Get Light instance.Show a message if not found.
- Parameters:
name
- user or system name of an existing light- Returns:
- the Light object
-
parseTime
int parseTime(java.lang.String s)
-
formatTime
public static java.lang.String formatTime(int hour, int minute)
Format time to hh:mm given integer hour and minute.- Parameters:
hour
- value for time hoursminute
- value for time minutes- Returns:
- Formatted time string
-
messageInvalidSignalHeadAppearance
void messageInvalidSignalHeadAppearance(java.lang.String name, java.lang.String appearance)
Send an Invalid Conditional SignalHead state message for Edit Logix pane.- Parameters:
name
- proposed appearance descriptionappearance
- to compare to
-
messageInvalidActionItemName
void messageInvalidActionItemName(java.lang.String name, java.lang.String itemType)
Send an Invalid Conditional Action name message for Edit Logix pane.- Parameters:
name
- user or system name to look upitemType
- type of Bean to look for
-
messageDuplicateConditionalUserName
void messageDuplicateConditionalUserName(java.lang.String svName)
Send a duplicate Conditional user name message for Edit Logix pane.- Parameters:
svName
- proposed name that duplicates an existing name
-
bringToFront
public void bringToFront()
-
locateAt
public void locateAt(java.awt.Component c)
-
getClassName
protected java.lang.String getClassName()
-
-