jaxx.runtime.swing.nav.tree
Class NavTreeNode<N extends NavTreeNode<N>>

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by jaxx.runtime.swing.nav.tree.NavTreeNode<N>
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode, NavNode<DefaultTreeModel,N>

public class NavTreeNode<N extends NavTreeNode<N>>
extends DefaultMutableTreeNode
implements NavNode<DefaultTreeModel,N>

Implementation of NavNode used to create in tree table This node extends DefaultMutableTreeNode

Since:
2.2
Author:
tchemit
See Also:
Serialized Form

Field Summary
protected  NavTreeNodeChildLoador<?,?,N> childLoador
          Optional child loador to lazy create childs of the node.
protected  String context
          Optinal context to distinguish different nodes with same internalClass.
protected  boolean dirty
          Flag to know when renderer should (re-)compute render of the node.
protected  String id
          Id of the data associated with the node.
protected  Class<?> internalClass
          Type of data associated with the node
protected  boolean loaded
          Flag to know when the none static node was loaded.
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
  NavTreeNode(Class<?> internalClass, String id, String context, NavTreeNodeChildLoador<?,?,N> childLoador)
           
protected NavTreeNode(String id)
           
 
Method Summary
 void add(N node)
           
 Enumeration<N> children()
           
 N findNodeById(String id, NavBridge<DefaultTreeModel,N> model, NavDataProvider provider)
          Given an id, obtain the child with matching id.
 N getChild(String id, NavBridge<DefaultTreeModel,N> model, NavDataProvider provider)
          Given an id, obtain the child with matching id.
 N getChildAfter(TreeNode aChild)
           
 N getChildAt(int index)
           
 N getChildBefore(TreeNode aChild)
           
 N getContainerNode()
          Gets the first node form this one to the root which has a none String type.
 String getContext()
           
 N getFirstChild()
           
 N getFirstLeaf()
           
 String getId()
           
 Class<?> getInternalClass()
           
 N getLastChild()
           
 N getLastLeaf()
           
 N getNextLeaf()
           
 N getNextNode()
           
 N getNextSibling()
           
 N getParent()
           
 N getPreviousLeaf()
           
 N getPreviousNode()
           
 N getPreviousSibling()
           
 N getRoot()
           
 N getSharedAncestor(N aNode)
           
 Object getUserObject()
           
 void insert(N node, int position)
           
 boolean isDirty()
           
 boolean isLeaf()
           
 boolean isLoaded()
           
 boolean isStaticNode()
          To know if the node is static.
 boolean isStringNode()
          Convinient method to known if the node is a String typed.
 void populateChilds(NavBridge<DefaultTreeModel,N> model, NavDataProvider provider)
          To populate childs of the node (only when a none static node).
 void populateNode(NavBridge<DefaultTreeModel,N> model, NavDataProvider provider, boolean populateChilds)
          To populate the node.
 void remove(N node)
           
 void setDirty(boolean dirty)
          Changes the NavNode.isDirty() state.
 String toString()
           
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, clone, depthFirstEnumeration, getAllowsChildren, getChildCount, getDepth, getIndex, getLeafCount, getLevel, getPath, getPathToRoot, getSharedAncestor, getSiblingCount, getUserObjectPath, insert, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jaxx.runtime.swing.nav.NavNode
isRoot
 
Methods inherited from interface javax.swing.tree.TreeNode
getAllowsChildren, getChildCount, getIndex
 

Field Detail

internalClass

protected final Class<?> internalClass
Type of data associated with the node


context

protected final String context
Optinal context to distinguish different nodes with same internalClass.


id

protected final String id
Id of the data associated with the node.


dirty

protected boolean dirty
Flag to know when renderer should (re-)compute render of the node.


loaded

protected boolean loaded
Flag to know when the none static node was loaded.


childLoador

protected final NavTreeNodeChildLoador<?,?,N extends NavTreeNode<N>> childLoador
Optional child loador to lazy create childs of the node.

Constructor Detail

NavTreeNode

protected NavTreeNode(String id)

NavTreeNode

public NavTreeNode(Class<?> internalClass,
                   String id,
                   String context,
                   NavTreeNodeChildLoador<?,?,N> childLoador)
Method Detail

getId

public String getId()
Specified by:
getId in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>

getContext

public String getContext()
Specified by:
getContext in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>

getInternalClass

public Class<?> getInternalClass()
Specified by:
getInternalClass in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>

isLoaded

public boolean isLoaded()
Specified by:
isLoaded in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>

isDirty

public boolean isDirty()
Specified by:
isDirty in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>

isStringNode

public boolean isStringNode()
Description copied from interface: NavNode
Convinient method to known if the node is a String typed.

Specified by:
isStringNode in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Returns:
true if the type of node if

isStaticNode

public boolean isStaticNode()
Description copied from interface: NavNode
To know if the node is static.

A static node has no childLoador.

Specified by:
isStaticNode in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Returns:
true when the node is static : says, the node has no childLoador.

getContainerNode

public N getContainerNode()
Description copied from interface: NavNode
Gets the first node form this one to the root which has a none String type.

Specified by:
getContainerNode in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Returns:
the first concrete node type

findNodeById

public N findNodeById(String id,
                      NavBridge<DefaultTreeModel,N> model,
                      NavDataProvider provider)
Description copied from interface: NavNode
Given an id, obtain the child with matching id.

If node is NOT loaded, then first loads it (method NavNode.populateChilds(NavBridge , NavDataProvider)) then do search on direct childs of the node recursivly.

Specified by:
findNodeById in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Parameters:
id - the id of the researched node
model - model owner of nodes
provider - data provider
Returns:
the found node or null if not found

getChild

public N getChild(String id,
                  NavBridge<DefaultTreeModel,N> model,
                  NavDataProvider provider)
Description copied from interface: NavNode
Given an id, obtain the child with matching id.

If node is NOT loaded, then first loads it (method NavNode.populateChilds(NavBridge , NavDataProvider)) then return on direct childs of the node.

Specified by:
getChild in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Parameters:
id - the id of the researched node
provider - data provider
Returns:
the found node or null if not found

setDirty

public void setDirty(boolean dirty)
Description copied from interface: NavNode
Changes the NavNode.isDirty() state.

As a side effect, when a renderer will use this node, it will force to reload the render from the NavDataProvider.

Specified by:
setDirty in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Parameters:
dirty - the new dirty value

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface TreeNode
Specified by:
isLeaf in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Overrides:
isLeaf in class DefaultMutableTreeNode

getUserObject

public Object getUserObject()
Specified by:
getUserObject in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Overrides:
getUserObject in class DefaultMutableTreeNode

toString

public String toString()
Specified by:
toString in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Overrides:
toString in class DefaultMutableTreeNode

populateNode

public void populateNode(NavBridge<DefaultTreeModel,N> model,
                         NavDataProvider provider,
                         boolean populateChilds)
Description copied from interface: NavNode
To populate the node. A side-effect of this method is to set dirty the node (renderer will recompute the render of the node).

If populateChilds is set to true, then also populate childs of the node using the given dataProvider.

Specified by:
populateNode in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Parameters:
model - le delegate modèles content le noeud
provider - le provider de données
populateChilds - un drapeau pour charger aussi les fils du noeud courant

populateChilds

public void populateChilds(NavBridge<DefaultTreeModel,N> model,
                           NavDataProvider provider)
Description copied from interface: NavNode
To populate childs of the node (only when a none static node). A side-effect of this method is to set loaded of the node.

For a static node, do nothing.

Specified by:
populateChilds in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Parameters:
model - model owner of the node
provider - data provider

getParent

public N getParent()
Specified by:
getParent in interface TreeNode
Specified by:
getParent in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>
Overrides:
getParent in class DefaultMutableTreeNode

getRoot

public N getRoot()
Overrides:
getRoot in class DefaultMutableTreeNode

getFirstChild

public N getFirstChild()
Overrides:
getFirstChild in class DefaultMutableTreeNode

getLastChild

public N getLastChild()
Overrides:
getLastChild in class DefaultMutableTreeNode

getChildAfter

public N getChildAfter(TreeNode aChild)
Overrides:
getChildAfter in class DefaultMutableTreeNode

getChildBefore

public N getChildBefore(TreeNode aChild)
Overrides:
getChildBefore in class DefaultMutableTreeNode

getNextSibling

public N getNextSibling()
Overrides:
getNextSibling in class DefaultMutableTreeNode

getPreviousSibling

public N getPreviousSibling()
Overrides:
getPreviousSibling in class DefaultMutableTreeNode

getFirstLeaf

public N getFirstLeaf()
Overrides:
getFirstLeaf in class DefaultMutableTreeNode

getLastLeaf

public N getLastLeaf()
Overrides:
getLastLeaf in class DefaultMutableTreeNode

getNextLeaf

public N getNextLeaf()
Overrides:
getNextLeaf in class DefaultMutableTreeNode

getPreviousLeaf

public N getPreviousLeaf()
Overrides:
getPreviousLeaf in class DefaultMutableTreeNode

getNextNode

public N getNextNode()
Overrides:
getNextNode in class DefaultMutableTreeNode

getPreviousNode

public N getPreviousNode()
Overrides:
getPreviousNode in class DefaultMutableTreeNode

getSharedAncestor

public N getSharedAncestor(N aNode)

getChildAt

public N getChildAt(int index)
Specified by:
getChildAt in interface TreeNode
Overrides:
getChildAt in class DefaultMutableTreeNode

children

public Enumeration<N> children()
Specified by:
children in interface TreeNode
Overrides:
children in class DefaultMutableTreeNode

add

public void add(N node)
Specified by:
add in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>

remove

public void remove(N node)
Specified by:
remove in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>

insert

public void insert(N node,
                   int position)
Specified by:
insert in interface NavNode<DefaultTreeModel,N extends NavTreeNode<N>>


Copyright © 2008-2010 CodeLutin. All Rights Reserved.