Package com.portal.pfc.ui
Class DefaultTreeTableModel
java.lang.Object
javax.swing.tree.DefaultTreeModel
com.portal.pfc.ui.DefaultTreeTableModel
- All Implemented Interfaces:
SortableTableModel
,TreeTableModel
,Serializable
,TreeModel
public class DefaultTreeTableModel
extends DefaultTreeModel
implements TreeTableModel, SortableTableModel
A simple tree table data model that uses TreeTableNodes. Also supports
sorting the tree table.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayList
The list of column identifiers.protected HashMap
The set of comparators used for sorting.Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultTreeTableModel
(TreeTableNode root, boolean asksAllowsChildren, Object[] columnNames) Creates a DefaultTreeTableModel specifying whether any node can have children, or whether only certain nodes can have children.DefaultTreeTableModel
(TreeTableNode root, boolean asksAllowsChildren, ArrayList columnNames) Creates a DefaultTreeTableModel specifying whether any node can have children, or whether only certain nodes can have children.DefaultTreeTableModel
(TreeTableNode root, Object[] columnNames) Creates a DefaultTreeTableModel in which any node can have children and with as many columns as there are elements in columnNamesDefaultTreeTableModel
(TreeTableNode root, ArrayList columnNames) Creates a DefaultTreeTableModel in which any node can have children and with as many columns as there are elements in columnNames -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNodeInto
(TreeTableNode newChild, TreeTableNode parent) Invoke this to insert newChild at a specific location in parents children.protected static ArrayList
convertToArrayList
(Object[] anArray) Returns an array list that contains the same objects as the array.protected void
fireTreeTableSorted
(Object source, Object[] path) Notify all listeners that have registered interest for notification on this event type.getColumnClass
(int column) Returns the type for column numbercolumn
.int
Returns the number of columns in the tree table.getColumnName
(int column) Returns the name for column numbercolumn
.getValueAt
(Object node, int column) Returns the value to be displayed for nodenode
, at column numbercolumn
.void
insertNodeInto
(MutableTreeNode newChild, MutableTreeNode parent, int index) boolean
isCellEditable
(Object node, int column) Indicates whether the the value for nodenode
, at column numbercolumn
is editable.void
nodeSorted
(TreeNode node) Invoke this method if you've sorted the nodevoid
Invoke this method if you've sorted the entire tree modelvoid
setAllCellsEditable
(boolean editable) Set all cells in the model editable or not editable.void
setColumnIdentifiers
(Object[] newIdentifiers) Replaces the column identifiers in the model.void
setColumnIdentifiers
(ArrayList newIdentifiers) Replaces the column identifiers in the model.void
setSortComparatorForColumn
(TreeTableNodeComparator comparator, int column) Specify a comparator to use when sorting the tree table based oncolumn
.void
setValueAt
(Object aValue, Object node, int row, int column) Sets the value for nodenode
, at row numberrow
.void
sort
(int column, boolean ascending) Sort the entire tree model according to the values of the specifiedcolumn
.void
valueForPathChanged
(TreePath path, Object newValue) Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, getChild, getChildCount, getIndexOfChild, getRoot, isLeaf, removeTreeModelListener
-
Field Details
-
columnIdentifiers
The list of column identifiers. -
sortComparators
The set of comparators used for sorting.
-
-
Constructor Details
-
DefaultTreeTableModel
Creates a DefaultTreeTableModel in which any node can have children and with as many columns as there are elements in columnNames- Parameters:
root
- - a TreeTableNode object that is the root of the treecolumnNames
- - array containing the names of the new columns; if this is null then the model has no columns
-
DefaultTreeTableModel
Creates a DefaultTreeTableModel in which any node can have children and with as many columns as there are elements in columnNames- Parameters:
root
- - a TreeTableNode object that is the root of the treecolumnNames
- - list containing the names of the new columns; if this is null then the model has no columns
-
DefaultTreeTableModel
Creates a DefaultTreeTableModel specifying whether any node can have children, or whether only certain nodes can have children. The tree table has as many columns as there are elements in columnNames- Parameters:
root
- - a TreeTableNode object that is the root of the treeasksAllowsChildren
- - if false, any node without children is a leafcolumnNames
- - array containing the names of the new columns; if this is null then the model has no columns
-
DefaultTreeTableModel
Creates a DefaultTreeTableModel specifying whether any node can have children, or whether only certain nodes can have children. The tree table has as many columns as there are elements in columnNames- Parameters:
root
- - a TreeTableNode object that is the root of the treeasksAllowsChildren
- - if false, any node without children is a leafcolumnNames
- - list containing the names of the new columns; if this is null then the model has no columns
-
-
Method Details
-
getColumnCount
public int getColumnCount()Returns the number of columns in the tree table.- Specified by:
getColumnCount
in interfaceTreeTableModel
-
getColumnName
Returns the name for column numbercolumn
.- Specified by:
getColumnName
in interfaceTreeTableModel
-
getColumnClass
Returns the type for column numbercolumn
.- Specified by:
getColumnClass
in interfaceTreeTableModel
-
getValueAt
Returns the value to be displayed for nodenode
, at column numbercolumn
.- Specified by:
getValueAt
in interfaceTreeTableModel
-
setAllCellsEditable
public void setAllCellsEditable(boolean editable) Set all cells in the model editable or not editable.- Parameters:
editable
-
-
isCellEditable
Indicates whether the the value for nodenode
, at column numbercolumn
is editable.- Specified by:
isCellEditable
in interfaceTreeTableModel
-
setValueAt
Sets the value for nodenode
, at row numberrow
. at column numbercolumn
.- Specified by:
setValueAt
in interfaceTreeTableModel
-
valueForPathChanged
- Specified by:
valueForPathChanged
in interfaceTreeModel
- Overrides:
valueForPathChanged
in classDefaultTreeModel
-
setColumnIdentifiers
Replaces the column identifiers in the model. If the number ofnewIdentifier
s is greater than the current number of columns, new columns are added to the end of each row in the model. If the number ofnewIdentifier
s is less than the current number of columns, all the extra columns at the end of a row are discarded.- Parameters:
newIdentifiers
- array of column identifiers. Ifnull
, set the model to zero columns- See Also:
-
setColumnIdentifiers
Replaces the column identifiers in the model. If the number ofnewIdentifier
s is greater than the current number of columns, new columns are added to the end of each row in the model. If the number ofnewIdentifier
s is less than the current number of columns, all the extra columns at the end of a row are discarded.- Parameters:
newIdentifiers
- vector of column identifiers. Ifnull
, set the model to zero columns- See Also:
-
addNodeInto
Invoke this to insert newChild at a specific location in parents children. The location will be normally be at the end of the child list. However, if parent is sorted then a location will be determined that is consistent with the current ordering. This method is the preferred mechanism for adding nodes to a sorted tree. This method will then message nodesWereInserted to create the appropriate event. This is the preferred way to add children as it will create the appropriate event. -
insertNodeInto
- Overrides:
insertNodeInto
in classDefaultTreeModel
-
setSortComparatorForColumn
Specify a comparator to use when sorting the tree table based oncolumn
. The comparator will be used to compare the values at the specifiedcolumn
within the nodes, not to compare the nodes themselves. -
sort
public void sort(int column, boolean ascending) Sort the entire tree model according to the values of the specifiedcolumn
. A comparator can be specified for comparing these values by callingsetSortComparatorForColumn
prior to calling this method.- Specified by:
sort
in interfaceSortableTableModel
- Parameters:
column
- - specifies the column identifier used to compare the nodesascending
- - whether to sort in ascending order as opposed to descending order
-
nodesSorted
public void nodesSorted()Invoke this method if you've sorted the entire tree model -
nodeSorted
Invoke this method if you've sorted the node -
fireTreeTableSorted
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.- See Also:
-
convertToArrayList
Returns an array list that contains the same objects as the array.- Parameters:
anArray
- the array to be converted- Returns:
- the new vector; if
anArray
isnull
, returnsnull
-