|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.tree.AbstractTreeModel com.jidesoft.tree.DefaultTreeModelWrapper com.jidesoft.tree.SortableTreeModel
public class SortableTreeModel
SortableTreeModel is a tree model wrapper which can do the sorting.
Given any existing tree model, you can wrap it into SortableTreeModel
and use it later on any JTree.
SortableTreeModel sortableTreeModel = new SortableTreeModel(treeModel);
JTree sortableTree = new JTree(sortableTreeModel);
To sort the tree, you just call
sortableTreeModel.sort(); // or sort(SortableTreeModel.SORT_DESCENDING) to sort descending.
Field Summary | |
---|---|
static int |
SORT_ASCENDING
|
static int |
SORT_DESCENDING
|
static int |
UNSORTED
|
Fields inherited from class com.jidesoft.tree.DefaultTreeModelWrapper |
---|
EVENT_TYPE_NODES_CHANGED, EVENT_TYPE_NODES_INSERTED, EVENT_TYPE_NODES_REMOVED, EVENT_TYPE_STRUCTURE_CHANGED |
Fields inherited from class com.jidesoft.tree.AbstractTreeModel |
---|
listenerList |
Constructor Summary | |
---|---|
SortableTreeModel()
|
|
SortableTreeModel(TreeModel model)
Creates a DefaultTreeModelWrapper from any table model. |
Method Summary | |
---|---|
protected void |
configureListModelWrapper(ListModelWrapper wrapper,
Object parent)
Configures the ListModelWrapper that is used to sort the tree nodes at the same level. |
protected TreeModelEvent |
convertTreeModelEvent(TreeModelEvent e,
int eventType)
Converts the tree model event for the actual model to the event for this model. |
protected ListModelWrapper |
createListModelWrapper(Object parent)
Creates an empty list model wrapper. |
int |
getSortOrder()
|
void |
setSortOrder(int sortOrder)
Set the sort order. |
protected boolean |
shouldOptimize(TreeModelEvent e)
Check if the sorting regarding data insertion or removal should be optimized. |
void |
sort()
Sort or unsort the tree model. |
void |
sort(int order)
Sort the tree model. |
void |
treeNodesChanged(TreeModelEvent e)
Method for TreeModelListener. |
void |
treeNodesInserted(TreeModelEvent e)
Method for TreeModelListener. |
void |
treeNodesRemoved(TreeModelEvent e)
Method for TreeModelListener. |
void |
unsort()
Unsort the tree model. |
Methods inherited from class com.jidesoft.tree.DefaultTreeModelWrapper |
---|
clearAllListModelWrappers, clearListModelWrapper, convertTreeModelEvent, getActualModel, getChild, getChildCount, getIndexOfChild, getListModelWrapper, getRoot, initWrapper, isLeaf, setActualModel, setListModelWrapper, treeStructureChanged, valueForPathChanged |
Methods inherited from class com.jidesoft.tree.AbstractTreeModel |
---|
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeStructureChanged, getPathToRoot, getPathToRoot, getTreeModelListeners, nodeChanged, nodesChanged, removeTreeModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SORT_ASCENDING
public static final int SORT_DESCENDING
public static final int UNSORTED
Constructor Detail |
---|
public SortableTreeModel()
public SortableTreeModel(TreeModel model)
model
- the tree modelMethod Detail |
---|
protected ListModelWrapper createListModelWrapper(Object parent)
DefaultTreeModelWrapper
FilterableTreeModel
overrides it to create an instance of FilterableListModel
. SortableTreeModel
overrides it to create an instance of SortableListModel
.
Default implementation of this method in this class simply returns a new instance of
DefaultListModelWrapper
.
createListModelWrapper
in class DefaultTreeModelWrapper
parent
- the tree node
public void treeNodesChanged(TreeModelEvent e)
DefaultTreeModelWrapper
treeNodesChanged
in interface TreeModelListener
treeNodesChanged
in class DefaultTreeModelWrapper
e
- the TreeModelEventprotected TreeModelEvent convertTreeModelEvent(TreeModelEvent e, int eventType)
DefaultTreeModelWrapper
convertTreeModelEvent
in class DefaultTreeModelWrapper
e
- the TreeModelEventeventType
- the event type, DefaultTreeModelWrapper.EVENT_TYPE_NODES_INSERTED
, DefaultTreeModelWrapper.EVENT_TYPE_NODES_REMOVED
or DefaultTreeModelWrapper.EVENT_TYPE_NODES_CHANGED
public void treeNodesInserted(TreeModelEvent e)
DefaultTreeModelWrapper
treeNodesInserted
in interface TreeModelListener
treeNodesInserted
in class DefaultTreeModelWrapper
e
- the TreeModelEventpublic void treeNodesRemoved(TreeModelEvent e)
DefaultTreeModelWrapper
treeNodesRemoved
in interface TreeModelListener
treeNodesRemoved
in class DefaultTreeModelWrapper
e
- the TreeModelEventprotected boolean shouldOptimize(TreeModelEvent e)
e
- the tree model event
protected void configureListModelWrapper(ListModelWrapper wrapper, Object parent)
configureListModelWrapper
in class DefaultTreeModelWrapper
wrapper
- the list model wrapperparent
- the parent rowpublic int getSortOrder()
public void setSortOrder(int sortOrder)
sortOrder
- the new sort order. Valid values for sortOrder are SORT_ASCENDING
, SORT_DESCENDING
and UNSORTED
.public void sort(int order)
SORT_ASCENDING
or SORT_DESCENDING
.
You can also pass in UNSORTED
, which will be the same as unsort()
.
order
- the new sort order.public void sort()
public void unsort()
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |