Class NavTreeNode<N extends NavTreeNode<N>>
- java.lang.Object
-
- javax.swing.tree.DefaultMutableTreeNode
-
- org.nuiton.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 ofNavNodeused to create in tree table This node extendsDefaultMutableTreeNode- Since:
- 2.2
- Author:
- Tony Chemit - dev@tchemit.fr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected NavTreeNodeChildLoador<?,?,N>childLoadorOptional child loador to lazy create childs of the node.protected StringcontextOptinal context to distinguish different nodes with sameinternalClass.protected booleandirtyFlag to know when renderer should (re-)compute render of the node.protected StringidId of the data associated with the node.protected Class<?>internalClassType of data associated with the nodeprotected booleanloadedFlag 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
Constructors Modifier Constructor Description NavTreeNode(Class<?> internalClass, String id, String context, NavTreeNodeChildLoador<?,?,N> childLoador)protectedNavTreeNode(String id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(N node)NfindNodeById(String id, NavBridge<DefaultTreeModel,N> model, NavDataProvider provider)Given anid, obtain the child with matching id.NgetChild(String id, NavBridge<DefaultTreeModel,N> bridge, NavDataProvider provider)Given anid, obtain the child with matching id.NgetChildAfter(TreeNode aChild)NgetChildAt(int index)NgetChildBefore(TreeNode aChild)NgetContainerNode()Gets the first node form this one to the root which has a noneStringtype.StringgetContext()NgetFirstChild()NgetFirstLeaf()StringgetId()Class<?>getInternalClass()NgetLastChild()NgetLastLeaf()NgetNextLeaf()NgetNextNode()NgetNextSibling()NgetParent()NgetPreviousLeaf()NgetPreviousNode()NgetPreviousSibling()NgetRoot()NgetSharedAncestor(N aNode)ObjectgetUserObject()voidinsert(N node, int position)booleanisDirty()booleanisLeaf()booleanisLoaded()booleanisStaticNode()To know if the node is static.booleanisStringNode()Convinient method to known if the node is aStringtyped.voidpopulateChilds(NavBridge<DefaultTreeModel,N> bridge, NavDataProvider provider)To populate childs of the node (only when a none static node).voidpopulateNode(NavBridge<DefaultTreeModel,N> model, NavDataProvider provider, boolean populateChilds)To populate the node.voidremove(N node)voidsetDirty(boolean dirty)Changes theNavNode.isDirty()state.StringtoString()-
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, 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 javax.swing.tree.TreeNode
children, 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 sameinternalClass.
-
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.
-
-
Method Detail
-
getId
public String getId()
- Specified by:
getIdin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>
-
getContext
public String getContext()
- Specified by:
getContextin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>
-
getInternalClass
public Class<?> getInternalClass()
- Specified by:
getInternalClassin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>
-
isLoaded
public boolean isLoaded()
- Specified by:
isLoadedin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>
-
isDirty
public boolean isDirty()
- Specified by:
isDirtyin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>
-
isStringNode
public boolean isStringNode()
Description copied from interface:NavNodeConvinient method to known if the node is aStringtyped.- Specified by:
isStringNodein interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Returns:
trueif the type of node if
-
isStaticNode
public boolean isStaticNode()
Description copied from interface:NavNodeTo know if the node is static. Astaticnode has nochildLoador.- Specified by:
isStaticNodein interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Returns:
truewhen the node is static : says, the node has nochildLoador.
-
getContainerNode
public N getContainerNode()
Description copied from interface:NavNodeGets the first node form this one to the root which has a noneStringtype.- Specified by:
getContainerNodein interfaceNavNode<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:NavNodeGiven anid, obtain the child with matching id. If node is NOTloaded, then first loads it (methodNavNode.populateChilds(NavBridge, NavDataProvider)) then do search on direct childs of the node recursivly.- Specified by:
findNodeByIdin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Parameters:
id- the id of the researched nodemodel- model owner of nodesprovider- data provider- Returns:
- the found node or
nullif not found
-
getChild
public N getChild(String id, NavBridge<DefaultTreeModel,N> bridge, NavDataProvider provider)
Description copied from interface:NavNodeGiven anid, obtain the child with matching id. If node is NOTloaded, then first loads it (methodNavNode.populateChilds(NavBridge, NavDataProvider)) then return on direct childs of the node.- Specified by:
getChildin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Parameters:
id- the id of the researched nodebridge- model owner of nodesprovider- data provider- Returns:
- the found node or
nullif not found
-
setDirty
public void setDirty(boolean dirty)
Description copied from interface:NavNodeChanges theNavNode.isDirty()state. As a side effect, when a renderer will use this node, it will force to reload the render from theNavDataProvider.- Specified by:
setDirtyin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Parameters:
dirty- the new dirty value
-
isLeaf
public boolean isLeaf()
- Specified by:
isLeafin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Specified by:
isLeafin interfaceTreeNode- Overrides:
isLeafin classDefaultMutableTreeNode
-
getUserObject
public Object getUserObject()
- Specified by:
getUserObjectin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Overrides:
getUserObjectin classDefaultMutableTreeNode
-
toString
public String toString()
- Specified by:
toStringin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Overrides:
toStringin classDefaultMutableTreeNode
-
populateNode
public void populateNode(NavBridge<DefaultTreeModel,N> model, NavDataProvider provider, boolean populateChilds)
Description copied from interface:NavNodeTo populate the node. A side-effect of this method is to setdirtythe node (renderer will recompute the render of the node). IfpopulateChildsis set totrue, then also populate childs of the node using the givendataProvider.- Specified by:
populateNodein interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Parameters:
model- le delegate modèles content le noeudprovider- le provider de donnéespopulateChilds- un drapeau pour charger aussi les fils du noeud courant
-
populateChilds
public void populateChilds(NavBridge<DefaultTreeModel,N> bridge, NavDataProvider provider)
Description copied from interface:NavNodeTo populate childs of the node (only when a none static node). A side-effect of this method is to setloadedof the node. For a static node, do nothing.- Specified by:
populateChildsin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Parameters:
bridge- model owner of the nodeprovider- data provider
-
getParent
public N getParent()
- Specified by:
getParentin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>- Specified by:
getParentin interfaceTreeNode- Overrides:
getParentin classDefaultMutableTreeNode
-
getRoot
public N getRoot()
- Overrides:
getRootin classDefaultMutableTreeNode
-
getFirstChild
public N getFirstChild()
- Overrides:
getFirstChildin classDefaultMutableTreeNode
-
getLastChild
public N getLastChild()
- Overrides:
getLastChildin classDefaultMutableTreeNode
-
getChildAfter
public N getChildAfter(TreeNode aChild)
- Overrides:
getChildAfterin classDefaultMutableTreeNode
-
getChildBefore
public N getChildBefore(TreeNode aChild)
- Overrides:
getChildBeforein classDefaultMutableTreeNode
-
getNextSibling
public N getNextSibling()
- Overrides:
getNextSiblingin classDefaultMutableTreeNode
-
getPreviousSibling
public N getPreviousSibling()
- Overrides:
getPreviousSiblingin classDefaultMutableTreeNode
-
getFirstLeaf
public N getFirstLeaf()
- Overrides:
getFirstLeafin classDefaultMutableTreeNode
-
getLastLeaf
public N getLastLeaf()
- Overrides:
getLastLeafin classDefaultMutableTreeNode
-
getNextLeaf
public N getNextLeaf()
- Overrides:
getNextLeafin classDefaultMutableTreeNode
-
getPreviousLeaf
public N getPreviousLeaf()
- Overrides:
getPreviousLeafin classDefaultMutableTreeNode
-
getNextNode
public N getNextNode()
- Overrides:
getNextNodein classDefaultMutableTreeNode
-
getPreviousNode
public N getPreviousNode()
- Overrides:
getPreviousNodein classDefaultMutableTreeNode
-
getChildAt
public N getChildAt(int index)
- Specified by:
getChildAtin interfaceTreeNode- Overrides:
getChildAtin classDefaultMutableTreeNode
-
add
public void add(N node)
- Specified by:
addin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>
-
remove
public void remove(N node)
- Specified by:
removein interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>
-
insert
public void insert(N node, int position)
- Specified by:
insertin interfaceNavNode<DefaultTreeModel,N extends NavTreeNode<N>>
-
-