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 ArrayListThe list of column identifiers.protected HashMapThe 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 TypeMethodDescriptionvoidaddNodeInto(TreeTableNode newChild, TreeTableNode parent) Invoke this to insert newChild at a specific location in parents children.protected static ArrayListconvertToArrayList(Object[] anArray) Returns an array list that contains the same objects as the array.protected voidfireTreeTableSorted(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.intReturns 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.voidinsertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index) booleanisCellEditable(Object node, int column) Indicates whether the the value for nodenode, at column numbercolumnis editable.voidnodeSorted(TreeNode node) Invoke this method if you've sorted the nodevoidInvoke this method if you've sorted the entire tree modelvoidsetAllCellsEditable(boolean editable) Set all cells in the model editable or not editable.voidsetColumnIdentifiers(Object[] newIdentifiers) Replaces the column identifiers in the model.voidsetColumnIdentifiers(ArrayList newIdentifiers) Replaces the column identifiers in the model.voidsetSortComparatorForColumn(TreeTableNodeComparator comparator, int column) Specify a comparator to use when sorting the tree table based oncolumn.voidsetValueAt(Object aValue, Object node, int row, int column) Sets the value for nodenode, at row numberrow.voidsort(int column, boolean ascending) Sort the entire tree model according to the values of the specifiedcolumn.voidvalueForPathChanged(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, setRootMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getColumnCountin interfaceTreeTableModel
-
getColumnName
Returns the name for column numbercolumn.- Specified by:
getColumnNamein interfaceTreeTableModel
-
getColumnClass
Returns the type for column numbercolumn.- Specified by:
getColumnClassin interfaceTreeTableModel
-
getValueAt
Returns the value to be displayed for nodenode, at column numbercolumn.- Specified by:
getValueAtin 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 numbercolumnis editable.- Specified by:
isCellEditablein interfaceTreeTableModel
-
setValueAt
Sets the value for nodenode, at row numberrow. at column numbercolumn.- Specified by:
setValueAtin interfaceTreeTableModel
-
valueForPathChanged
- Specified by:
valueForPathChangedin interfaceTreeModel- Overrides:
valueForPathChangedin classDefaultTreeModel
-
setColumnIdentifiers
Replaces the column identifiers in the model. If the number ofnewIdentifiers is greater than the current number of columns, new columns are added to the end of each row in the model. If the number ofnewIdentifiers 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 ofnewIdentifiers is greater than the current number of columns, new columns are added to the end of each row in the model. If the number ofnewIdentifiers 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:
insertNodeIntoin 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 specifiedcolumnwithin 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 callingsetSortComparatorForColumnprior to calling this method.- Specified by:
sortin 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
anArrayisnull, returnsnull
-