com.ibm.as400.ui.framework.java
Class PanelTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.ibm.as400.ui.framework.java.PanelTableModel
All Implemented Interfaces:
Serializable, TableModel
Direct Known Subclasses:
PanelTreeTableModel

public class PanelTableModel
extends AbstractTableModel

An implementation of TableModel that uses a two-dimensional array of objects to store the cell values. The row count will be the length of the largest array that is supplied on a call to setColumn.

Since:
v4r2m0
Version:
1.0, 04/15/98
Author:
D. Petty
See Also:
TableModel, Serialized Form

Field Summary
Modifier and Type Field and Description
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
Constructor and Description
PanelTableModel(Vector tableColumns)
          Constructs a PanelTableModel.
 
Method Summary
Modifier and Type Method and Description
 void addRow(Vector rowData)
          Adds a row to the end of the model.
 Object[] getColumn(int column)
          Returns the list of values for the column at column.
 Object[] getColumn(String name)
          Returns the list of values for the column whose identifer is name.
 Class getColumnClass(int column)
          Returns the lowest common denominator Class in the column.
 int getColumnCount()
          Returns the number of columns managed by this object.
 String getColumnIdentifier(int column)
          Returns the identifier of the column at column.
 String getColumnName(int column)
          Returns the name of the column at column.
 int getRowCount()
          Returns the number of records managed by this object.
 Vector[] getRows()
          Returns a Vector array.
 Object getValueAt(int row, int column)
          Returns an attribute value for the cell at row and column.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 void removeRow(int rowToRemove)
          Removes the row at rowToRemove from the model.
 void removeRows(int[] rowsToRemove)
          Removes the rows identified in rowsToRemove from the model.
 void setCellEditable(boolean editable, int row, int column)
          Indicates whether the cell at row and column is editable.
 void setColumn(int column, Object[] items)
          Sets the list of values for the column at column.
 void setRows(Vector[] rowData)
          Reassigns all values in the table.
 void setValueAt(Object value, int row, int column)
          Sets an attribute value for the record in the cell at row and column.
 String toString()
          Returns a string representation of the model.
 
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, wait, wait, wait
 

Constructor Detail

PanelTableModel

public PanelTableModel(Vector tableColumns)
Constructs a PanelTableModel.

Parameters:
tableColumns - a list of ColumnDescriptors for the table columns
Since:
v4r2m0
Method Detail

getColumn

public Object[] getColumn(int column)
Returns the list of values for the column at column.

Parameters:
column - the column whose values are to be looked up
Returns:
the list of values at the specified column
Since:
v4r2m0
See Also:
setColumn(int, java.lang.Object[])

getColumn

public Object[] getColumn(String name)
Returns the list of values for the column whose identifer is name.

Parameters:
name - the column whose values are to be looked up
Returns:
the list of values at the specified column or null if not found
Since:
v5r1m0
See Also:
setColumn(int, java.lang.Object[])

setColumn

public void setColumn(int column,
                      Object[] items)
Sets the list of values for the column at column.

Parameters:
column - the column whose values are to be set
the - list of values at the specified column
Since:
v4r2m0
See Also:
getColumn(int)

toString

public String toString()
Returns a string representation of the model.

Overrides:
toString in class Object
Returns:
the dimensions of the table as a string
Since:
v4r2m0

getColumnCount

public int getColumnCount()
Returns the number of columns managed by this object.

Returns:
the number or columns in the model
Since:
v4r2m0
See Also:
getRowCount()

getRowCount

public int getRowCount()
Returns the number of records managed by this object.

Returns:
the number or rows in the model
Since:
v4r2m0
See Also:
getColumnCount()

getValueAt

public Object getValueAt(int row,
                         int column)
Returns an attribute value for the cell at row and column.

Parameters:
row - the row whose value is to be looked up
column - the column whose value is to be looked up
Returns:
the value Object at the specified cell
Since:
v4r2m0
See Also:
setValueAt(java.lang.Object, int, int)

getColumnName

public String getColumnName(int column)
Returns the name of the column at column.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
column - the index of column
Returns:
the name of the column
Since:
v4r2m0

getColumnIdentifier

public String getColumnIdentifier(int column)
Returns the identifier of the column at column.

Parameters:
column - the index of column
Returns:
the identifier of the column
Since:
v5r1m0

getColumnClass

public Class getColumnClass(int column)
Returns the lowest common denominator Class in the column.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Returns:
the common ancestor class of the object values in the model
Since:
v4r2m0

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at row and column is editable. Otherwise, setValueAt() on the cell will not change the value of that cell.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
row - the row whose editable status is to be looked up
column - the column whose editable status is to be looked up
Returns:
true if the cell is editable; false otherwise
Since:
v4r2m0
See Also:
setCellEditable(boolean, int, int)

setCellEditable

public void setCellEditable(boolean editable,
                            int row,
                            int column)
Indicates whether the cell at row and column is editable. Otherwise, setValueAt() on the cell will not change the value of that cell.

Parameters:
editable - true if the cell should be editable, false otherwise
row - the row whose value is to be looked up
column - the column whose value is to be looked up
Since:
v4r2m0
See Also:
isCellEditable(int, int)

setValueAt

public void setValueAt(Object value,
                       int row,
                       int column)
Sets an attribute value for the record in the cell at row and column. value is the new value.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
Parameters:
value - the new value
row - the row whose value is to be changed
column - the column whose value is to be changed
Since:
v4r2m0
See Also:
getValueAt(int, int)

addRow

public void addRow(Vector rowData)
Adds a row to the end of the model. The new row will contain null values unless rowData is specified. Notification of the row being added will be generated.

Parameters:
rowData - data of the row being added (may be null)
Since:
v4r2m0
See Also:
removeRow(int)

setRows

public void setRows(Vector[] rowData)
Reassigns all values in the table. The new table will contain null values unless rowData is specified. Notification of the rows being added will be generated.

Parameters:
rowData - array of data for the rows being added (may be null)
Since:
v4r2m0
See Also:
getRows()

getRows

public Vector[] getRows()
Returns a Vector array. Each vector contains the attribute values for each cell in a table row.

Since:
v4r2m0
See Also:
setRows(java.util.Vector[])

removeRow

public void removeRow(int rowToRemove)
Removes the row at rowToRemove from the model. Notification of the row being removed will be sent to all listeners.

Parameters:
rowToRemove - the row index of the row to be removed
Throws:
ArrayIndexOutOfBoundsException - if the row was invalid
Since:
v4r2m0

removeRows

public void removeRows(int[] rowsToRemove)
Removes the rows identified in rowsToRemove from the model. Notification of the rows being removed will be sent to all listeners.

Parameters:
rowsToRemove - a list of row indices for the rows to be removed
Since:
v4r2m0