JIDE 3.5.15

com.jidesoft.tree
Class AbstractTreeModel

java.lang.Object
  extended by com.jidesoft.tree.AbstractTreeModel
All Implemented Interfaces:
TreeModel
Direct Known Subclasses:
DefaultTreeModelWrapper

public abstract class AbstractTreeModel
extends Object
implements TreeModel

This abstract class provides default implementations for some of the methods in the TreeModel interface. It takes care of the management of listeners and provides some conveniences for generating TreeModelEvents and dispatching them to the listeners.

Author:
Santhosh Kumar T

Field Summary
protected  EventListenerList listenerList
           
 
Constructor Summary
AbstractTreeModel()
           
 
Method Summary
 void addTreeModelListener(TreeModelListener l)
           
protected  void fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children)
          Fires events to notify the parties who listener to TreeModelEvent about tree nodes are changed.
protected  void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children)
          Fires events to notify the parties who listener to TreeModelEvent about tree nodes are inserted.
protected  void fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children)
          Fires events to notify the parties who listener to TreeModelEvent about tree nodes are removed.
protected  void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children)
          Fires events to notify the parties who listener to TreeModelEvent about tree structure changed.
protected  void fireTreeStructureChanged(Object source, TreePath path)
           
 TreeNode[] getPathToRoot(TreeNode aNode)
          Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.
protected  TreeNode[] getPathToRoot(TreeNode aNode, int depth)
          Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.
 TreeModelListener[] getTreeModelListeners()
           
 void nodeChanged(TreeNode node)
          Invoke this method after you've changed how node is to be represented in the tree.
 void nodesChanged(TreeNode node, int[] childIndices)
          Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.
 void removeTreeModelListener(TreeModelListener l)
           
 void valueForPathChanged(TreePath path, Object newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.tree.TreeModel
getChild, getChildCount, getIndexOfChild, getRoot, isLeaf
 

Field Detail

listenerList

protected EventListenerList listenerList
Constructor Detail

AbstractTreeModel

public AbstractTreeModel()
Method Detail

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Specified by:
valueForPathChanged in interface TreeModel

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Specified by:
addTreeModelListener in interface TreeModel

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Specified by:
removeTreeModelListener in interface TreeModel

getTreeModelListeners

public TreeModelListener[] getTreeModelListeners()

nodeChanged

public void nodeChanged(TreeNode node)
Invoke this method after you've changed how node is to be represented in the tree.

Parameters:
node - the changing tree node

nodesChanged

public void nodesChanged(TreeNode node,
                         int[] childIndices)
Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.

Parameters:
node - the changing tree node
childIndices - the changing child indices

getPathToRoot

public TreeNode[] getPathToRoot(TreeNode aNode)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree.

Parameters:
aNode - the TreeNode to get the path for
Returns:
the path to the root.

getPathToRoot

protected TreeNode[] getPathToRoot(TreeNode aNode,
                                   int depth)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree.

Parameters:
aNode - the TreeNode to get the path for
depth - an int giving the number of steps already taken towards the root (on recursive calls), used to size the returned array
Returns:
an array of TreeNodes giving the path from the root to the specified node

fireTreeNodesChanged

protected void fireTreeNodesChanged(Object source,
                                    Object[] path,
                                    int[] childIndices,
                                    Object[] children)
Fires events to notify the parties who listener to TreeModelEvent about tree nodes are changed.

Parameters:
source - the Object responsible for generating the event (typically the creator of the event object passes this for its value)
path - an array of Object identifying the path to the parent of the modified item(s), where the first element of the array is the Object stored at the root node and the last element is the Object stored at the parent node
childIndices - an array of int that specifies the index values of the changed items. The indices must be in sorted order, from lowest to highest
children - an array of Object containing the inserted, removed, or changed objects

fireTreeNodesInserted

protected void fireTreeNodesInserted(Object source,
                                     Object[] path,
                                     int[] childIndices,
                                     Object[] children)
Fires events to notify the parties who listener to TreeModelEvent about tree nodes are inserted.

Parameters:
source - the Object responsible for generating the event (typically the creator of the event object passes this for its value)
path - an array of Object identifying the path to the parent of the modified item(s), where the first element of the array is the Object stored at the root node and the last element is the Object stored at the parent node
childIndices - an array of int that specifies the index values of the inserted items. The indices must be in sorted order, from lowest to highest
children - an array of Object containing the inserted, removed, or changed objects

fireTreeNodesRemoved

protected void fireTreeNodesRemoved(Object source,
                                    Object[] path,
                                    int[] childIndices,
                                    Object[] children)
Fires events to notify the parties who listener to TreeModelEvent about tree nodes are removed.

Parameters:
source - the Object responsible for generating the event (typically the creator of the event object passes this for its value)
path - an array of Object identifying the path to the parent of the modified item(s), where the first element of the array is the Object stored at the root node and the last element is the Object stored at the parent node
childIndices - an array of int that specifies the index values of the removed items. The indices must be in sorted order, from lowest to highest
children - an array of Object containing the inserted, removed, or changed objects

fireTreeStructureChanged

protected void fireTreeStructureChanged(Object source,
                                        Object[] path,
                                        int[] childIndices,
                                        Object[] children)
Fires events to notify the parties who listener to TreeModelEvent about tree structure changed.

Parameters:
source - the Object responsible for generating the event (typically the creator of the event object passes this for its value)
path - an array of Object identifying the path to the parent of the modified item(s), where the first element of the array is the Object stored at the root node and the last element is the Object stored at the parent node
childIndices - an array of int that specifies the index values of the changed items. The indices must be in sorted order, from lowest to highest
children - an array of Object containing the inserted, removed, or changed objects

fireTreeStructureChanged

protected void fireTreeStructureChanged(Object source,
                                        TreePath path)

JIDE 3.5.15