|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sciapp.treetable.AbstractTreeTableModel
com.sciapp.treetable.TreeModelMap
com.sciapp.treetable.TreeTableModelMap
com.sciapp.treetable.DefaultSortTreeTableModel
public class DefaultSortTreeTableModel
DefaultSortTreeTableModel provides sorting capabilities to a TreeTableModel. This class wraps around a TreeTableModel and uses an internal SortTableModel instance to sort each group row of the model. You can use the sort tablemodel to control the sorting.
Field Summary |
---|
Fields inherited from class com.sciapp.treetable.TreeTableModelMap |
---|
treeTableModel |
Fields inherited from class com.sciapp.treetable.TreeModelMap |
---|
treeModel |
Fields inherited from class com.sciapp.treetable.AbstractTreeTableModel |
---|
listenerList, root |
Fields inherited from interface com.sciapp.treetable.TreeTableModel |
---|
CHANGE_COLUMN_SOURCE |
Constructor Summary | |
---|---|
DefaultSortTreeTableModel(TreeTableModel treeTableModel)
Constructs a DefaultSortTreeTableModel. |
Method Summary | |
---|---|
void |
clear()
Clears the model of any sorting performed. |
Object |
getChild(Object parent,
int index)
Returns the child of parent at index index
in the parent's
child array. parent must be a node previously obtained
from this data source. This should not return null
if index
is a valid index for parent (that is index >= 0 &&
index < getChildCount(parent )). |
int |
getIndexOfChild(Object parent,
Object child)
Returns the index of child in parent. If parent
is null or child is null ,
returns -1. |
int[] |
getMappedIndexes(Object node)
Returns an array representing how the nodes' children have been transformed. |
SortTableModel |
getSortTableModel()
Returns the internal sort tablemodel instance. |
boolean |
shouldSort(Object node)
Determines on which occasions the sort treetable model should sort the supplied node. |
void |
treeNodesChanged(TreeModelEvent e)
Invoked after a node (or a set of siblings) has changed in some way. The node(s) have not changed locations in the tree or altered their children arrays, but other attributes have changed and may affect presentation. Example: the name of a file has changed, but it is in the same location in the file system. To indicate the root has changed, childIndices and children will be null. Use |
void |
treeNodesInserted(TreeModelEvent e)
Invoked after nodes have been inserted into the tree. Use |
void |
treeNodesRemoved(TreeModelEvent e)
Invoked after nodes have been removed from the tree. Note that if a subtree is removed from the tree, this method may only be invoked once for the root of the removed subtree, not once for each individual set of siblings removed. Use |
void |
treeStructureChanged(TreeModelEvent e)
Invoked after the tree has drastically changed structure from a given node down. If the path returned by e.getPath() is of length one and the first element does not identify the current root node the first element should become the new root of the tree.
Use |
Methods inherited from class com.sciapp.treetable.TreeTableModelMap |
---|
addReorderListener, fireRowsMapped, fireRowsReordered, getColumnClass, getColumnCount, getColumnName, getInnerTreeTableModel, getTreeTableModel, getUncachedChildren, getUncachedGroupCount, getUncachedGroups, getValueAt, isAggregate, isCellEditable, isCountCached, isFooter, isHeader, isRangedModel, isValueCached, removeReorderListener, rowsReordered, setTreeModel, setTreeTableModel, setValueAt |
Methods inherited from class com.sciapp.treetable.TreeModelMap |
---|
getChildCount, getPathToRoot, getPathToRoot, getRoot, getTreeModel, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, valueForPathChanged |
Methods inherited from class com.sciapp.treetable.AbstractTreeTableModel |
---|
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeTableStructureChanged, fireTreeTableStructureChanged, removeTreeModelListener, setRoot |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.sciapp.treetable.TreeTableModel |
---|
getColumnClass, getColumnCount, getColumnName, getValueAt, isAggregate, isCellEditable, isFooter, isHeader, setValueAt |
Methods inherited from interface javax.swing.tree.TreeModel |
---|
addTreeModelListener, getChildCount, getRoot, isLeaf, removeTreeModelListener, valueForPathChanged |
Constructor Detail |
---|
public DefaultSortTreeTableModel(TreeTableModel treeTableModel)
Method Detail |
---|
public void clear()
public Object getChild(Object parent, int index)
parent
at index index
in the parent's
child array. parent
must be a node previously obtained
from this data source. This should not return null
if index
is a valid index for parent
(that is index >= 0 &&
index < getChildCount(parent
)).
getChild
in interface TreeModel
getChild
in class TreeModelMap
parent
- a node in the tree, obtained from this data source
parent
at index index
public int getIndexOfChild(Object parent, Object child)
parent
is null
or child
is null
,
returns -1.
getIndexOfChild
in interface TreeModel
getIndexOfChild
in class TreeModelMap
parent
- a note in the tree, obtained from this data sourcechild
- the node we are interested in
child
or parent
are null
public int[] getMappedIndexes(Object node)
getMappedIndexes
in class TreeTableModelMap
node
- the tree node
public SortTableModel getSortTableModel()
public boolean shouldSort(Object node)
For example, for not sorting the root node:
return node != getRoot();
For not sorting the root node and its direct children nodes:
return node != getRoot() && super.getIndexOfChild(getRoot(), node) == -1;
To allow sorting only at a specific node level, and supposing node
is a DefaultMutableTreeNode:
DefaultMutableTreeNode n = (DefaultMutableTreeNode) node;
int level = n.getLevel();
return level == 3;
You can also take the sort states currently installed in the sort tablemodel instance into consideration in your evaluation of this method:
SortState[] sortStates = getSortTableModel().getSortStates();
if (sortStates != null && sortStates.length > 0) {
int field = sortStates[0].getField();
if (field == 3 && node != getRoot()) return false;
}
return true;
node
- the affected node
public void treeNodesChanged(TreeModelEvent e)
Invoked after a node (or a set of siblings) has changed in some way. The node(s) have not changed locations in the tree or altered their children arrays, but other attributes have changed and may affect presentation. Example: the name of a file has changed, but it is in the same location in the file system.
To indicate the root has changed, childIndices and children will be null.
Use e.getPath()
to get the parent of the changed node(s).
e.getChildIndices()
returns the index(es) of the changed node(s).
treeNodesChanged
in interface TreeModelListener
treeNodesChanged
in class TreeModelMap
public void treeNodesInserted(TreeModelEvent e)
Invoked after nodes have been inserted into the tree.
Use e.getPath()
to get the parent of the new node(s).
e.getChildIndices()
returns the index(es) of the new node(s)
in ascending order.
treeNodesInserted
in interface TreeModelListener
treeNodesInserted
in class TreeModelMap
public void treeNodesRemoved(TreeModelEvent e)
Invoked after nodes have been removed from the tree. Note that if a subtree is removed from the tree, this method may only be invoked once for the root of the removed subtree, not once for each individual set of siblings removed.
Use e.getPath()
to get the former parent of the deleted node(s).
e.getChildIndices()
returns, in ascending order, the index(es)
the node(s) had before being deleted.
treeNodesRemoved
in interface TreeModelListener
treeNodesRemoved
in class TreeModelMap
public void treeStructureChanged(TreeModelEvent e)
Invoked after the tree has drastically changed structure from a given node down. If the path returned by e.getPath() is of length one and the first element does not identify the current root node the first element should become the new root of the tree.
Use e.getPath()
to get the path to the node.
e.getChildIndices()
returns null.
treeStructureChanged
in interface TreeModelListener
treeStructureChanged
in class TreeModelMap
|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |