com.alee.laf.tree
Class TreeUtils

java.lang.Object
  extended by com.alee.laf.tree.TreeUtils

public final class TreeUtils
extends java.lang.Object

This class provides a set of utilities for trees. This is a library utility class and its not intended for use outside of the trees.

Author:
Mikle Garin

Constructor Summary
TreeUtils()
           
 
Method Summary
static TreeState getTreeState(javax.swing.JTree tree)
          Returns tree expansion and selection states.
static TreeState getTreeState(javax.swing.JTree tree, boolean saveSelection)
          Returns tree expansion and selection states.
static
<E extends javax.swing.tree.DefaultMutableTreeNode>
void
optimizeNodes(java.util.List<E> nodes)
          Optimizes list of nodes by removing those which already have their parent node in the list.
static void setTreeState(javax.swing.JTree tree, TreeState treeState)
          Restores tree expansion and selection states.
static void setTreeState(javax.swing.JTree tree, TreeState treeState, boolean restoreSelection)
          Restores tree expansion and selection states.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeUtils

public TreeUtils()
Method Detail

getTreeState

public static TreeState getTreeState(javax.swing.JTree tree)
Returns tree expansion and selection states. Tree nodes must be instances of UniqueNode class.

Parameters:
tree - tree to process
Returns:
tree expansion and selection states

getTreeState

public static TreeState getTreeState(javax.swing.JTree tree,
                                     boolean saveSelection)
Returns tree expansion and selection states. Tree nodes must be instances of UniqueNode class.

Parameters:
tree - tree to process
saveSelection - whether to save selection states or not
Returns:
tree expansion and selection states

setTreeState

public static void setTreeState(javax.swing.JTree tree,
                                TreeState treeState)
Restores tree expansion and selection states. Tree nodes must be instances of UniqueNode class.

Parameters:
tree - tree to process
treeState - tree expansion and selection states

setTreeState

public static void setTreeState(javax.swing.JTree tree,
                                TreeState treeState,
                                boolean restoreSelection)
Restores tree expansion and selection states. Tree nodes must be instances of UniqueNode class.

Parameters:
tree - tree to process
treeState - tree expansion and selection states
restoreSelection - whether to restore selection states or not

optimizeNodes

public static <E extends javax.swing.tree.DefaultMutableTreeNode> void optimizeNodes(java.util.List<E> nodes)
Optimizes list of nodes by removing those which already have their parent node in the list.

Parameters:
nodes - nodes list to optimize