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

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.ibm.as400.ui.framework.java.PanelTableModel
          extended by com.ibm.as400.ui.framework.java.PanelTreeTableModel
All Implemented Interfaces:
Serializable, EventListener, TreeExpansionListener, TreeModelListener, TreeWillExpandListener, TableModel

public class PanelTreeTableModel
extends PanelTableModel
implements TreeExpansionListener, TreeModelListener, TreeWillExpandListener

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:
v5r1m0
Version:
1.0, 01/10/00
Author:
L. Schneckloth
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
PanelTreeTableModel(Vector tableColumns)
          Constructs a PanelTreeTableModel.
 
Method Summary
Modifier and Type Method and Description
 void addRow(Vector rowData)
          Adds a row to the end of the model.
 void addRow(Vector rowData, DefaultMutableTreeNode parent)
          Adds a row to the end of the model.
 Vector[] getRows()
          Returns a Vector array.
 Object getValueAt(int row, int column)
          Returns an attribute value for the cell at row and column.
 void insertNodeRow(Vector rowData, DefaultMutableTreeNode nodeParent, int nodeIndex)
          Inserts a node into the renderer tree and then calls insertRow to add the corresponding row to the table model.
 void insertRow(int rowIndex, Vector rowData)
          Inserts a row at rowIndex the model.
 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 setColumn(int column, Object[] items, com.ibm.as400.ui.framework.java.ComponentAttributeAssociation caa)
          Sets the list of values for the column at column.
 void setComponentAttributeAssociation(com.ibm.as400.ui.framework.java.ComponentAttributeAssociation caa)
          Sets the ComponentAttributeAssociation associated with this model.
 void setRendererTree(JTree tree)
          Sets the JTree used to render the tree column cells.
 void setRows(Vector[] rowData)
          Reassigns all values in the table.
 void setTable(PanelTreeTable table)
          Sets the PanelTreeTable associated with this model.
 void setValueAt(Object value, int row, int column)
          Sets an attribute value for the record in the cell at row and column.
 void treeCollapsed(TreeExpansionEvent event)
           
 void treeExpanded(TreeExpansionEvent event)
           
 void treeNodesChanged()
           
 void treeNodesChanged(TreeModelEvent e)
           
 void treeNodesInserted(TreeModelEvent e)
           
 void treeNodesRemoved(TreeModelEvent e)
           
 void treeStructureChanged(TreeModelEvent e)
           
 void treeWillCollapse(TreeExpansionEvent event)
           
 void treeWillExpand(TreeExpansionEvent event)
           
 
Methods inherited from class com.ibm.as400.ui.framework.java.PanelTableModel
getColumn, getColumn, getColumnClass, getColumnCount, getColumnIdentifier, getColumnName, getRowCount, toString
 
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

PanelTreeTableModel

public PanelTreeTableModel(Vector tableColumns)
Constructs a PanelTreeTableModel.

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

setRendererTree

public void setRendererTree(JTree tree)
Sets the JTree used to render the tree column cells.

Parameters:
tree - the tree to be used as the renderer
Since:
v5r1m0

setTable

public void setTable(PanelTreeTable table)
Sets the PanelTreeTable associated with this model.

Parameters:
table - the PanelTreeTable associated with this model
Since:
v5r1m0

setComponentAttributeAssociation

public void setComponentAttributeAssociation(com.ibm.as400.ui.framework.java.ComponentAttributeAssociation caa)
Sets the ComponentAttributeAssociation associated with this model.

Parameters:
caa - the ComponentAttributeAssociation associated with this model
Since:
v5r1m0

setColumn

public void setColumn(int column,
                      Object[] items,
                      com.ibm.as400.ui.framework.java.ComponentAttributeAssociation caa)
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:
v5r1m0
See Also:
PanelTableModel.getColumn(int)

setColumn

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

Overrides:
setColumn in class PanelTableModel
Parameters:
column - the column whose values are to be set
the - list of values at the specified column
Since:
v5r1m0
See Also:
PanelTableModel.getColumn(int)

getValueAt

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

Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class PanelTableModel
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:
v5r1m0
See Also:
setValueAt(java.lang.Object, int, int)

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 PanelTableModel
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:
v5r1m0
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.

Overrides:
setCellEditable in class PanelTableModel
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:
v5r1m0
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 PanelTableModel
Parameters:
value - the new value
row - the row whose value is to be changed
column - the column whose value is to be changed
Since:
v5r1m0
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.

Overrides:
addRow in class PanelTableModel
Parameters:
rowData - data of the row being added (may be null)
Since:
v5r1m0
See Also:
removeRow(int)

addRow

public void addRow(Vector rowData,
                   DefaultMutableTreeNode parent)
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:
v5r1m0
See Also:
removeRow(int)

insertNodeRow

public void insertNodeRow(Vector rowData,
                          DefaultMutableTreeNode nodeParent,
                          int nodeIndex)
Inserts a node into the renderer tree and then calls insertRow to add the corresponding row to the table model. Notification of the row being added to the table model will be generated.

Parameters:
nodeRow - - the row of data to be added. The first element in this vector must be a DefaultMutableTreeNode
nodeParent - - the parent node of the node being added
nodeIndex - - the index of this node in the parent's child array
Since:
v5r1m0
See Also:
insertRow(int, java.util.Vector), removeRow(int)

insertRow

public void insertRow(int rowIndex,
                      Vector rowData)
Inserts a row at rowIndex the model. The new row will contain null values unless rowData is specified. Notification of the row being added will be generated.

Parameters:
rowIndex - - the row index of the row to be inserted
rowData - - optional data of the row being added
Since:
v5r1m0
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.

Overrides:
setRows in class PanelTableModel
Parameters:
rowData - array of data for the rows being added (may be null)
Since:
v5r1m0
See Also:
getRows()

getRows

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

Overrides:
getRows in class PanelTableModel
Since:
v5r1m0
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.

Overrides:
removeRow in class PanelTableModel
Parameters:
rowToRemove - the row index of the row to be removed
Throws:
ArrayIndexOutOfBoundsException - if the row was invalid
Since:
v5r1m0

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.

Overrides:
removeRows in class PanelTableModel
Parameters:
rowsToRemove - a list of row indices for the rows to be removed
Since:
v5r1m0

treeExpanded

public void treeExpanded(TreeExpansionEvent event)
Specified by:
treeExpanded in interface TreeExpansionListener

treeCollapsed

public void treeCollapsed(TreeExpansionEvent event)
Specified by:
treeCollapsed in interface TreeExpansionListener

treeWillExpand

public void treeWillExpand(TreeExpansionEvent event)
Specified by:
treeWillExpand in interface TreeWillExpandListener

treeWillCollapse

public void treeWillCollapse(TreeExpansionEvent event)
Specified by:
treeWillCollapse in interface TreeWillExpandListener

treeNodesChanged

public void treeNodesChanged(TreeModelEvent e)
Specified by:
treeNodesChanged in interface TreeModelListener

treeNodesInserted

public void treeNodesInserted(TreeModelEvent e)
Specified by:
treeNodesInserted in interface TreeModelListener

treeNodesRemoved

public void treeNodesRemoved(TreeModelEvent e)
Specified by:
treeNodesRemoved in interface TreeModelListener

treeStructureChanged

public void treeStructureChanged(TreeModelEvent e)
Specified by:
treeStructureChanged in interface TreeModelListener

treeNodesChanged

public void treeNodesChanged()