JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.treetable
Class TableFromTreeTable

java.lang.Object
  |
  +--com.klg.jclass.util.treetable.TableFromTreeTable
All Implemented Interfaces:
TableModel

public class TableFromTreeTable
extends Object
implements TableModel

Class to wrap a treetable model so that the data in it can be viewed as a table model. This is an internal class and not for public use.


Field Summary
protected  int hashInt
           
protected  ArrayList rowMap
           
protected  Hashtable treeMap
           
protected  com.klg.jclass.util.treetable.JCTreeTableModel treetable
           
 
Constructor Summary
TableFromTreeTable(com.klg.jclass.util.treetable.JCTreeTableModel treetable)
           
 
Method Summary
protected  void addKids(TreePath parent_path, Object parent)
          Add the kids of the parent whose is currently at the end of the parent_path, to the row to treepath and treepath to row mappings.
 void addTableModelListener(TableModelListener l)
          Adds a listener to the list that's notified each time a change to the data model occurs.
 Class getColumnClass(int columnIndex)
          Returns the lowest common denominator Class in the column.
 int getColumnCount()
          Returns the number of columns managed by the data source object.
 String getColumnName(int columnIndex)
          Returns the name of the column at columnIndex.
 int getRowCount()
          Returns the number of records managed by the data source object.
 Object getValueAt(int rowIndex, int columnIndex)
          Returns an attribute value for the cell at columnIndex and rowIndex.
protected  void initMappings()
          Initialize the row to tree and tree to row mappings
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true if the cell at rowIndex and columnIndex is editable.
 void removeTableModelListener(TableModelListener l)
          Removes a listener from the list that's notified each time a change to the data model occurs.
protected  void resetMappings()
          If the treetable has changed it needs to call this to reset the mappings
protected  Object rowToNode(int row)
          Get the node for the given row
protected  TreePath rowToTreePath(int row)
          Get the tree path for the given row
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
          Sets an attribute value for the record in the cell at columnIndex and rowIndex.
protected  int treePathToRow(TreePath path)
          Get the row for the given tree path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

treetable

protected com.klg.jclass.util.treetable.JCTreeTableModel treetable

rowMap

protected ArrayList rowMap

hashInt

protected int hashInt

treeMap

protected Hashtable treeMap
Constructor Detail

TableFromTreeTable

public TableFromTreeTable(com.klg.jclass.util.treetable.JCTreeTableModel treetable)
Method Detail

addKids

protected void addKids(TreePath parent_path,
                       Object parent)
Add the kids of the parent whose is currently at the end of the parent_path, to the row to treepath and treepath to row mappings. If the kids have children, recursively call this method on the kids.

Parameters:
parent_path - The path from the root up to and including the parent
parent - The parent whose kids we want to add

initMappings

protected void initMappings()
Initialize the row to tree and tree to row mappings


resetMappings

protected void resetMappings()
If the treetable has changed it needs to call this to reset the mappings


rowToNode

protected Object rowToNode(int row)
Get the node for the given row

Parameters:
row - The row whose node we want
Returns:
The node for the given row

rowToTreePath

protected TreePath rowToTreePath(int row)
Get the tree path for the given row

Parameters:
row - The row whose path we want
Returns:
The tree path for the given row

treePathToRow

protected int treePathToRow(TreePath path)
Get the row for the given tree path

Parameters:
path - The path whose row we want
Returns:
The row corresponding to the given tree path. Returns a negative value on error.

getRowCount

public int getRowCount()
Returns the number of records managed by the data source object. A JTable uses this method to determine how many rows it should create and display. This method should be quick, as it is called by JTable quite frequently.

Specified by:
getRowCount in interface TableModel
Returns:
the number or rows in the model
See Also:
getColumnCount()

getColumnCount

public int getColumnCount()
Returns the number of columns managed by the data source object. A JTable< uses this method to determine how many columns it should create and display upon initialization.

Specified by:
getColumnCount in interface TableModel
Returns:
the number or columns in the model
See Also:
getRowCount()

getColumnName

public String getColumnName(int columnIndex)
Returns the name of the column at columnIndex. This is used to initialize the table's column header name. Note, this name does not need to be unique. Two columns in a table can have the same name.

Specified by:
getColumnName in interface TableModel
Parameters:
columnIndex - the index of column
Returns:
the name of the column

getColumnClass

public Class getColumnClass(int columnIndex)
Returns the lowest common denominator Class in the column. This is used by the table to set up a default renderer and editor for the column.

Specified by:
getColumnClass in interface TableModel
Parameters:
columnIndex - the index of the column whose class has been requested
Returns:
the common ancestor class of the object values in the model.

isCellEditable

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

Specified by:
isCellEditable in interface TableModel
Parameters:
rowIndex - the row of the cell whose editable value is requested
columnIndex - the column of the cell whose editable value is requested
Returns:
true if the cell is editable.
See Also:
setValueAt(java.lang.Object, int, int)

getValueAt

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

Specified by:
getValueAt in interface TableModel
Parameters:
rowIndex - the row whose value is to be looked up
columnIndex - the column whose value is to be looked up
Returns:
the value Object at the specified cell

setValueAt

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

Specified by:
setValueAt in interface TableModel
Parameters:
aValue - the new value
rowIndex - the row whose value is to be changed
columnIndex - the column whose value is to be changed
See Also:
getValueAt(int, int), isCellEditable(int, int)

addTableModelListener

public void addTableModelListener(TableModelListener l)
Adds a listener to the list that's notified each time a change to the data model occurs.

Specified by:
addTableModelListener in interface TableModel
Parameters:
l - the TableModelListener

removeTableModelListener

public void removeTableModelListener(TableModelListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.

Specified by:
removeTableModelListener in interface TableModel
Parameters:
l - the TableModelListener

Copyright © 2004 Quest Software Inc..
All rights reserved.