jmri.jmrit.symbolicprog.tabbedframe
Class PaneProgPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jmri.jmrit.symbolicprog.tabbedframe.PaneProgPane
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible

public class PaneProgPane
extends JPanel
implements PropertyChangeListener

Provides 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.
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.

Author:
Bob Jacobsen Copyright (C) 2001, 2003, 2004, 2005, 2006, D Miller Copyright 2003, Howard G. Penny Copyright (C) 2005
See Also:
VariableValue.isChanged(), Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PaneProgPane()
          Create a null object.
PaneProgPane(PaneContainer parent, String name, Element pane, CvTableModel cvModel, IndexedCvTableModel icvModel, VariableTableModel varModel, Element modelElem)
          Construct the Pane from the XML definition element.
 
Method Summary
 boolean confirmPaneAll()
          Invoked by "Compare Full Sheet" button, this sets in motion a continuing sequence of "confirm" operations on the variables & CVs in the Pane.
 boolean confirmPaneChanges()
          Invoked by "Compare changes on sheet" button, this sets in motion a continuing sequence of "confirm" operations on the variables & CVs in the Pane.
 int countOpsNeeded(boolean read, boolean changes)
          Estimate the number of CVs that will be accessed when reading or writing the contents of this pane.
 void dispose()
           
 String getName()
           
 JComponent getRepresentation(String name, Element var)
          Get a GUI representation of a particular variable for display.
 boolean includeInPrint()
           
 void includeInPrint(boolean inc)
           
 boolean isBusy()
           
 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.
 JPanel newColumn(Element element, boolean showStdName, Element modelElem)
          Create a single column from the JDOM column Element
 JPanel newRow(Element element, boolean showStdName, Element modelElem)
          Create a single row from the JDOM column Element
 void newVariable(Element var, JComponent col, GridBagLayout g, GridBagConstraints cs, boolean showStdName)
          Add the representation of a single variable.
 void prepConfirmPane(boolean onlyChanges)
          Prepare this pane for a compare operation.
 void prepReadPane(boolean onlyChanges)
          Prepare this pane for a read operation.
 void prepWritePane(boolean onlyChanges)
          Prepare a "write full sheet" operation.
 void printPane(HardcopyWriter w)
           
 void propertyChange(PropertyChangeEvent e)
          Get notification of a variable property change, specifically "busy" going to false at the end of a programming operation.
 boolean readPaneAll()
          Invoked by "Read Full Sheet" button, this sets in motion a continuing sequence of "read" operations on the variables & CVs in the Pane.
 boolean readPaneChanges()
          Invoked by "Read changes on sheet" button, this sets in motion a continuing sequence of "read" operations on the variables & CVs in the Pane.
 void replyWhileProgrammingCV()
           
 void replyWhileProgrammingIndxCV()
           
 void replyWhileProgrammingVar()
           
protected  void setBusy(boolean busy)
           
 String toString()
           
 boolean writePaneAll()
          Invoked by "Write full sheet" button to write all CVs.
 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.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PaneProgPane

public PaneProgPane()
Create a null object. Normally only used for tests and to pre-load classes.


PaneProgPane

public PaneProgPane(PaneContainer parent,
                    String name,
                    Element pane,
                    CvTableModel cvModel,
                    IndexedCvTableModel icvModel,
                    VariableTableModel varModel,
                    Element modelElem)
Construct the Pane from the XML definition element.

Parameters:
name - Name to appear on tab of pane
pane - The JDOM Element for the pane definition
cvModel - Already existing TableModel containing the CV definitions
icvModel - Already existing TableModel containing the Indexed 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.
Method Detail

getName

public String getName()
Overrides:
getName in class Component

toString

public String toString()
Overrides:
toString in class Component

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.

readPaneChanges

public boolean readPaneChanges()
Invoked by "Read changes on sheet" button, this sets in motion a continuing sequence of "read" operations on the variables & 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


readPaneAll

public boolean readPaneAll()
Invoked by "Read Full Sheet" button, this sets in motion a continuing sequence of "read" operations on the variables & 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.

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.


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


confirmPaneChanges

public boolean confirmPaneChanges()
Invoked by "Compare changes on sheet" button, this sets in motion a continuing sequence of "confirm" operations on the variables & 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 & 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

public void propertyChange(PropertyChangeEvent e)
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

replyWhileProgrammingVar

public void replyWhileProgrammingVar()

replyWhileProgrammingCV

public void replyWhileProgrammingCV()

replyWhileProgrammingIndxCV

public void replyWhileProgrammingIndxCV()

newColumn

public JPanel newColumn(Element element,
                        boolean showStdName,
                        Element modelElem)
Create a single column from the JDOM column Element


newRow

public JPanel newRow(Element element,
                     boolean showStdName,
                     Element modelElem)
Create a single row from the JDOM column Element


newVariable

public void newVariable(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.


getRepresentation

public JComponent getRepresentation(String name,
                                    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

dispose

public void dispose()

includeInPrint

public boolean includeInPrint()

includeInPrint

public void includeInPrint(boolean inc)

printPane

public void printPane(HardcopyWriter w)


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads