com.alee.laf.tree
Class WebTreeModel<E extends javax.swing.tree.DefaultMutableTreeNode>

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by com.alee.laf.tree.WebTreeModel<E>
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.TreeModel
Direct Known Subclasses:
AsyncTreeModel

public class WebTreeModel<E extends javax.swing.tree.DefaultMutableTreeNode>
extends javax.swing.tree.DefaultTreeModel

Extended Swing DefaultTreeModel. This model contains multiply elements add/remove methods and works with typed elements.

Author:
Mikle Garin
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
WebTreeModel(E root)
          Constructs tree model with a specified node as root.
WebTreeModel(E root, boolean asksAllowsChildren)
          Constructs tree model with a specified node as root.
 
Method Summary
 E getRootNode()
          Returns root node.
 void insertNodesInto(E[] children, E parent, int index)
          Inserts a list of child nodes into parent node.
 void insertNodesInto(java.util.List<E> children, E parent, int index)
          Inserts a list of child nodes into parent node.
 void removeNodesFromParent(E node)
          Removes all child nodes under the specified node from tree structure.
 void removeNodesFromParent(E[] nodes)
          Removes specified nodes from tree structure.
 void removeNodesFromParent(java.util.List<E> nodes)
          Removes specified nodes from tree structure.
 void updateNode(E node)
          Forces tree node to be updated.
 void updateNodeStructure(E node)
          Forces tree node to be updated.
 void updateTree()
          Forces update of all visible node sizes and view.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebTreeModel

public WebTreeModel(E root)
Constructs tree model with a specified node as root.

Parameters:
root - TreeNode object that is the root of the tree

WebTreeModel

public WebTreeModel(E root,
                    boolean asksAllowsChildren)
Constructs tree model with a specified node as root.

Parameters:
root - TreeNode object that is the root of the tree
asksAllowsChildren - false if any node can have children, true if each node is asked to see if it can have children
Method Detail

getRootNode

public E getRootNode()
Returns root node.

Returns:
root node

insertNodesInto

public void insertNodesInto(java.util.List<E> children,
                            E parent,
                            int index)
Inserts a list of child nodes into parent node.

Parameters:
children - list of new child nodes
parent - parent node
index - insert index

insertNodesInto

public void insertNodesInto(E[] children,
                            E parent,
                            int index)
Inserts a list of child nodes into parent node.

Parameters:
children - array of new child nodes
parent - parent node
index - insert index

removeNodesFromParent

public void removeNodesFromParent(java.util.List<E> nodes)
Removes specified nodes from tree structure.

Parameters:
nodes - nodes to remove

removeNodesFromParent

public void removeNodesFromParent(E node)
Removes all child nodes under the specified node from tree structure.

Parameters:
node - node to remove childs from

removeNodesFromParent

public void removeNodesFromParent(E[] nodes)
Removes specified nodes from tree structure.

Parameters:
nodes - nodes to remove

updateNode

public void updateNode(E node)
Forces tree node to be updated.

Parameters:
node - tree node to be updated

updateNodeStructure

public void updateNodeStructure(E node)
Forces tree node to be updated.

Parameters:
node - tree node to be updated

updateTree

public void updateTree()
Forces update of all visible node sizes and view. This call might be useful if renderer changes dramatically and you have to update the whole tree.