Class PaneProgPane

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible
Direct Known Subclasses:
PaneProgDp3Action.ThisProgPane

public class PaneProgPane extends JPanel implements PropertyChangeListener
Provide the individual panes for the TabbedPaneProgrammer.

Note that this is not only the panes carrying variables, but also the special purpose panes for the CV table, etc.

This class implements PropertyChangeListener so that it can be notified when a variable changes its busy status at the end of a programming read/write operation. There are four read and write operation types, all of which have to be handled carefully:

Write Changes
This must write changes that occur after the operation starts, because the act of writing a variable/CV may change another. For example, writing CV 1 will mark CV 29 as changed.

The definition of "changed" is operationally in the VariableValue.isChanged() member function.

Write All
Like write changes, this might have to go back and re-write a variable depending on what has previously happened. It should write every variable (at least) once.
Read All
This should read every variable once. UML Sequence diagram
Read Changes
This should read every variable that's marked as changed. Currently, we use a common definition of changed with the write operations, and that someday might have to change.
See Also:
  • Field Details

  • Constructor Details

    • PaneProgPane

      public PaneProgPane()
      Construct a null object.

      Normally only used for tests and to pre-load classes.

    • PaneProgPane

      public PaneProgPane(PaneContainer parent, String name, org.jdom2.Element pane, CvTableModel cvModel, VariableTableModel varModel, org.jdom2.Element modelElem, RosterEntry pRosterEntry)
    • PaneProgPane

      public PaneProgPane(PaneContainer parent, String name, org.jdom2.Element pane, CvTableModel cvModel, VariableTableModel varModel, org.jdom2.Element modelElem, RosterEntry pRosterEntry, boolean isProgPane)
      Construct the Pane from the XML definition element. In case this is invoked from off the Swing/AWT thread, it defers to that thread in a granular manner.
      Parameters:
      parent - The parent pane
      name - Name to appear on tab of pane
      pane - The JDOM Element for the pane definition
      cvModel - Already existing TableModel containing the CV definitions
      varModel - Already existing TableModel containing the variable definitions
      modelElem - "model" element from the Decoder Index, used to check what decoder options are present.
      pRosterEntry - The current roster entry, used to get sound labels.
      isProgPane - True if the pane is a default programmer pane
  • Method Details

    • setNoDecoder

      public void setNoDecoder()
    • getName

      public String getName()
      Overrides:
      getName in class Component
    • toString

      public String toString()
      Overrides:
      toString in class Component
    • enableReadButtons

      Enable the read all and read changes button if possible. This checks to make sure this is appropriate, given the attached programmer's capability.
    • enableConfirmButtons

      Enable the compare all and compare changes button if possible. This checks to make sure this is appropriate, given the attached programmer's capability.
    • countOpsNeeded

      public int countOpsNeeded(boolean read, boolean changes)
      Estimate the number of CVs that will be accessed when reading or writing the contents of this pane.
      Parameters:
      read - true if counting for read, false for write
      changes - true if counting for a *Changes operation; false, if counting for a *All operation
      Returns:
      the total number of CV reads/writes needed for this pane
    • makeOpsNeededSet

      public Set<Integer> makeOpsNeededSet(boolean read, boolean changes, Set<Integer> set)
      Produce a set of CVs that will be accessed when reading or writing the contents of this pane.
      Parameters:
      read - true if counting for read, false for write
      changes - true if counting for a *Changes operation; false, if counting for a *All operation
      set - The set to fill. Any CVs already in here will not be duplicated, which provides a way to aggregate a set of CVs across multiple panes.
      Returns:
      the same set as the parameter, for convenient chaining of operations.
    • enableButtons

      void enableButtons(boolean stat)
    • readPaneChanges

      public boolean readPaneChanges()
      Invoked by "Read changes on sheet" button, this sets in motion a continuing sequence of "read" operations on the variables and CVs in the Pane. Only variables in states marked as "changed" will be read.
      Returns:
      true is a read has been started, false if the pane is complete.
    • prepReadPane

      public void prepReadPane(boolean onlyChanges)
      Prepare this pane for a read operation.

      The read mechanism only reads variables in certain states (and needs to do that to handle error processing right now), so this is implemented by first setting all variables and CVs on this pane to TOREAD via this method

      Parameters:
      onlyChanges - true if only reading changes; false if reading all
    • readPaneAll

      public boolean readPaneAll()
      Invoked by "Read Full Sheet" button, this sets in motion a continuing sequence of "read" operations on the variables and CVs in the Pane. The read mechanism only reads variables in certain states (and needs to do that to handle error processing right now), so this is implemented by first setting all variables and CVs on this pane to TOREAD in prepReadPaneAll, then starting the execution.
      Returns:
      true is a read has been started, false if the pane is complete
    • setToRead

      void setToRead(boolean justChanges, boolean startProcess)
      Set the "ToRead" parameter in all variables and CVs on this pane.
      Parameters:
      justChanges - true if this is read changes, false if read all
      startProcess - true if this is the start of processing, false if cleaning up at end
    • setToWrite

      void setToWrite(boolean justChanges, boolean startProcess)
      Set the "ToWrite" parameter in all variables and CVs on this pane
      Parameters:
      justChanges - true if this is read changes, false if read all
      startProcess - true if this is the start of processing, false if cleaning up at end
    • executeRead

    • executeWrite

    • nextRead

      boolean nextRead()
      If there are any more read operations to be done on this pane, do the next one.

      Each invocation of this method reads one variable or CV; completion of that request will cause it to happen again, reading the next one, until there's nothing left to read.

      Returns:
      true is a read has been started, false if the pane is complete.
    • nextConfirm

      boolean nextConfirm()
      If there are any more compare operations to be done on this pane, do the next one.

      Each invocation of this method compares one CV; completion of that request will cause it to happen again, reading the next one, until there's nothing left to read.

      Returns:
      true is a compare has been started, false if the pane is complete.
    • writePaneChanges

      public boolean writePaneChanges()
      Invoked by "Write changes on sheet" button, this sets in motion a continuing sequence of "write" operations on the variables in the Pane. Only variables in isChanged states are written; other states don't need to be.
      Returns:
      true if a write has been started, false if the pane is complete
    • writePaneAll

      public boolean writePaneAll()
      Invoked by "Write full sheet" button to write all CVs.
      Returns:
      true if a write has been started, false if the pane is complete
    • prepWritePane

      public void prepWritePane(boolean onlyChanges)
      Prepare a "write full sheet" operation.
      Parameters:
      onlyChanges - true if only writing changes; false if writing all
    • nextWrite

      boolean nextWrite()
    • prepConfirmPane

      public void prepConfirmPane(boolean onlyChanges)
      Prepare this pane for a compare operation.

      The read mechanism only reads variables in certain states (and needs to do that to handle error processing right now), so this is implemented by first setting all variables and CVs on this pane to TOREAD via this method

      Parameters:
      onlyChanges - true if only confirming changes; false if confirming all
    • confirmPaneChanges

      public boolean confirmPaneChanges()
      Invoked by "Compare changes on sheet" button, this sets in motion a continuing sequence of "confirm" operations on the variables and CVs in the Pane. Only variables in states marked as "changed" will be checked.
      Returns:
      true is a confirm has been started, false if the pane is complete.
    • confirmPaneAll

      public boolean confirmPaneAll()
      Invoked by "Compare Full Sheet" button, this sets in motion a continuing sequence of "confirm" operations on the variables and CVs in the Pane. The read mechanism only reads variables in certain states (and needs to do that to handle error processing right now), so this is implemented by first setting all variables and CVs on this pane to TOREAD in prepReadPaneAll, then starting the execution.
      Returns:
      true is a confirm has been started, false if the pane is complete.
    • isBusy

      public boolean isBusy()
    • setBusy

      protected void setBusy(boolean busy)
    • propertyChange

      Get notification of a variable property change, specifically "busy" going to false at the end of a programming operation. If we're in a programming operation, we then continue it by reinvoking the nextRead/writePane operation.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      e - the event to respond to
    • replyWhileProgrammingVar

      public void replyWhileProgrammingVar()
    • replyWhileProgrammingCV

      public void replyWhileProgrammingCV()
    • restartProgramming

    • stopProgramming

      protected void stopProgramming()
    • newGroup

      protected JPanel newGroup(org.jdom2.Element element, boolean showStdName, org.jdom2.Element modelElem)
      Create a new group from the JDOM group Element
      Parameters:
      element - element containing group contents
      showStdName - show the name following the rules for the nameFmt element
      modelElem - element containing the decoder model
      Returns:
      a panel containing the group
    • newGridGroup

      protected void newGridGroup(org.jdom2.Element element, JPanel c, GridBagLayout g, PaneProgPane.GridGlobals globs, boolean showStdName, org.jdom2.Element modelElem)
      Create a new grid group from the JDOM group Element.
      Parameters:
      element - element containing group contents
      c - the panel to create the grid in
      g - the layout manager for the panel
      globs - properties to configure g
      showStdName - show the name following the rules for the nameFmt element
      modelElem - element containing the decoder model
    • newColumn

      public JPanel newColumn(org.jdom2.Element element, boolean showStdName, org.jdom2.Element modelElem)
      Create a single column from the JDOM column Element.
      Parameters:
      element - element containing column contents
      showStdName - show the name following the rules for the nameFmt element
      modelElem - element containing the decoder model
      Returns:
      a panel containing the group
    • newRow

      public JPanel newRow(org.jdom2.Element element, boolean showStdName, org.jdom2.Element modelElem)
      Create a single row from the JDOM column Element
      Parameters:
      element - element containing row contents
      showStdName - show the name following the rules for the nameFmt element
      modelElem - element containing the decoder model
      Returns:
      a panel containing the group
    • newGrid

      public JPanel newGrid(org.jdom2.Element element, boolean showStdName, org.jdom2.Element modelElem)
      Create a grid from the JDOM Element.
      Parameters:
      element - element containing group contents
      showStdName - show the name following the rules for the nameFmt element
      modelElem - element containing the decoder model
      Returns:
      a panel containing the group
    • newGridItem

      public JPanel newGridItem(org.jdom2.Element element, boolean showStdName, org.jdom2.Element modelElem, PaneProgPane.GridGlobals globs)
      Create a grid item from the JDOM Element
      Parameters:
      element - element containing grid item contents
      showStdName - show the name following the rules for the nameFmt element
      modelElem - element containing the decoder model
      globs - properties to configure the layout
      Returns:
      a panel containing the group
    • makeLabel

      protected void makeLabel(org.jdom2.Element e, JPanel c, GridBagLayout g, GridBagConstraints cs)
      Create label from Element.
      Parameters:
      e - element containing label contents
      c - panel to insert label into
      g - panel layout manager
      cs - constraints on layout manager
    • makeSoundLabel

      protected void makeSoundLabel(org.jdom2.Element e, JPanel c, GridBagLayout g, GridBagConstraints cs)
      Create sound label from Element.
      Parameters:
      e - element containing label contents
      c - panel to insert label into
      g - panel layout manager
      cs - constraints on layout manager
    • makeCvTable

    • setCvListFromTable

    • pickFnMapPanel

      void pickFnMapPanel(JPanel c, GridBagLayout g, GridBagConstraints cs, org.jdom2.Element modelElem)
      Pick an appropriate function map panel depending on model attribute.
      If attribute extFnsESU="yes":
      Invoke FnMapPanelESU(VariableTableModel v, List<Integer> varsUsed, Element model)
      Otherwise:
      Invoke FnMapPanel(VariableTableModel v, List<Integer> varsUsed, Element model)
      Parameters:
      modelElem - element containing model attributes
      c - panel to add function map panel to
      g - panel layout manager
      cs - constraints on layout manager
    • newVariable

      public void newVariable(org.jdom2.Element var, JComponent col, GridBagLayout g, GridBagConstraints cs, boolean showStdName)
      Add the representation of a single variable. The variable is defined by a JDOM variable Element from the XML file.
      Parameters:
      var - element containing variable
      col - column to insert label into
      g - panel layout manager
      cs - constraints on layout manager
      showStdName - show the name following the rules for the nameFmt element
    • getRepresentation

      public JComponent getRepresentation(String name, org.jdom2.Element var)
      Get a GUI representation of a particular variable for display.
      Parameters:
      name - Name used to look up the Variable object
      var - XML Element which might contain a "format" attribute to be used in the VariableValue.getNewRep(java.lang.String) call from the Variable object; "tooltip" elements are also processed here.
      Returns:
      JComponent representing this variable
    • modifyToolTipText

      Takes default tool tip text, e.g. from the decoder element, and modifies it as needed.

      Intended to handle e.g. adding CV numbers to variables.

      Parameters:
      start - existing tool tip text
      variable - the CV
      Returns:
      new tool tip text
    • getRep

      JComponent getRep(int i, String format)
    • dispose

      public void dispose()
    • isEmpty

      public boolean isEmpty()
      Check if varList and cvList, and thus the tab, is empty.
      Returns:
      true if empty
    • includeInPrint

      public boolean includeInPrint()
    • includeInPrint

      public void includeInPrint(boolean inc)
    • printPane

      public void printPane(HardcopyWriter w)