org.PingOO.DLAI.lib.directorytree
Class DirectoryTreeModel

java.lang.Object
  |
  +--javax.swing.tree.DefaultTreeModel
        |
        +--org.PingOO.DLAI.lib.PWidget.DefaultPTreeModel
              |
              +--org.PingOO.DLAI.lib.directorytree.DirectoryTreeModel

public final class DirectoryTreeModel
extends DefaultPTreeModel

Defines the model that represents the LDAP directory.
A model is an abstract version of a tree.

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)
See Also:
DefaultPTreeModel, Serialized Form

Fields inherited from class org.PingOO.DLAI.lib.PWidget.DefaultPTreeModel
autoSort
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
DirectoryTreeModel(DirectoryComponent root)
          Creates a tree in which any node can have children.
DirectoryTreeModel(DirectoryComponent root, boolean autoSort)
          Creates a tree in which any node can have children.
 
Method Summary
 DirectoryComponent getComponentForDN(java.lang.String dn)
          Get a component that has the same DN (distinguished name).
static DirectoryComponent getComponentForDN(java.lang.String dn, DirectoryNode node, boolean recursiveSearch)
          Get a component that has the same DN (distinguished name).
 javax.swing.tree.TreePath getTreePathforComponent(DirectoryComponent component)
          Gets a tree path from a given component.
 void insertNodeInto(javax.swing.tree.MutableTreeNode newChild, javax.swing.tree.MutableTreeNode parent)
          Invoked this to insert newChild in parents children.
 void insertNodeInto(javax.swing.tree.MutableTreeNode newChild, javax.swing.tree.MutableTreeNode parent, int index, boolean doSort)
          Invoked this to insert newChild at location index in parents children.
 void sortNode(javax.swing.tree.DefaultMutableTreeNode node)
          Sort one level under a givent node.
 void sortTree(javax.swing.tree.DefaultMutableTreeNode node)
          Sort the whole tree.
 
Methods inherited from class org.PingOO.DLAI.lib.PWidget.DefaultPTreeModel
insertNodeInto, setAutoSort, setAutoSort, sortTree
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getPathToRoot, getPathToRoot, getRoot, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, readObject, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged, writeObject
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

DirectoryTreeModel

public DirectoryTreeModel(DirectoryComponent root)
Creates a tree in which any node can have children.
Parameters:
root - A directory node object that is the root of the tree

DirectoryTreeModel

public DirectoryTreeModel(DirectoryComponent root,
                          boolean autoSort)
Creates a tree in which any node can have children.
Parameters:
root - A directory node object that is the root of the tree
autoSort - If true sort the node when modifying the model.
Method Detail

insertNodeInto

public void insertNodeInto(javax.swing.tree.MutableTreeNode newChild,
                           javax.swing.tree.MutableTreeNode parent)
Invoked this to insert newChild in parents children.
This will then message nodesWereInserted to create the appropriate event.
This is the preferred way to add children as it will create the appropriate event.
Parameters:
newChild - The new node to add.
parent - The node where to add the child.
Overrides:
insertNodeInto in class DefaultPTreeModel

insertNodeInto

public void insertNodeInto(javax.swing.tree.MutableTreeNode newChild,
                           javax.swing.tree.MutableTreeNode parent,
                           int index,
                           boolean doSort)
Invoked this to insert newChild at location index in parents children.
This will then message nodesWereInserted to create the appropriate event.
This is the preferred way to add children as it will create the appropriate event.
Parameters:
newChild - The new node to add.
parent - The node where to add the child.
index - The index were to add the node.
doSort - If true the sorting will occur.
Overrides:
insertNodeInto in class DefaultPTreeModel

sortTree

public final void sortTree(javax.swing.tree.DefaultMutableTreeNode node)
Sort the whole tree.
Parameters:
node - The root node of the tree.
Overrides:
sortTree in class DefaultPTreeModel

sortNode

public final void sortNode(javax.swing.tree.DefaultMutableTreeNode node)
Sort one level under a givent node.
Parameters:
node - The node to sort.
Overrides:
sortNode in class DefaultPTreeModel

getTreePathforComponent

public javax.swing.tree.TreePath getTreePathforComponent(DirectoryComponent component)
Gets a tree path from a given component.
Parameters:
component - The component from which the path is required.

getComponentForDN

public DirectoryComponent getComponentForDN(java.lang.String dn)
Get a component that has the same DN (distinguished name).
Parameters:
dn - The dn used to retreive the researched component.
Returns:
The desired component or null if the component was not found or if it does not belong to this tree.

getComponentForDN

public static DirectoryComponent getComponentForDN(java.lang.String dn,
                                                   DirectoryNode node,
                                                   boolean recursiveSearch)
Get a component that has the same DN (distinguished name).
Parameters:
dn - The dn used to retreive the researched component.
node - The root node of the search.
recursiveSearch - If true allows a recursive search.
Returns:
The desired component or null if the component was not found or if it does not belong to this tree.