jaxx.runtime.swing.navigation
Class NavigationTreeNode

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

public class NavigationTreeNode
extends javax.swing.tree.DefaultMutableTreeNode

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 NavigationTreeNodeRenderer which is in fact the DefaultMutableTreeNode.userObject, the object can be synch with the bean via the NavigationTreeNodeRenderer.reload(java.lang.Object) method.

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

Field Summary
protected  java.lang.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  java.lang.String fullPath
          The full path for the node from the rood node.
protected  java.lang.Class<?> internalClass
          The type of the related bean associated with the node.
protected  JAXXContextEntryDef<?> jaxxContextEntryDef
          The context entry definition to retrieve the bean.
protected  java.lang.String jaxxContextEntryPath
          The jxPath to process to obtain real bean from the data retrieve in the context.
protected  java.lang.String path
          The node path.
protected  java.lang.String pathSeparator
          The path separator used to build the fullPath.
protected  java.lang.Class<? extends JAXXObject> uIClass
          The UI class associated with the node.
protected  java.lang.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(java.lang.String pathSeparator, java.lang.String navigationPath, JAXXContextEntryDef<?> jaxxContextEntryDef, java.lang.String jaxxContextEntryPath)
           
NavigationTreeNode(java.lang.String pathSeparator, java.lang.String navigationPath, java.lang.Object jaxxContextEntryDef)
           
 
Method Summary
protected  java.lang.String computeJXPath(java.lang.String expr, NavigationTreeNode parentNode)
           
 java.lang.Object getBean()
           
 java.lang.Object getBean(JAXXContext context)
          Obtain the associated bean value from context corresponding to node
 NavigationTreeNode getChild(java.lang.String path)
           
 NavigationTreeNode getChildAt(int index)
           
protected  NavigationTreeNode getFirstAncestorWithDef()
           
 java.lang.String getFullPath()
           
 java.lang.Class<?> getInternalClass()
           
 JAXXContextEntryDef<?> getJaxxContextEntryDef()
           
 java.lang.String getJaxxContextEntryPath()
           
 java.lang.String getNodePath()
           
 NavigationTreeNode getParent()
           
 java.lang.String getPathSeparator()
           
 NavigationTreeNodeRenderer getRenderer()
           
 java.lang.Class<? extends JAXXObject> getUIClass()
           
 java.lang.Class<? extends JAXXAction> getUIHandlerClass()
           
 void reload(JAXXContext context)
           
 void setBean(java.lang.Object bean)
           
 void setInternalClass(java.lang.Class<?> internalClass)
           
 void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef)
           
 void setJaxxContextEntryPath(java.lang.String jaxxContextEntryPath)
           
 void setNodePath(java.lang.String navigationPath)
           
 void setRenderer(NavigationTreeNodeRenderer renderer)
           
 void setUIClass(java.lang.Class<? extends JAXXObject> uIClass)
           
 void setUIHandlerClass(java.lang.Class<? extends JAXXAction> uIHandlerClass)
           
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getPath, 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
 

Field Detail

pathSeparator

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

See Also:
path, fullPath

path

protected java.lang.String path
The node path.

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

See Also:
pathSeparator, fullPath

fullPath

protected java.lang.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 java.lang.Class<? extends JAXXObject> uIClass
The UI class associated with the node.

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


uIHandlerClass

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

This class can be null, in that case, the NavigationTreeModelBuilder.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 java.lang.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 java.lang.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 java.lang.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(java.lang.String pathSeparator,
                          java.lang.String navigationPath,
                          java.lang.Object jaxxContextEntryDef)

NavigationTreeNode

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

getRenderer

public NavigationTreeNodeRenderer getRenderer()
Returns:
the text node renderer (store in DefaultMutableTreeNode.userObject property.

setRenderer

public void setRenderer(NavigationTreeNodeRenderer renderer)

getPathSeparator

public java.lang.String getPathSeparator()

getNodePath

public java.lang.String getNodePath()

setNodePath

public void setNodePath(java.lang.String navigationPath)

getUIClass

public java.lang.Class<? extends JAXXObject> getUIClass()

setUIClass

public void setUIClass(java.lang.Class<? extends JAXXObject> uIClass)

setInternalClass

public void setInternalClass(java.lang.Class<?> internalClass)

getUIHandlerClass

public java.lang.Class<? extends JAXXAction> getUIHandlerClass()

setUIHandlerClass

public void setUIHandlerClass(java.lang.Class<? extends JAXXAction> uIHandlerClass)

getJaxxContextEntryDef

public JAXXContextEntryDef<?> getJaxxContextEntryDef()

setJaxxContextEntryDef

public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef)

getJaxxContextEntryPath

public java.lang.String getJaxxContextEntryPath()

setJaxxContextEntryPath

public void setJaxxContextEntryPath(java.lang.String jaxxContextEntryPath)

getInternalClass

public java.lang.Class<?> getInternalClass()

getFullPath

public java.lang.String getFullPath()
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 javax.swing.tree.TreeNode
Overrides:
getChildAt in class javax.swing.tree.DefaultMutableTreeNode

getParent

public NavigationTreeNode getParent()
Specified by:
getParent in interface javax.swing.tree.TreeNode
Overrides:
getParent in class javax.swing.tree.DefaultMutableTreeNode

getChild

public NavigationTreeNode getChild(java.lang.String path)
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 java.lang.Object getBean()

setBean

public void setBean(java.lang.Object bean)

reload

public void reload(JAXXContext context)

getBean

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

Parameters:
context - the context to seek
Returns:
the value associated in context with the given context path

getFirstAncestorWithDef

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

computeJXPath

protected java.lang.String computeJXPath(java.lang.String expr,
                                         NavigationTreeNode parentNode)


Copyright © 2008-2010 CodeLutin. All Rights Reserved.