PIRL

PIRL.Conductor
Class Procedures_Table_Model

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by javax.swing.table.DefaultTableModel
          extended by PIRL.Conductor.Procedures_Table_Model
All Implemented Interfaces:
Serializable, TableModel

public class Procedures_Table_Model
extends DefaultTableModel

A Procedures_Table_Model contains a table of Conductor procedure definition records.

Version:
1.5
Author:
Bradford Castalia, UA/PIRL
See Also:
Serialized Form

Field Summary
 int Current_Row
          The row designated as the currently active procedure definitiion of the table.
 boolean Editable
          Flag that determines if the table cells are editable.
static String ID
          Class identification name with source code version and date.
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
Procedures_Table_Model()
          Construct an empty Procedures_Table_Model.
Procedures_Table_Model(String[] field_names)
          Construct a Procedures_Table_Model from a Vector of field names but no table data.
Procedures_Table_Model(String[][] records, String[] field_names)
          Construct a Procedures_Table_Model from an array of data record arrays and an array of field names.
Procedures_Table_Model(Vector field_names)
          Construct a Procedures_Table_Model from a Vector of field names but no table data.
Procedures_Table_Model(Vector records, Vector field_names)
          Construct a Procedures_Table_Model from a Vector of data record Vectors and a Vector of field names.
 
Method Summary
 Vector Column_Names()
          The table field names.
 Class getColumnClass(int column)
          Get the Class for a table column.
 Object getValueAt(int row, int column)
          Get a table cell value.
 void insertRow(int row, Vector record)
          Insert a procedure definition record in the table.
 boolean isCellEditable(int row, int column)
          Test if a table cell is editable.
 Vector Record(int row)
          Get the procedure definition record at a table row index.
 Procedures_Table_Model Record(int row, Vector record)
          Set the procedure definition record at a table row index.
static Vector Record(Vector record)
          Copy record data.
 void Restore()
          Restore the table content from the last snapshot.
 void setDataVector(Vector records, Vector field_names)
          Replace the table data content.
 Vector Snapshot_Column_Names()
          The last table field names snapshot.
 Vector Snapshot_Table_Data()
          The last table data records snapshot.
 void Snapshot()
          Save a snapshot of the table contents.
static Vector Table(Vector records)
          Copy table data.
 
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getColumnName, getDataVector, getRowCount, insertRow, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setNumRows, setRowCount, setValueAt
 
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
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values

Editable

public boolean Editable
Flag that determines if the table cells are editable.


Current_Row

public int Current_Row
The row designated as the currently active procedure definitiion of the table.

Constructor Detail

Procedures_Table_Model

public Procedures_Table_Model()
Construct an empty Procedures_Table_Model.


Procedures_Table_Model

public Procedures_Table_Model(Vector records,
                              Vector field_names)
Construct a Procedures_Table_Model from a Vector of data record Vectors and a Vector of field names.

Parameters:
records - A Vector of records; each record is a Vector of field value Strings any of which may be null.
field_names - A Vector of field_name Strings.
See Also:
setDataVector(Vector, Vector)

Procedures_Table_Model

public Procedures_Table_Model(String[][] records,
                              String[] field_names)
Construct a Procedures_Table_Model from an array of data record arrays and an array of field names.

Parameters:
records - An array of records; each record is an array of field value Strings any of which may be null.
field_names - An array of field_name Strings.
See Also:
setDataVector(Vector, Vector)

Procedures_Table_Model

public Procedures_Table_Model(Vector field_names)
Construct a Procedures_Table_Model from a Vector of field names but no table data.

A snapshot of the model is taken.

Parameters:
field_names - A Vector of field_name Strings.

Procedures_Table_Model

public Procedures_Table_Model(String[] field_names)
Construct a Procedures_Table_Model from a Vector of field names but no table data.

A snapshot of the model is taken.

Parameters:
field_names - An array of field_name Strings.
Method Detail

getColumnClass

public Class getColumnClass(int column)
Get the Class for a table column.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
column - A table column index.
Returns:
String.class; except if the column is not a valid value Object.class is returned.

getValueAt

public Object getValueAt(int row,
                         int column)
Get a table cell value.

Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class DefaultTableModel
Parameters:
row - A table row index.
column - A table column index.
Returns:
The Object at the row and column cell location of the table data. This will be null if either the row or column value is invalid.

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Test if a table cell is editable.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class DefaultTableModel
Parameters:
row - A table row index.
column - A table column index.
Returns:
The value of the Editable flag.

setDataVector

public void setDataVector(Vector records,
                          Vector field_names)
Replace the table data content.

Both the field names and procedure records are replaced.

A snapshot of the model is taken.

Overrides:
setDataVector in class DefaultTableModel
Parameters:
records - A Vector of records; each record is a Vector of field value Strings any of which may be null.
field_names - A Vector of field_name Strings.

insertRow

public void insertRow(int row,
                      Vector record)
Insert a procedure definition record in the table.

The table snapshot data is updated with the new record.

Overrides:
insertRow in class DefaultTableModel
Parameters:
row - A table row index. This must be in the range zero to the total number of records in the table, inclusive. If the row equals the total number of records in the table the record is appended to the table.
record - A procedure definition record Vector. It's size must be the same as the table's column count.

Record

public Vector Record(int row)
Get the procedure definition record at a table row index.

Parameters:
row - A table row index. This must be in the range zero to the total number of records in the table, exclusive.
Returns:
A procedure definition record Vector.

Record

public Procedures_Table_Model Record(int row,
                                     Vector record)
Set the procedure definition record at a table row index.

If a new row is added to the table the table snapshot data is updated with the new record.

Notification of the row record being updated or added will be generated.

Parameters:
row - A table row index. This must be in the range zero to the total number of records in the table, inclusive. If the row equals the total number of records in the table the record is appended to the table. Otherwise the record replaces the existing record at the row index.
record - A procedure definition record Vector. It's size must be the same as the table's column count.
Returns:
This Procedures_Table_Model.
Throws:
ArrayIndexOutOfBoundsException - If the row index is invalid or the record size is not the same as the number of columns in the table.

Restore

public void Restore()
Restore the table content from the last snapshot.

The table records are restored from a copy of the last snapshot table data. If the number of table columns has changed since the last snapshot the field names are also restored from a copy of the last snapshot column names. N.B.: No check is made if the field names have changed; full table content can be forced by:

    setDataVector
      (Table (Snapshot_Table_Data ()),
      Record (Snapshot_Column_Names ()));

Notification of the change to the table contents will be generated.

See Also:
Snapshot()

Snapshot

public void Snapshot()
Save a snapshot of the table contents.

Both the table data records and field names are saved.

See Also:
Snapshot_Table_Data(), Snapshot_Column_Names()

Snapshot_Table_Data

public Vector Snapshot_Table_Data()
The last table data records snapshot.

Returns:
A Vector containing a copy of each record Vector in the table at the time of the last snapshot was taken. N.B.: The returned Vector is the snapshot data, not a copy.

Snapshot_Column_Names

public Vector Snapshot_Column_Names()
The last table field names snapshot.

Returns:
A Vector containing a copy of the field names for the table at the time of the last snapshot was taken. N.B.: The returned Vector is the snapshot data, not a copy.

Column_Names

public Vector Column_Names()
The table field names.

Returns:
A Vector containing the field names for the table. N.B.: The returned Vector is not a copy.

Table

public static Vector Table(Vector records)
Copy table data.

The table is a Vector of row record Vectors. The table is expected to be square: the size of the first row record determines the size of all other rows; no attempt is made to compensenate for an irregular table.

The data elements are not copied; the reference to each element Object is copied. For the expected case where the data elements are Strings, which are immutable, there is no concern that changes in the copied data will affect the copy, or vice versa.

Parameters:
records - A Vector of records; each record is a Vector of field value Strings any of which may be null.
Returns:
A Vector containing a copy of each record Vector in the table. This will be null if the table is null.

Record

public static Vector Record(Vector record)
Copy record data.

Parameters:
record - A Vector of field value Strings any of which may be null.
Returns:
A Vector containing a copy of the record. Must not be null.

PIRL

Copyright (C) \ 2003-2009 Bradford Castalia, University of Arizona