Class ConditionalTreeEdit


  • public class ConditionalTreeEdit
    extends ConditionalEditBase
    A tree based editor for maintaining Logix Conditionals, State Variables and Actions.

    The tree has 3 levels. The first level are the conditionals contained in the selected Logix. The second level contains the antecedent, logic type and trigger mode settings. The third level contains the detail Variable and Action lines.

    Compare with the other Conditional Edit tool ConditionalListEdit

    • Constructor Detail

      • ConditionalTreeEdit

        public ConditionalTreeEdit​(java.lang.String sName)
        Create a new Conditional Tree View editor.
        Parameters:
        sName - The system name of the current Logix
    • Method Detail

      • makeEditLogixWindow

        void makeEditLogixWindow()
        Create the edit logix window.

        The left side contains a tree structure containing the conditionals for the current Logix. The right side contains detail edit panes based on the current tree row selection.

      • makeDetailGrid

        void makeDetailGrid​(java.lang.String gridType)
        Build new GridBag content. The grid panel is hidden, emptied, re-built and made visible.
        Parameters:
        gridType - The type of grid to create
      • makeEmptyGrid

        void makeEmptyGrid​(java.awt.GridBagConstraints c)
        This grid is used when there are no edit grids required.
        Parameters:
        c - The constraints object used for the grid construction
      • makeConditionalGrid

        void makeConditionalGrid​(java.awt.GridBagConstraints c)
        This grid is used to edit the Conditional User Name.
        Parameters:
        c - The constraints object used for the grid construction
      • makeAntecedentGrid

        void makeAntecedentGrid​(java.awt.GridBagConstraints c)
        This grid is used to edit the Antecedent when the Logic Type is Mixed.
        Parameters:
        c - The constraints object used for the grid construction
      • makeLogicTypeGrid

        void makeLogicTypeGrid​(java.awt.GridBagConstraints c)
        This grid is used to edit the Logic Type.
        Parameters:
        c - The constraints object used for the grid construction
      • addPressed

        void addPressed()
        Add new items: Conditionals, Variables or Actions.
      • newVariable

        void newVariable()
        Create a new variable Can be invoked by a Variables or Variable node.
      • newAction

        void newAction()
        Create a new action Can be invoked by a Actions or Action node.
      • updatePressed

        void updatePressed()
        Apply the updates to the current node.
      • userNameChanged

        void userNameChanged​(java.lang.String newName)
        Change the conditional user name.
        Parameters:
        newName - The proposed new name
      • logicTypeChanged

        void logicTypeChanged​(Conditional.AntecedentOperator newType)
        Respond to a change of Logic Type in the dialog window by showing/hiding the _antecedentPanel when Mixed is selected.
        Parameters:
        newType - The selected logic type
      • antecedentChanged

        void antecedentChanged​(java.lang.String antecedentText)
        Update the antecedent.
        Parameters:
        antecedentText - the new antecedent
      • makeAntecedent

        void makeAntecedent()
        Build the antecedent statement.
      • validateAntecedent

        boolean validateAntecedent​(java.lang.String antecedentText)
        Check the antecedent and logic type.
        Parameters:
        antecedentText - The user supplied antecedent text
        Returns:
        false if antecedent can't be validated
      • togglePressed

        void togglePressed()
        Update the Actions trigger mode, adjust the Action descriptions.
      • checkPressed

        void checkPressed()
        Refresh the Conditional or Variable state.
      • deletePressed

        void deletePressed()
        Process the node delete request.
      • upPressed

        void upPressed()
        Move a conditional, variable or action row up 1 row.
      • downPressed

        void downPressed()
        Move a conditional, variable or action row down 1 row.
      • removeActionTimers

        void removeActionTimers()
        Remove Action timers and listeners before Action list structure changes. This relates to moving and deleting rows. New actions at the end are not problem. The issue is that the timer listeners are tied to the action row number. This can result in orphan timers and listeners that keep running.
        Since:
        4.11.2
      • moveTreeNode

        void moveTreeNode​(java.lang.String direction)
        Move a tree node in response to a up or down request.
        Parameters:
        direction - The direction of movement, Up or Down
      • setMoveButtons

        void setMoveButtons()
        Enable/Disable the Up and Down buttons based on the postion in the list.
      • helpPressed

        void helpPressed()
        Respond to Help button press in the Edit Logix menu bar. Only visible when using mixed mode and an antecedent node is selected.
      • cancelPressed

        void cancelPressed()
        Cancel the current node edit.
      • donePressed

        void donePressed()
        Clean up, notify the parent Logix that edit session is done.
      • buildConditionalTree

        javax.swing.JTree buildConditionalTree()
        Create the conditional tree structure using the current Logix.
        Returns:
        _cdlTree The tree ddefinition with its content
      • createConditionalContent

        void createConditionalContent()
        Create the tree content. Level 1 are the conditionals, Level 2 includes the antecedent, logic type, trigger mode and parent nodes for Variables and Actions, Level 3 contains the detail Variable and Action entries.
      • buildNodeText

        java.lang.String buildNodeText​(java.lang.String nodeType,
                                       java.lang.Object component,
                                       int idx)
        Create the localized node text display strings based on node type.
        Parameters:
        nodeType - The type of the node
        component - The conditional object or child object
        idx - Optional index value
        Returns:
        nodeText containing the text to display on the node
      • setFocusListeners

        void setFocusListeners()
        Add the focus listener to each detail edit field.
      • setEditMode

        void setEditMode​(boolean active)
        Enable/disable buttons based on edit state. Open pick lists based on the current SelectionMode. The edit state controls the ability to select tree nodes.
        Parameters:
        active - True to make edit active, false to make edit inactive
      • doPickList

        void doPickList()
        Create a Variable or Action based tabbed PickList with appropriate tab selected.
      • doPickSingle

        void doPickSingle()
        Create a Variable or Action based single pane PickList.
      • buildVariableComponents

        void buildVariableComponents()
        Called once during class initialization to define the GUI objects. Where possible, the combo box content is loaded.
      • makeEmptyVariableGrid

        void makeEmptyVariableGrid​(java.awt.GridBagConstraints c)
        Create a one row grid with just the Variable Type box. This is the base for larger grids as well as the initial grid for new State Variables.
        Parameters:
        c - the constraints object used for the grid construction
      • makeStandardVariableGrid

        void makeStandardVariableGrid​(java.awt.GridBagConstraints c)
        Create the standard Name and State rows. The name field will be either a text field or a combo box. The name field label is a variable to support run time changes.
        Parameters:
        c - The constraints object used for the grid construction
      • makeSignalAspectVariableGrid

        void makeSignalAspectVariableGrid​(java.awt.GridBagConstraints c)
        Add the Aspect field for signal heads and signal masts.
        Parameters:
        c - The constraints object used for the grid construction
      • makeConditionalVariableGrid

        void makeConditionalVariableGrid​(java.awt.GridBagConstraints c)
        Create the Logix and Conditional rows and the State row.
        Parameters:
        c - The constraints object used for the grid construction
      • makeMemoryVariableGrid

        void makeMemoryVariableGrid​(java.awt.GridBagConstraints c)
        Create the Memory specific rows.
        Parameters:
        c - The constraints object used for the grid construction
      • makeFastClockVariableGrid

        void makeFastClockVariableGrid​(java.awt.GridBagConstraints c)
        Create the Fast Clock start and end time rows.
        Parameters:
        c - The constraints object used for the grid construction
      • initializeStateVariables

        void initializeStateVariables()
        Set display to show current state variable (curVariable) parameters.
      • setVariableNameBox

        void setVariableNameBox​(Conditional.ItemType itemType)
        Update the name combo box selection based on the current contents of the name field. Called by variableItemChanged.
        Parameters:
        itemType - The item type, such as sensor or turnout.
        Since:
        4.7.3
      • updateVariable

        void updateVariable()
        Respond to Update Variable button in the Edit Variable pane.
      • cleanUpVariable

        void cleanUpVariable()
        Clean up: Cancel, Update and Delete Variable buttons.
      • loadSelectLogixBox

        void loadSelectLogixBox()
        Load the Logix selection box. Set the selection to the current Logix.
        Since:
        4.7.4
      • loadSelectConditionalBox

        void loadSelectConditionalBox​(java.lang.String logixName)
        Load the Conditional selection box. The first row is a prompt.
        Parameters:
        logixName - The Logix system name for selecting the owned Conditionals
        Since:
        4.7.4
      • loadJComboBoxWithHeadAppearances

        void loadJComboBoxWithHeadAppearances​(javax.swing.JComboBox<java.lang.String> box,
                                              java.lang.String signalHeadName)
        Fetch valid localized appearances for a given Signal Head.

        Warn if head is not found.

        Parameters:
        box - the comboBox on the setup pane to fill
        signalHeadName - user or system name of the Signal Head
      • loadJComboBoxWithMastAspects

        void loadJComboBoxWithMastAspects​(javax.swing.JComboBox<java.lang.String> box,
                                          java.lang.String mastName)
        Fetch valid aspects for a given Signal Mast.

        Warn if mast is not found.

        Parameters:
        box - the comboBox on the setup pane to fill
        mastName - user or system name of the Signal Mast
      • validateVariable

        boolean validateVariable()
        Validate Variable data from Edit Variable panel, and transfer it to current variable object as appropriate.

        Messages are sent to the user for any errors found. This routine returns false immediately after finding the first error, even if there might be more errors.

        Returns:
        true if all data checks out OK, otherwise false
      • updateVariableOperator

        void updateVariableOperator()
        Update the variable operation. If a change has occurred, also update the antecedent and antecedent tree node.
      • updateVariableNegation

        void updateVariableNegation()
        Update the variable negation. If a change has occurred, also update the antecedent and antecedent tree node.
      • updateVariableList

        void updateVariableList()
        Update the conditional variable list and refresh the local copy. The parent Logix is de-activated and re-activated. This ensures that listeners are properly handled.
        Since:
        4.11.2
      • buildActionComponents

        void buildActionComponents()
        Called once during class initialization to define the GUI objects. Where possible, the combo box content is loaded.
      • makeEmptyActionGrid

        void makeEmptyActionGrid​(java.awt.GridBagConstraints c)
        Create a one row grid with just the Action Item box. This is the base for larger grids as well as the initial grid for new Actions.
        Parameters:
        c - the constraints object used for the grid construction
      • makeNameTypeActionGrid

        void makeNameTypeActionGrid​(java.awt.GridBagConstraints c,
                                    boolean finalRow)
        Create the standard Name and Type rows. The name field will be either a text field or a combo box. The name field label is a variable to support run time changes.
        Parameters:
        c - The constraints object used for the grid construction
        finalRow - Controls whether the tigger combo box is included
      • makeTypeActionGrid

        void makeTypeActionGrid​(java.awt.GridBagConstraints c,
                                boolean finalRow)
        Create the standard Type row.
        Parameters:
        c - The constraints object used for the grid construction
        finalRow - Controls whether the tigger combo box is included
      • makeStandardActionGrid

        void makeStandardActionGrid​(java.awt.GridBagConstraints c,
                                    boolean finalRow)
        Add the action box to the grid.
        Parameters:
        c - The constraints object used for the grid construction
        finalRow - Controls whether the tigger combo box is included
      • makeShortFieldActionGrid

        void makeShortFieldActionGrid​(java.awt.GridBagConstraints c,
                                      boolean includeBox)
        Add the short name field to the grid.
        Parameters:
        c - The constraints object used for the grid construction
        includeBox - Controls whether the normal action type combo box is included
      • makeTypeShortActionGrid

        void makeTypeShortActionGrid​(java.awt.GridBagConstraints c)
        Just a short text field, no name field. Used by set clock and jython command.
        Parameters:
        c - The constraints object used for the grid construction
      • makeFileActionGrid

        void makeFileActionGrid​(java.awt.GridBagConstraints c)
        Add the file selection components.
        Parameters:
        c - The constraints object used for the grid construction
      • makeChangeTriggerActionGrid

        void makeChangeTriggerActionGrid​(java.awt.GridBagConstraints c)
        Add the change/trigger box the grid. This is the last item in an Action and is usually called from one of the other entry points.
        Parameters:
        c - The constraints object used for the grid construction
      • actionItemChanged

        void actionItemChanged​(Conditional.ItemType type)
        Respond to a change in an Action Type comboBox.

        Set components visible for the selected type.

        Parameters:
        type - index of the newly selected Action type
      • setActionNameBox

        void setActionNameBox​(Conditional.ItemType itemType)
        Update the name combo box selection based on the current contents of the name field.
        Parameters:
        itemType - The item type, such as sensor or turnout.
        Since:
        4.7.3
      • cancelEditAction

        void cancelEditAction()
        Respond to Cancel action button and window closer of the Edit Action window.

        Also does cleanup of Update and Delete buttons.

      • updateAction

        void updateAction()
        Respond to Update button.
      • cleanUpAction

        void cleanUpAction()
        Clean up Update and Delete Action buttons.
      • setFileLocation

        void setFileLocation​(java.awt.event.ActionEvent e)
        Respond to the [...] button in the Edit Action window action section.

        Ask user to select an audio or python script file on disk.

        Parameters:
        e - the event heard
      • validateAction

        boolean validateAction()
        Validate Action data from Edit Action Window, and transfer it to current action object as appropriate.

        Messages are sent to the user for any errors found. This routine returns false immediately after finding an error, even if there might be more errors.

        Returns:
        true if all data checks out OK, otherwise false.
      • updateActionList

        void updateActionList()
        Update the conditional action list and refresh the local copy. The parent Logix is de-activated and re-activated. This ensures that listeners are properly handled, specifically the delayed sensor and turnout options.
        Since:
        4.11.2
      • checkIsAction

        boolean checkIsAction​(java.lang.String name,
                              Conditional.ItemType itemType)
        Check that a state variable is not also used as an action
        Parameters:
        name - of the state variable
        itemType - item type of the state variable
        Returns:
        true if variable is not an action of if the user OK's its use as an action also.
      • checkIsVariable

        boolean checkIsVariable​(java.lang.String name,
                                Conditional.ItemType itemType)
        Check that an action is not also used as a state variable
        Parameters:
        name - of the action
        itemType - item type of the action
        Returns:
        true if action is not a state variable of if the user OK's its use as such.