jaxx.runtime.swing.navigation.tree
Class NavigationTreeNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by jaxx.runtime.swing.navigation.tree.NavigationTreeNode
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode, NavigationNode<NavigationTreeNode>

public class NavigationTreeNode
extends DefaultMutableTreeNode
implements NavigationNode<NavigationTreeNode>

Node of the NavigationTreeModel.

Each node is associated with :

To retrieve the bean from the context, there is a huge logic in the method getBean(JAXXContext).

In few words, if the jaxxContextEntryDef is defined, it means that the object is taken from the context.

Otherwise, find the first ancestor with an context entry and retrieve from here the bean.

Then go down to the initial node by applying the jxpath expressions jaxxContextEntryPath of each node on road back.

To identify easly a node, each node has a path and a fullPath (full path from root node).

To display the node we use a NavigationNodeRenderer which is in fact the DefaultMutableTreeNode.userObject, the object can be synch with the bean via the NavigationNodeRenderer.reload(Object) method.

Since:
1.7.2
Author:
chemit
See Also:
NavigationTreeModel, NavigationNodeRenderer, Serialized Form

Field Summary
protected  Object bean
          The bean associated with the node ( the value can be obtain via the method getBean(JAXXContext) or directly set via method setBean(Object).
protected  String fullPath
          The full path for the node from the rood node.
protected  Class<?> internalClass
          The type of the related bean associated with the node.
protected  JAXXContextEntryDef<?> jaxxContextEntryDef
          The context entry definition to retrieve the bean.
protected  String jaxxContextEntryPath
          The jxPath to process to obtain real bean from the data retrieve in the context.
protected  String path
          The node path.
protected  String pathSeparator
          The path separator used to build the fullPath.
protected  Class<? extends JAXXObject> uIClass
          The UI class associated with the node.
protected  Class<? extends JAXXAction> uIHandlerClass
          The UI handler class associated with the node.
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
NavigationTreeNode(String pathSeparator, String navigationPath, JAXXContextEntryDef<?> jaxxContextEntryDef, String jaxxContextEntryPath)
           
NavigationTreeNode(String pathSeparator, String navigationPath, Object jaxxContextEntryDef)
           
 
Method Summary
 void add(NavigationTreeNode node)
           
 Enumeration<? extends NavigationTreeNode> children()
           
protected  String computeJXPath(String expr, NavigationTreeNode parentNode)
           
 Object getBean()
           
 Object getBean(JAXXContext context)
          Obtain the associated bean value from context corresponding to node
 NavigationTreeNode getChild(String path)
           
 NavigationTreeNode getChildAt(int index)
           
protected  NavigationTreeNode getFirstAncestorWithDef()
           
 String getFullPath()
           
 int getIndex(NavigationTreeNode node)
           
 Class<?> getInternalClass()
           
 JAXXContextEntryDef<?> getJaxxContextEntryDef()
           
 String getJaxxContextEntryPath()
           
 String getNodePath()
           
 NavigationTreeNode getParent()
           
 NavigationTreeNode[] getPath()
           
 String getPathSeparator()
           
 NavigationTreeNode[] getPathToRoot(NavigationTreeNode aNode, int depth)
           
 NavigationNodeRenderer getRenderer()
           
 Class<? extends JAXXObject> getUIClass()
           
 Class<? extends JAXXAction> getUIHandlerClass()
           
 void insert(NavigationTreeNode child, int index)
           
 void reload(JAXXContext context)
           
 void remove(NavigationTreeNode node)
           
 void setBean(Object bean)
           
 void setInternalClass(Class<?> internalClass)
           
 void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef)
           
 void setJaxxContextEntryPath(String jaxxContextEntryPath)
           
 void setNodePath(String navigationPath)
           
 void setParent(NavigationTreeNode newParent)
           
 void setRenderer(NavigationNodeRenderer renderer)
           
 void setUIClass(Class<? extends JAXXObject> uIClass)
           
 void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass)
           
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jaxx.runtime.swing.navigation.NavigationNode
getAllowsChildren, getChildCount, getUserObject, isLeaf, isRoot, remove, removeFromParent, setUserObject
 

Field Detail

pathSeparator

protected final String pathSeparator
The path separator used to build the fullPath.

See Also:
path, fullPath

path

protected String path
The node path.

Used to build the fullPath which gives a unique identifier of the node.

See Also:
pathSeparator, fullPath

fullPath

protected String fullPath
The full path for the node from the rood node.

This path is build by appending nodes path from the root node to this node, between each path we introduce the pathSeparator.

Exemple :

 root
   $root
    `-- child1
         `-- child2
 
will given $root/child1/child2.

See Also:
pathSeparator, path

uIClass

protected Class<? extends JAXXObject> uIClass
The UI class associated with the node.

This class can be null, in that case, the AbstractNavigationModelBuilder.defaultUIClass will be used while building the model.


uIHandlerClass

protected Class<? extends JAXXAction> uIHandlerClass
The UI handler class associated with the node.

This class can be null, in that case, the AbstractNavigationModelBuilder.defaultUIHandlerClass will be used while building the model.


jaxxContextEntryDef

protected JAXXContextEntryDef<?> jaxxContextEntryDef
The context entry definition to retrieve the bean.

Note: If not set - the bean will be retrieve on a ancestor node.


jaxxContextEntryPath

protected String jaxxContextEntryPath
The jxPath to process to obtain real bean from the data retrieve in the context.

Note: If not set -no jxpath will be apply on the bean from context.


bean

protected transient Object bean
The bean associated with the node ( the value can be obtain via the method getBean(JAXXContext) or directly set via method setBean(Object).

cache of bean associated with bean to improve performance


internalClass

protected Class<?> internalClass
The type of the related bean associated with the node.

Note: This type is here to override the NodeRenderer internalClass, since we could need to override this data.

If this property is let to null, then we will use the NodeRenderer one

Constructor Detail

NavigationTreeNode

public NavigationTreeNode(String pathSeparator,
                          String navigationPath,
                          Object jaxxContextEntryDef)

NavigationTreeNode

public NavigationTreeNode(String pathSeparator,
                          String navigationPath,
                          JAXXContextEntryDef<?> jaxxContextEntryDef,
                          String jaxxContextEntryPath)
Method Detail

getRenderer

public NavigationNodeRenderer getRenderer()
Specified by:
getRenderer in interface NavigationNode<NavigationTreeNode>
Returns:
the text node renderer (store in DefaultMutableTreeNode.userObject property.

setRenderer

public void setRenderer(NavigationNodeRenderer renderer)
Specified by:
setRenderer in interface NavigationNode<NavigationTreeNode>

getPathSeparator

public String getPathSeparator()
Specified by:
getPathSeparator in interface NavigationNode<NavigationTreeNode>

getNodePath

public String getNodePath()
Specified by:
getNodePath in interface NavigationNode<NavigationTreeNode>

setNodePath

public void setNodePath(String navigationPath)
Specified by:
setNodePath in interface NavigationNode<NavigationTreeNode>

getUIClass

public Class<? extends JAXXObject> getUIClass()
Specified by:
getUIClass in interface NavigationNode<NavigationTreeNode>

setUIClass

public void setUIClass(Class<? extends JAXXObject> uIClass)
Specified by:
setUIClass in interface NavigationNode<NavigationTreeNode>

setInternalClass

public void setInternalClass(Class<?> internalClass)
Specified by:
setInternalClass in interface NavigationNode<NavigationTreeNode>

getUIHandlerClass

public Class<? extends JAXXAction> getUIHandlerClass()
Specified by:
getUIHandlerClass in interface NavigationNode<NavigationTreeNode>

setUIHandlerClass

public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass)
Specified by:
setUIHandlerClass in interface NavigationNode<NavigationTreeNode>

getJaxxContextEntryDef

public JAXXContextEntryDef<?> getJaxxContextEntryDef()
Specified by:
getJaxxContextEntryDef in interface NavigationNode<NavigationTreeNode>

setJaxxContextEntryDef

public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef)
Specified by:
setJaxxContextEntryDef in interface NavigationNode<NavigationTreeNode>

getJaxxContextEntryPath

public String getJaxxContextEntryPath()
Specified by:
getJaxxContextEntryPath in interface NavigationNode<NavigationTreeNode>

setJaxxContextEntryPath

public void setJaxxContextEntryPath(String jaxxContextEntryPath)
Specified by:
setJaxxContextEntryPath in interface NavigationNode<NavigationTreeNode>

getInternalClass

public Class<?> getInternalClass()
Specified by:
getInternalClass in interface NavigationNode<NavigationTreeNode>

getFullPath

public String getFullPath()
Specified by:
getFullPath in interface NavigationNode<NavigationTreeNode>
Returns:
the fully context path of the node from the root node to this.

getChildAt

public NavigationTreeNode getChildAt(int index)
Specified by:
getChildAt in interface TreeNode
Specified by:
getChildAt in interface NavigationNode<NavigationTreeNode>
Overrides:
getChildAt in class DefaultMutableTreeNode

getParent

public NavigationTreeNode getParent()
Specified by:
getParent in interface TreeNode
Specified by:
getParent in interface NavigationNode<NavigationTreeNode>
Overrides:
getParent in class DefaultMutableTreeNode

getChild

public NavigationTreeNode getChild(String path)
Specified by:
getChild in interface NavigationNode<NavigationTreeNode>
Parameters:
path - the name of the path to be matched in the child of this node.
Returns:
the child of this node with given path value.

getBean

public Object getBean()
Specified by:
getBean in interface NavigationNode<NavigationTreeNode>

setBean

public void setBean(Object bean)
Specified by:
setBean in interface NavigationNode<NavigationTreeNode>

reload

public void reload(JAXXContext context)
Specified by:
reload in interface NavigationNode<NavigationTreeNode>

getBean

public Object getBean(JAXXContext context)
Obtain the associated bean value from context corresponding to node

Specified by:
getBean in interface NavigationNode<NavigationTreeNode>
Parameters:
context - the context to seek
Returns:
the value associated in context with the given context path

insert

public void insert(NavigationTreeNode child,
                   int index)
Specified by:
insert in interface NavigationNode<NavigationTreeNode>

remove

public void remove(NavigationTreeNode node)
Specified by:
remove in interface NavigationNode<NavigationTreeNode>

setParent

public void setParent(NavigationTreeNode newParent)
Specified by:
setParent in interface NavigationNode<NavigationTreeNode>

getIndex

public int getIndex(NavigationTreeNode node)
Specified by:
getIndex in interface NavigationNode<NavigationTreeNode>

children

public Enumeration<? extends NavigationTreeNode> children()
Specified by:
children in interface TreeNode
Specified by:
children in interface NavigationNode<NavigationTreeNode>
Overrides:
children in class DefaultMutableTreeNode

add

public void add(NavigationTreeNode node)
Specified by:
add in interface NavigationNode<NavigationTreeNode>

getPath

public NavigationTreeNode[] getPath()
Specified by:
getPath in interface NavigationNode<NavigationTreeNode>
Overrides:
getPath in class DefaultMutableTreeNode

getPathToRoot

public NavigationTreeNode[] getPathToRoot(NavigationTreeNode aNode,
                                          int depth)
Specified by:
getPathToRoot in interface NavigationNode<NavigationTreeNode>

getFirstAncestorWithDef

protected NavigationTreeNode getFirstAncestorWithDef()
Returns:
the first ancestor with a none null jaxxContextEntryDef or null if none find..

computeJXPath

protected String computeJXPath(String expr,
                               NavigationTreeNode parentNode)


Copyright © 2008-2010 CodeLutin. All Rights Reserved.