org.openbp.swing.components.treetable
Class DefaultTreeTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.openbp.swing.components.treetable.SimpleTreeTableModel
org.openbp.swing.components.treetable.DefaultTreeTableModel
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.table.TableModel, javax.swing.tree.TreeModel, TreeTableModel
public class DefaultTreeTableModel
- extends SimpleTreeTableModel
The DefaultTreeTable model implements the TreeTableModel interface and extends the
AbstractTableModel. The TreeTableModel combines the TableModel and TreeModel interfaces,
thus providing a combined model for the JTreeTable. The model structure for the tree table
is based on the DefaultTreeTableNode, that implements functionality for holding all the column
objects of the table in a tree node. This provides a mechanism where the DefaultTreeTableNode
presents both a table row and a tree node. In order to build the structure for the tree table,
a DefaultTreeTableNode containing all the column objects should be added to the
DefaultTreeTableModel with the addNode() method. It is important to note that column value (0)
is the value used to display the value in the tree. This object may either be a String, or a
JLabel. In the case of a String, the String will be embedded into a JLabel with the appropriate
system icon for open, closed or leaf nodes. In the case of a JLabel, this label will be used
with the icon implemented in the label.
- Author:
- Erich Lauterbach
- See Also:
- Serialized Form
| Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
| Methods inherited from class org.openbp.swing.components.treetable.SimpleTreeTableModel |
addTreeModelListener, delayedFireTableDataChanged, fireNodeChanged, fireNodeInserted, fireNodeRemoved, fireNodeStructureChanged, fireTableChangesCompleted, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getColumnClass, getColumnName, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getRowCount, getTreeModelListeners, getValueAt, isCellEditable, isCellSelectable, isLeaf, removeTreeModelListener, setColumnHeader, setRoot, setTreeTable, setValueAt |
| 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 |
DefaultTreeTableModel
public DefaultTreeTableModel(DefaultTreeTableNode root)
- Default Constructor
- Parameters:
root - The root node for the TreeTable
getColumnCount
public int getColumnCount()
- Returns the number of columns contained in the table.
- Specified by:
getColumnCount in interface javax.swing.table.TableModel- Overrides:
getColumnCount in class SimpleTreeTableModel
- Returns:
- The number of columns contained in the table
valueForPathChanged
public void valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
- This sets the user object of the TreeNode identified by path
and posts a node changed. If you use custom user objects in
the TreeModel you're going to need to subclass this and
set the user object of the changed node to something meaningful.
- Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel- Overrides:
valueForPathChanged in class SimpleTreeTableModel
- Parameters:
path - The treePath for identificationnewValue - The new user object
addNode
public void addNode(DefaultTreeTableNode parent,
DefaultTreeTableNode child)
- Adds a new node to the tree. The node is of type
DefaultTreeTableNode, thus should containe all the
column objects.
- Parameters:
parent - The parent node to which the specified node
is to be added. The parent the parent is null, then the node
will use the parent set within the node, and if this is null,
then the node will added to the root node.child - Node to add
removeNode
public void removeNode(DefaultTreeTableNode node)
- Removed the specified node from the model. Note!: If the node contains
children, the these will also be removed.
- Parameters:
node - The node to be removed from the model
Copyright © 2011. All Rights Reserved.