com.ca.directory.jxplorer.tree
Class SmartModel

java.lang.Object
  |
  +--javax.swing.tree.DefaultTreeModel
        |
        +--com.ca.directory.jxplorer.tree.SmartModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.TreeModel

public class SmartModel
extends javax.swing.tree.DefaultTreeModel

The intention behind this class is to keep DefaultTreeModel largely unchanged, but add some utility ftns to make the task of translating between DNs and objects in the tree (SmartNodes and TreePaths).

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
SmartModel(javax.swing.tree.TreeNode root)
           
SmartModel(javax.swing.tree.TreeNode root, boolean asksAllowsChildren)
           
 
Method Summary
 DN getDNForNode(javax.swing.tree.TreeNode node)
          A conversion function - returns the current Node as a DN
 DN getDNForPath(javax.swing.tree.TreeNode[] path)
          A conversion function.
 DN getDNForPath(javax.swing.tree.TreePath path)
          A conversion function.
 SmartNode getNodeForDN(DN nodeDN)
          A conversion function.
 javax.swing.tree.TreePath getPathForDN(DN nodeDN)
          A conversion function - gets a path for a particular DN
 javax.swing.tree.TreePath getPathForNode(javax.swing.tree.TreeNode node)
          A conversion function - gets the path to given node.
protected  java.lang.String getUniqueCopyRDN(DN activeDN, DN copyDN)
          A rare condition occurs when a user tries to copy a node over an existing node with the same name.
 
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

SmartModel

public SmartModel(javax.swing.tree.TreeNode root)

SmartModel

public SmartModel(javax.swing.tree.TreeNode root,
                  boolean asksAllowsChildren)
Method Detail

getDNForPath

public DN getDNForPath(javax.swing.tree.TreePath path)
A conversion function. It takes a path and returns it as the corresponding DN.

Parameters:
path - a tree path to determine the DN for.
Returns:
the corresponding Distinguished Name

getDNForNode

public DN getDNForNode(javax.swing.tree.TreeNode node)
A conversion function - returns the current Node as a DN


getDNForPath

public DN getDNForPath(javax.swing.tree.TreeNode[] path)
A conversion function. It takes an array of tree nodes representing a path and returns it as the corresponding DN.

Parameters:
path - an array of tree nodes to convert to a DN.
Returns:
the corresponding Distinguished Name

getPathForNode

public javax.swing.tree.TreePath getPathForNode(javax.swing.tree.TreeNode node)
A conversion function - gets the path to given node.


getPathForDN

public javax.swing.tree.TreePath getPathForDN(DN nodeDN)
A conversion function - gets a path for a particular DN


getNodeForDN

public SmartNode getNodeForDN(DN nodeDN)
A conversion function. Returns the existing smart node corresponding to a DN. Returns null if the DN does not currently exist in the client tree, even if it is a valid DN on the server. (We're only searching the GUI Tree here.)

Parameters:
nodeDN - the full DN of the node to be found

getUniqueCopyRDN

protected java.lang.String getUniqueCopyRDN(DN activeDN,
                                            DN copyDN)
A rare condition occurs when a user tries to copy a node over an existing node with the same name. This ftn. emulates the behaviour of many tree editing systems by allowing the copy, but prepending 'Copy ' or 'Copy (n) of' to the name. This ftn searches the existing set of siblings to find a unique name, whether 'Copy ', or 'Copy (n) of' where n is a unique number.

Parameters:
activeDN - the DN of the node into which the new node is being copied.
copyDN - the DN of the node being copied.