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 interfaceConditionalEditBase.LogixEventListenerCreate a custom listener event.(package private) static classConditionalEditBase.NameBoxListenerListen for name combo box selection events.(package private) classConditionalEditBase.PickSingleListenerListen for Pick Single table click events.static classConditionalEditBase.SelectionModeInput 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>listenerListMaintain a list of listeners -- normally only one.java.util.HashMap<java.lang.String,java.lang.String>logixDataThis 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 voidaddLogixEventListener(ConditionalEditBase.LogixEventListener listener)Add a listener.(package private) java.lang.StringappendToAntecedent(Conditional.AntecedentOperator logicType, int varListSize, java.lang.String antecedent)Add a variable R# entry to the antecedent string.voidbringToFront()(package private) booleancheckConditionalReferences(java.lang.String logixName)Check for conditional references.(package private) booleancheckConditionalUserName(java.lang.String uName, Logix logix)Verify that the user name is not a duplicate for the selected Logix.(package private) voidcloseSinglePanelPickList()Close a single panel picklist JFrame and related items.(package private) booleanconfirmActionAsVariable(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) booleanconfirmIndirectMemory(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) voidcreateSinglePanelPickList(Conditional.ItemType itemType, ConditionalEditBase.PickSingleListener listener, boolean actionType)Create a single panel picklist JFrame for choosing action and variable names.(package private) voiddisplayBadNumberReference(Conditional.Action actionType)Display an error message to user when an invalid number is provided in Conditional setup.(package private) voidfindPickListTabPane(java.awt.Component[] compList, int level)Recursive search for the tab panel.(package private) voidfireLogixEvent()Notify the listeners to check for new data.static java.lang.StringformatTime(int hour, int minute)Format time to hh:mm given integer hour and minute.protected java.lang.StringgetClassName()(package private) LightgetLight(java.lang.String name)Get Light instance.(package private) voidhidePickListTable()Hide the drag-n-drop Pick List if the last detail edit is closing.(package private) voidloadReferenceNames(java.util.List<ConditionalVariable> varList, java.util.TreeSet<java.lang.String> treeSet)Build a tree set from conditional references.(package private) voidloadSelectionMode()Get the saved mode selection, default to the tranditional tabbed pick list.voidlocateAt(java.awt.Component c)(package private) java.lang.StringmakeAntecedent(java.util.List<ConditionalVariable> variableList)Create an antecedent string based on the current variables(package private) voidmessageDuplicateConditionalUserName(java.lang.String svName)Send a duplicate Conditional user name message for Edit Logix pane.(package private) voidmessageInvalidActionItemName(java.lang.String name, java.lang.String itemType)Send an Invalid Conditional Action name message for Edit Logix pane.(package private) voidopenPickListTable()Open a new drag-n-drop Pick List to drag Variable and Action names from to form Logix Conditionals.(package private) intparseTime(java.lang.String s)voidremoveLogixEventListener(ConditionalEditBase.LogixEventListener listener)Remove a listener -- not used.(package private) voidsetPickListTab(Conditional.ItemType curType, boolean actionType)Set the pick list tab based on the variable or action type.(package private) voidshowSaveReminder()Display reminder to save.static java.lang.StringtranslateAntecedent(java.lang.String antecedent, boolean isLocal)Translate an antecedent string between English and the current language as determined by the Bundle classes.(package private) voidupdateWhereUsed(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) booleanvalidateAntecedent(Conditional.AntecedentOperator logicType, java.lang.String antecedentText, java.util.List<ConditionalVariable> variableList, Conditional curConditional)Check the antecedent and logic type.(package private) java.lang.StringvalidateAudioReference(java.lang.String name)Check an Audio reference of text.(package private) java.lang.StringvalidateConditionalReference(java.lang.String name)Check Conditional reference of text.(package private) java.lang.StringvalidateEntryExitReference(java.lang.String name)Check an EntryExit reference of text.(package private) booleanvalidateIntensity(int time)Check if text represents an integer is suitable for percentage w/o NumberFormatException.(package private) booleanvalidateIntensityReference(Conditional.Action actionType, java.lang.String intReference)Check if String is an integer or references an integer.(package private) java.lang.StringvalidateLightReference(java.lang.String name)Check Light reference of text.(package private) java.lang.StringvalidateLogixReference(java.lang.String name)Check Logix reference of text.(package private) java.lang.StringvalidateMemoryReference(java.lang.String name)Check Memory reference of text.(package private) java.lang.StringvalidateOBlockReference(java.lang.String name)Check OBlock reference of text.(package private) java.lang.StringvalidateRouteReference(java.lang.String name)Check Route reference of text.(package private) java.lang.StringvalidateSensorReference(java.lang.String name)Check Sensor reference of text.(package private) java.lang.StringvalidateSignalHeadReference(java.lang.String name)Check SignalHead reference of text.(package private) java.lang.StringvalidateSignalMastReference(java.lang.String name)Check SignalMast reference of text.(package private) booleanvalidateTime(Conditional.Action actionType, float time)Range check time entry (assumes seconds).(package private) booleanvalidateTimeReference(Conditional.Action actionType, java.lang.String ref)Check if a string is decimal or references a decimal.(package private) java.lang.StringvalidateTurnoutReference(java.lang.String name)Check Turnout reference of text.(package private) java.lang.StringvalidateWarrantReference(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(@Nonnull 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, @CheckForNull 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, @CheckForNull 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(@Nonnull 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
@CheckForNull java.lang.String validateMemoryReference(@CheckForNull 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
@CheckForNull java.lang.String validateTurnoutReference(@CheckForNull 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
@CheckForNull java.lang.String validateSignalHeadReference(@CheckForNull 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
@CheckForNull java.lang.String validateSignalMastReference(@CheckForNull 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
@CheckForNull java.lang.String validateWarrantReference(@CheckForNull 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
@CheckForNull java.lang.String validateOBlockReference(@CheckForNull 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
@CheckForNull java.lang.String validateSensorReference(@CheckForNull 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
@CheckForNull java.lang.String validateLightReference(@CheckForNull 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
@CheckForNull java.lang.String validateConditionalReference(@CheckForNull 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
@CheckForNull java.lang.String validateLogixReference(@CheckForNull 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
@CheckForNull java.lang.String validateRouteReference(@CheckForNull 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
@CheckForNull java.lang.String validateAudioReference(@CheckForNull 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
@CheckForNull java.lang.String validateEntryExitReference(@CheckForNull 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
@CheckForNull Light getLight(@CheckForNull 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
-
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
-
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()
-
-