|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
org.openbp.swing.components.treetable.SimpleTreeTableModel
public class SimpleTreeTableModel
The SimpleTreeTableModel can be thought of as an abstract model, although all required
methods have been implemented. When wanting to write an own TreeTableModel, it is suggested
to extend this model and override only those methods as required.
| Field Summary | |
|---|---|
protected java.lang.String[] |
columnHeader
The header information for the columns |
protected TreeTableNode |
root
The root element used by the tree. |
protected JTreeTable |
treeTable
The JTreeTable using this model. |
| Fields inherited from class javax.swing.table.AbstractTableModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
SimpleTreeTableModel(TreeTableNode rootNode)
Default Constructor Note: When using this constructor the tree table reference to this model will have to be explicity set. |
|
SimpleTreeTableModel(TreeTableNode rootNode,
JTreeTable treeTable)
Default preferred constructor. |
|
| Method Summary | |
|---|---|
void |
addTreeModelListener(javax.swing.event.TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes. |
protected void |
delayedFireTableDataChanged(int tableEventType)
Invokes fireTableDataChanged after all the pending events have been processed. |
void |
fireNodeChanged(javax.swing.tree.TreeNode node)
Invoke this method if you've totally changed the children of node and its childrens children... |
void |
fireNodeInserted(javax.swing.tree.TreeNode parent)
Invoke this method if you've inserted a new node into the model. |
void |
fireNodeRemoved(javax.swing.tree.TreeNode parent)
Invoke this method if you've removed a node from the model. |
void |
fireNodeStructureChanged(javax.swing.tree.TreeNode node)
Invoke this method if you've totally changed the children of node and its childrens children... |
void |
fireTableChangesCompleted(int tableEventType)
Notifies all tree table listeners that all changes have been completed. |
protected void |
fireTreeNodesChanged(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireTreeNodesInserted(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireTreeNodesRemoved(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireTreeStructureChanged(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
Notifies all listeners that have registered interest for notification on this event type. |
java.lang.Object |
getChild(java.lang.Object parent,
int index)
Returns the child of parent at index index in the parent's child array. |
int |
getChildCount(java.lang.Object parent)
Returns the number of children DefaultTreeTableNodes the receiver contains. |
java.lang.Class |
getColumnClass(int column)
Returns the class type for column number column. |
int |
getColumnCount()
Gets the number of columns contained to be used in the JTreeTable |
java.lang.String |
getColumnName(int columnIndex)
Gets the column header for the specified column index. |
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
Returns the index of child in parent. |
java.util.EventListener[] |
getListeners(java.lang.Class listenerType)
Returns an array of all the objects currently registered as FooListeners upon this model. |
javax.swing.tree.TreeNode[] |
getPathToRoot(javax.swing.tree.TreeNode aNode)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. |
protected javax.swing.tree.TreeNode[] |
getPathToRoot(javax.swing.tree.TreeNode aNode,
int depth)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. |
java.lang.Object |
getRoot()
Returns the root of the tree. |
int |
getRowCount()
Returns the number of rows contained in the table. |
javax.swing.event.TreeModelListener[] |
getTreeModelListeners()
Returns an array of all the tree model listeners registered on this model. |
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex)
Gets the object value for a specified cell for the receiver node. |
boolean |
isCellEditable(int row,
int column)
Returns if a cell at a specified row and column is editable. |
boolean |
isCellSelectable(int row,
int column)
Used by the tree table to determine if a specified cell is selectable. |
boolean |
isLeaf(java.lang.Object node)
Returns true if the receiver is a leaf. |
void |
removeTreeModelListener(javax.swing.event.TreeModelListener l)
Removes a listener previously added with addTreeModelListener. |
void |
setColumnHeader(java.lang.String[] columnHeader)
Set the column headers. |
void |
setRoot(TreeTableNode root)
Sets the root. |
void |
setTreeTable(JTreeTable treeTable)
If the constructor was used in which the JTreeTable was not set, this method
should be called directly after instantiating the model to set the JTreeTable. |
void |
setValueAt(java.lang.Object aValue,
java.lang.Object node,
int column)
Sets the value for node node, at column number column. |
void |
valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
Messaged when the user has altered the value for the item identified by path to newValue. |
| Methods inherited from class javax.swing.table.AbstractTableModel |
|---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getTableModelListeners, removeTableModelListener, setValueAt |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.swing.table.TableModel |
|---|
addTableModelListener, removeTableModelListener, setValueAt |
| Field Detail |
|---|
protected TreeTableNode root
protected JTreeTable treeTable
protected java.lang.String[] columnHeader
| Constructor Detail |
|---|
public SimpleTreeTableModel(TreeTableNode rootNode)
rootNode - The root node for this model
public SimpleTreeTableModel(TreeTableNode rootNode,
JTreeTable treeTable)
rootNode - The root element of the treetreeTable - The treeTable using this model| Method Detail |
|---|
public void setTreeTable(JTreeTable treeTable)
JTreeTable was not set, this method
should be called directly after instantiating the model to set the JTreeTable.
setTreeTable in interface TreeTableModeltreeTable - The JTreeTable using this modelpublic void setColumnHeader(java.lang.String[] columnHeader)
columnHeader - A string arraypublic int getRowCount()
getRowCount in interface javax.swing.table.TableModelpublic java.lang.Class getColumnClass(int column)
TreeTableModel class is returned, and the rest
are Object classes.
getColumnClass in interface javax.swing.table.TableModelgetColumnClass in class javax.swing.table.AbstractTableModelcolumn - The column of interest
public boolean isCellEditable(int row,
int column)
isCellEditable in interface javax.swing.table.TableModelisCellEditable in class javax.swing.table.AbstractTableModelrow - The cell's rowcolumn - The cell's column
public void setValueAt(java.lang.Object aValue,
java.lang.Object node,
int column)
aValue - The object to be setnode - The node to which the object is to be setcolumn - The column index where the object is to set
public java.lang.Object getValueAt(int rowIndex,
int columnIndex)
getValueAt in interface javax.swing.table.TableModelrowIndex - The row index of the specified cellcolumnIndex - The column index for the specified cell
public int getColumnCount()
JTreeTable
getColumnCount in interface javax.swing.table.TableModelpublic java.lang.String getColumnName(int columnIndex)
getColumnName in interface javax.swing.table.TableModelgetColumnName in class javax.swing.table.AbstractTableModelcolumnIndex - Index of the column
public java.lang.Object getRoot()
getRoot in interface javax.swing.tree.TreeModelpublic void setRoot(TreeTableNode root)
root - The root to setpublic int getChildCount(java.lang.Object parent)
getChildCount in interface javax.swing.tree.TreeModelparent - The node from which the child count is required
public boolean isLeaf(java.lang.Object node)
isLeaf in interface javax.swing.tree.TreeModelnode - The node to be examined
public java.lang.Object getChild(java.lang.Object parent,
int index)
getChild in interface javax.swing.tree.TreeModelparent - The node in the tree, obtained from this data sourceindex - The index of the child node in the parent array
public int getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
getIndexOfChild in interface javax.swing.tree.TreeModelparent - a note in the tree, obtained from this data sourcechild - the node we are interested in
public void valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
valueForPathChanged in interface javax.swing.tree.TreeModelpath - path to the node that the user has alterednewValue - the new value from the TreeCellEditor
public boolean isCellSelectable(int row,
int column)
isCellSelectable in interface TreeTableModelrow - Row index of the specified cellcolumn - Column index of the specified cell
public void addTreeModelListener(javax.swing.event.TreeModelListener l)
addTreeModelListener in interface javax.swing.tree.TreeModell - the listener to addpublic void removeTreeModelListener(javax.swing.event.TreeModelListener l)
removeTreeModelListener in interface javax.swing.tree.TreeModell - the listener to removepublic javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode)
aNode - the TreeNode to get the path for
protected javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode,
int depth)
aNode - the TreeNode to get the path fordepth - an int giving the number of steps already taken towards
the root (on recursive calls), used to size the returned array
public javax.swing.event.TreeModelListener[] getTreeModelListeners()
public void fireNodeStructureChanged(javax.swing.tree.TreeNode node)
node - The node where the structture has changedpublic void fireNodeInserted(javax.swing.tree.TreeNode parent)
parent - Parent of the node that was insertedpublic void fireNodeRemoved(javax.swing.tree.TreeNode parent)
parent - Parent of the node that was removedpublic void fireNodeChanged(javax.swing.tree.TreeNode node)
node - The node where the structure has changed
protected void fireTreeNodesChanged(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
source - the node being changedpath - the path to the root nodechildIndices - the indices of the changed elementschildren - the changed elements
protected void fireTreeNodesInserted(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
source - the node where new elements are being insertedpath - the path to the root nodechildIndices - the indices of the new elementschildren - the new elements
protected void fireTreeNodesRemoved(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
source - the node where elements are being removedpath - the path to the root nodechildIndices - the indices of the removed elementschildren - the removed elements
protected void fireTreeStructureChanged(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
source - the node where the tree model has changedpath - the path to the root nodechildIndices - the indices of the affected elementschildren - the affected elementspublic void fireTableChangesCompleted(int tableEventType)
tableEventType - The table event type of TableModelEventpublic java.util.EventListener[] getListeners(java.lang.Class listenerType)
You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a DefaultTreeModel m for its tree model listeners with the following code:
TreeModelListener[] tmls = (TreeModelListener[])(m.getListeners(TreeModelListener.class));If no such listeners exist, this method returns an empty array.
getListeners in class javax.swing.table.AbstractTableModellistenerType - the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
java.lang.ClassCastException - if listenerType
doesn't specify a class or interface that implements
java.util.EventListenerprotected void delayedFireTableDataChanged(int tableEventType)
tableEventType - The table event type of TableModelEvent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||