jmri.jmrit.symbolicprog
Class VariableTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by jmri.jmrit.symbolicprog.VariableTableModel
All Implemented Interfaces:
ActionListener, PropertyChangeListener, Serializable, EventListener, TableModel

public class VariableTableModel
extends AbstractTableModel
implements ActionListener, PropertyChangeListener

Table data model for display of variables in symbolic programmer. Also responsible for loading from the XML file...

Author:
Bob Jacobsen Copyright (C) 2001, 2006, 2010, Howard G. Penny Copyright (C) 2005, Daniel Boudreau Copyright (C) 2007
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
VariableTableModel(JLabel status, String[] h, CvTableModel cvModel, IndexedCvTableModel iCvModel)
          Defines the columns; values understood are: "Name", "Value", "Range", "Read", "Write", "Comment", "CV", "Mask", "State"
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void configDone()
           
protected  VariableValue createIndexedVariableFromElement(Element e, int row, String name, String comment, String cvName, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int cv, String mask, String item, String productID)
          Create an IndexedVariableValue object of a specific type from a describing element.
 boolean decoderDirty()
          Check for change to values, etc, hence rewriting the decoder is desirable.
 void dispose()
           
 boolean fileDirty()
          Represents any change to values, etc, hence rewriting the file is desirable.
 VariableValue findVar(String name)
           
 int findVarIndex(String name)
           
 Class<?> getColumnClass(int col)
           
 int getColumnCount()
           
 String getColumnName(int col)
           
 String getCvName(int row)
           
 String getItem(int row)
           
 String getLabel(int row)
           
 Object getRep(int row, String format)
           
 int getRowCount()
           
 int getState(int row)
           
 String getValString(int row)
           
 Object getValueAt(int row, int col)
           
 VariableValue getVariable(int row)
           
 boolean isCellEditable(int row, int col)
           
 void newDecVariableValue(String name, int CV, String mask, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly)
           
 int piCv()
           
protected  VariableValue processCompositeVal(Element child, String name, String comment, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int CV, String mask, String item)
           
protected  VariableValue processDecVal(Element child, String name, String comment, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int CV, String mask, String item)
           
protected  VariableValue processEnumVal(Element child, String name, String comment, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int CV, String mask, String item)
           
protected  VariableValue processHexVal(Element child, String name, String comment, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int CV, String mask, String item)
           
protected  VariableValue processIEnumVal(Element child, int row, String name, String comment, String cvName, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int cv, String mask, String item, String productID)
           
protected  VariableValue processIndexedPairVal(Element child, int row, boolean readOnly, boolean infoOnly, boolean writeOnly, String name, String comment, String cvName, boolean opsOnly, int cv, String mask, String item)
           
protected  VariableValue processIndexedVal(Element child, int row, String name, String comment, String cvName, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int cv, String mask, String item)
           
protected  VariableValue processLongAddressVal(int CV, boolean readOnly, boolean infoOnly, boolean writeOnly, String name, String comment, boolean opsOnly, String mask, String item)
           
protected  void processModifierElements(Element e, VariableValue v)
          If there are any modifier elements, process them by e.g. setting attributes on the VariableValue
protected  VariableValue processShortAddressVal(String name, String comment, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int CV, String mask, String item, Element child)
           
protected  VariableValue processSpeedTableVal(Element child, int CV, boolean readOnly, boolean infoOnly, boolean writeOnly, String name, String comment, boolean opsOnly, String mask, String item)
           
protected  VariableValue processSplitVal(Element child, int CV, boolean readOnly, boolean infoOnly, boolean writeOnly, String name, String comment, boolean opsOnly, String mask, String item)
           
 void propertyChange(PropertyChangeEvent e)
           
 void read(int i)
          Command reading of a particular variable
protected  void setButtonsReadWrite(boolean readOnly, boolean infoOnly, boolean writeOnly, JButton bw, JButton br, int row)
           
 void setConstant(Element e)
          Configure from a constant.
protected  boolean setDefaultValue(Element e, VariableValue v)
          If there's a "default" attribute, set that value to start
 void setFileDirty(boolean b)
           
 int setIndxRow(int row, Element e, String productID)
          Load one row in the IndexedVariableTableModel, by reading in the Element containing its definition.
 void setIntValue(int row, int val)
           
 void setRow(int row, Element e)
          Load one row in the VariableTableModel, by reading in the Element containing its definition.
 void setState(int row, int val)
           
protected  void setToolTip(Element e, VariableValue v)
           
 void setValueAt(Object value, int row, int col)
           
 int siCv()
           
 void write(int i)
          Command writing of a particular variable
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableTableModel

public VariableTableModel(JLabel status,
                          String[] h,
                          CvTableModel cvModel,
                          IndexedCvTableModel iCvModel)
Defines the columns; values understood are: "Name", "Value", "Range", "Read", "Write", "Comment", "CV", "Mask", "State"

Method Detail

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnName

public String getColumnName(int col)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getColumnClass

public Class<?> getColumnClass(int col)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

getVariable

public VariableValue getVariable(int row)

getLabel

public String getLabel(int row)

getItem

public String getItem(int row)

getCvName

public String getCvName(int row)

getValString

public String getValString(int row)

setIntValue

public void setIntValue(int row,
                        int val)

setState

public void setState(int row,
                     int val)

getState

public int getState(int row)

getRep

public Object getRep(int row,
                     String format)

getValueAt

public Object getValueAt(int row,
                         int col)
Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object value,
                       int row,
                       int col)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

setRow

public void setRow(int row,
                   Element e)
Load one row in the VariableTableModel, by reading in the Element containing its definition.

Invoked from DecoderFile

Parameters:
row - number of row to fill
e - Element of type "variable"

processModifierElements

protected void processModifierElements(Element e,
                                       VariableValue v)
If there are any modifier elements, process them by e.g. setting attributes on the VariableValue


createIndexedVariableFromElement

protected VariableValue createIndexedVariableFromElement(Element e,
                                                         int row,
                                                         String name,
                                                         String comment,
                                                         String cvName,
                                                         boolean readOnly,
                                                         boolean infoOnly,
                                                         boolean writeOnly,
                                                         boolean opsOnly,
                                                         int cv,
                                                         String mask,
                                                         String item,
                                                         String productID)
                                                  throws NumberFormatException
Create an IndexedVariableValue object of a specific type from a describing element.

Returns:
null if no valid element
Throws:
NumberFormatException

setDefaultValue

protected boolean setDefaultValue(Element e,
                                  VariableValue v)
If there's a "default" attribute, set that value to start

Returns:
true if the value was set

piCv

public int piCv()

siCv

public int siCv()

setIndxRow

public int setIndxRow(int row,
                      Element e,
                      String productID)
Load one row in the IndexedVariableTableModel, by reading in the Element containing its definition.

Invoked from DecoderFile

Parameters:
row - number of row to fill
e - Element of type "variable"

processCompositeVal

protected VariableValue processCompositeVal(Element child,
                                            String name,
                                            String comment,
                                            boolean readOnly,
                                            boolean infoOnly,
                                            boolean writeOnly,
                                            boolean opsOnly,
                                            int CV,
                                            String mask,
                                            String item)

processDecVal

protected VariableValue processDecVal(Element child,
                                      String name,
                                      String comment,
                                      boolean readOnly,
                                      boolean infoOnly,
                                      boolean writeOnly,
                                      boolean opsOnly,
                                      int CV,
                                      String mask,
                                      String item)
                               throws NumberFormatException
Throws:
NumberFormatException

processEnumVal

protected VariableValue processEnumVal(Element child,
                                       String name,
                                       String comment,
                                       boolean readOnly,
                                       boolean infoOnly,
                                       boolean writeOnly,
                                       boolean opsOnly,
                                       int CV,
                                       String mask,
                                       String item)
                                throws NumberFormatException
Throws:
NumberFormatException

processHexVal

protected VariableValue processHexVal(Element child,
                                      String name,
                                      String comment,
                                      boolean readOnly,
                                      boolean infoOnly,
                                      boolean writeOnly,
                                      boolean opsOnly,
                                      int CV,
                                      String mask,
                                      String item)
                               throws NumberFormatException
Throws:
NumberFormatException

processIEnumVal

protected VariableValue processIEnumVal(Element child,
                                        int row,
                                        String name,
                                        String comment,
                                        String cvName,
                                        boolean readOnly,
                                        boolean infoOnly,
                                        boolean writeOnly,
                                        boolean opsOnly,
                                        int cv,
                                        String mask,
                                        String item,
                                        String productID)
                                 throws NumberFormatException
Throws:
NumberFormatException

processIndexedPairVal

protected VariableValue processIndexedPairVal(Element child,
                                              int row,
                                              boolean readOnly,
                                              boolean infoOnly,
                                              boolean writeOnly,
                                              String name,
                                              String comment,
                                              String cvName,
                                              boolean opsOnly,
                                              int cv,
                                              String mask,
                                              String item)
                                       throws NumberFormatException
Throws:
NumberFormatException

processIndexedVal

protected VariableValue processIndexedVal(Element child,
                                          int row,
                                          String name,
                                          String comment,
                                          String cvName,
                                          boolean readOnly,
                                          boolean infoOnly,
                                          boolean writeOnly,
                                          boolean opsOnly,
                                          int cv,
                                          String mask,
                                          String item)
                                   throws NumberFormatException
Throws:
NumberFormatException

processLongAddressVal

protected VariableValue processLongAddressVal(int CV,
                                              boolean readOnly,
                                              boolean infoOnly,
                                              boolean writeOnly,
                                              String name,
                                              String comment,
                                              boolean opsOnly,
                                              String mask,
                                              String item)

processShortAddressVal

protected VariableValue processShortAddressVal(String name,
                                               String comment,
                                               boolean readOnly,
                                               boolean infoOnly,
                                               boolean writeOnly,
                                               boolean opsOnly,
                                               int CV,
                                               String mask,
                                               String item,
                                               Element child)

processSpeedTableVal

protected VariableValue processSpeedTableVal(Element child,
                                             int CV,
                                             boolean readOnly,
                                             boolean infoOnly,
                                             boolean writeOnly,
                                             String name,
                                             String comment,
                                             boolean opsOnly,
                                             String mask,
                                             String item)
                                      throws NumberFormatException
Throws:
NumberFormatException

processSplitVal

protected VariableValue processSplitVal(Element child,
                                        int CV,
                                        boolean readOnly,
                                        boolean infoOnly,
                                        boolean writeOnly,
                                        String name,
                                        String comment,
                                        boolean opsOnly,
                                        String mask,
                                        String item)
                                 throws NumberFormatException
Throws:
NumberFormatException

setButtonsReadWrite

protected void setButtonsReadWrite(boolean readOnly,
                                   boolean infoOnly,
                                   boolean writeOnly,
                                   JButton bw,
                                   JButton br,
                                   int row)

setToolTip

protected void setToolTip(Element e,
                          VariableValue v)

setConstant

public void setConstant(Element e)
Configure from a constant. This is like setRow (which processes a variable Element).


newDecVariableValue

public void newDecVariableValue(String name,
                                int CV,
                                String mask,
                                boolean readOnly,
                                boolean infoOnly,
                                boolean writeOnly,
                                boolean opsOnly)

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

read

public void read(int i)
Command reading of a particular variable

Parameters:
i - row number

write

public void write(int i)
Command writing of a particular variable

Parameters:
i - row number

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener

configDone

public void configDone()

fileDirty

public boolean fileDirty()
Represents any change to values, etc, hence rewriting the file is desirable.


setFileDirty

public void setFileDirty(boolean b)

decoderDirty

public boolean decoderDirty()
Check for change to values, etc, hence rewriting the decoder is desirable.


findVar

public VariableValue findVar(String name)

findVarIndex

public int findVarIndex(String name)

dispose

public void dispose()


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