Class NavTreeNode<N extends NavTreeNode<N>>

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

public class NavTreeNode<N extends NavTreeNode<N>>
extends javax.swing.tree.DefaultMutableTreeNode
implements NavNode<javax.swing.tree.DefaultTreeModel,​N>
Implementation of NavNode used to create in tree table This node extends DefaultMutableTreeNode
Since:
2.2
Author:
Tony Chemit - chemit@codelutin.com
See Also:
Serialized Form
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected NavTreeNodeChildLoador<?,​?,​N> childLoador
    Optional child loador to lazy create childs of the node.
    protected java.lang.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 java.lang.String id
    Id of the data associated with the node.
    protected java.lang.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

    Constructors
    Modifier Constructor Description
      NavTreeNode​(java.lang.Class<?> internalClass, java.lang.String id, java.lang.String context, NavTreeNodeChildLoador<?,​?,​N> childLoador)  
    protected NavTreeNode​(java.lang.String id)  
  • Method Summary

    Modifier and Type Method Description
    void add​(N node)  
    java.util.Enumeration<javax.swing.tree.TreeNode> children()  
    N findNodeById​(java.lang.String id, NavBridge<javax.swing.tree.DefaultTreeModel,​N> model, NavDataProvider provider)
    Given an id, obtain the child with matching id.
    N getChild​(java.lang.String id, NavBridge<javax.swing.tree.DefaultTreeModel,​N> bridge, NavDataProvider provider)
    Given an id, obtain the child with matching id.
    N getChildAfter​(javax.swing.tree.TreeNode aChild)  
    N getChildAt​(int index)  
    N getChildBefore​(javax.swing.tree.TreeNode aChild)  
    N getContainerNode()
    Gets the first node form this one to the root which has a none String type.
    java.lang.String getContext()  
    N getFirstChild()  
    N getFirstLeaf()  
    java.lang.String getId()  
    java.lang.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)  
    java.lang.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<javax.swing.tree.DefaultTreeModel,​N> bridge, NavDataProvider provider)
    To populate childs of the node (only when a none static node).
    void populateNode​(NavBridge<javax.swing.tree.DefaultTreeModel,​N> model, NavDataProvider provider, boolean populateChilds)
    To populate the node.
    void remove​(N node)  
    void setDirty​(boolean dirty)
    Changes the NavNode.isDirty() state.
    java.lang.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 Details

    • internalClass

      protected final java.lang.Class<?> internalClass
      Type of data associated with the node
    • context

      protected final java.lang.String context
      Optinal context to distinguish different nodes with same internalClass.
    • id

      protected final java.lang.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 Details

    • NavTreeNode

      protected NavTreeNode​(java.lang.String id)
    • NavTreeNode

      public NavTreeNode​(java.lang.Class<?> internalClass, java.lang.String id, java.lang.String context, NavTreeNodeChildLoador<?,​?,​N> childLoador)
  • Method Details

    • getId

      public java.lang.String getId()
      Specified by:
      getId in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
    • getContext

      public java.lang.String getContext()
      Specified by:
      getContext in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
    • getInternalClass

      public java.lang.Class<?> getInternalClass()
      Specified by:
      getInternalClass in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
    • isLoaded

      public boolean isLoaded()
      Specified by:
      isLoaded in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
    • isDirty

      public boolean isDirty()
      Specified by:
      isDirty in interface NavNode<javax.swing.tree.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<javax.swing.tree.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<javax.swing.tree.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<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
      Returns:
      the first concrete node type
    • findNodeById

      public N findNodeById​(java.lang.String id, NavBridge<javax.swing.tree.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<javax.swing.tree.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​(java.lang.String id, NavBridge<javax.swing.tree.DefaultTreeModel,​N> bridge, 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<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
      Parameters:
      id - the id of the researched node
      bridge - model owner of nodes
      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<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
      Parameters:
      dirty - the new dirty value
    • isLeaf

      public boolean isLeaf()
      Specified by:
      isLeaf in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
      Specified by:
      isLeaf in interface javax.swing.tree.TreeNode
      Overrides:
      isLeaf in class javax.swing.tree.DefaultMutableTreeNode
    • getUserObject

      public java.lang.Object getUserObject()
      Specified by:
      getUserObject in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
      Overrides:
      getUserObject in class javax.swing.tree.DefaultMutableTreeNode
    • toString

      public java.lang.String toString()
      Specified by:
      toString in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
      Overrides:
      toString in class javax.swing.tree.DefaultMutableTreeNode
    • populateNode

      public void populateNode​(NavBridge<javax.swing.tree.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<javax.swing.tree.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<javax.swing.tree.DefaultTreeModel,​N> bridge, 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<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
      Parameters:
      bridge - model owner of the node
      provider - data provider
    • getParent

      public N getParent()
      Specified by:
      getParent in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
      Specified by:
      getParent in interface javax.swing.tree.TreeNode
      Overrides:
      getParent in class javax.swing.tree.DefaultMutableTreeNode
    • getRoot

      public N getRoot()
      Overrides:
      getRoot in class javax.swing.tree.DefaultMutableTreeNode
    • getFirstChild

      public N getFirstChild()
      Overrides:
      getFirstChild in class javax.swing.tree.DefaultMutableTreeNode
    • getLastChild

      public N getLastChild()
      Overrides:
      getLastChild in class javax.swing.tree.DefaultMutableTreeNode
    • getChildAfter

      public N getChildAfter​(javax.swing.tree.TreeNode aChild)
      Overrides:
      getChildAfter in class javax.swing.tree.DefaultMutableTreeNode
    • getChildBefore

      public N getChildBefore​(javax.swing.tree.TreeNode aChild)
      Overrides:
      getChildBefore in class javax.swing.tree.DefaultMutableTreeNode
    • getNextSibling

      public N getNextSibling()
      Overrides:
      getNextSibling in class javax.swing.tree.DefaultMutableTreeNode
    • getPreviousSibling

      public N getPreviousSibling()
      Overrides:
      getPreviousSibling in class javax.swing.tree.DefaultMutableTreeNode
    • getFirstLeaf

      public N getFirstLeaf()
      Overrides:
      getFirstLeaf in class javax.swing.tree.DefaultMutableTreeNode
    • getLastLeaf

      public N getLastLeaf()
      Overrides:
      getLastLeaf in class javax.swing.tree.DefaultMutableTreeNode
    • getNextLeaf

      public N getNextLeaf()
      Overrides:
      getNextLeaf in class javax.swing.tree.DefaultMutableTreeNode
    • getPreviousLeaf

      public N getPreviousLeaf()
      Overrides:
      getPreviousLeaf in class javax.swing.tree.DefaultMutableTreeNode
    • getNextNode

      public N getNextNode()
      Overrides:
      getNextNode in class javax.swing.tree.DefaultMutableTreeNode
    • getPreviousNode

      public N getPreviousNode()
      Overrides:
      getPreviousNode in class javax.swing.tree.DefaultMutableTreeNode
    • getSharedAncestor

      public N getSharedAncestor​(N aNode)
    • getChildAt

      public N getChildAt​(int index)
      Specified by:
      getChildAt in interface javax.swing.tree.TreeNode
      Overrides:
      getChildAt in class javax.swing.tree.DefaultMutableTreeNode
    • children

      public java.util.Enumeration<javax.swing.tree.TreeNode> children()
      Specified by:
      children in interface javax.swing.tree.TreeNode
      Overrides:
      children in class javax.swing.tree.DefaultMutableTreeNode
    • add

      public void add​(N node)
      Specified by:
      add in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
    • remove

      public void remove​(N node)
      Specified by:
      remove in interface NavNode<javax.swing.tree.DefaultTreeModel,​N extends NavTreeNode<N>>
    • insert

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