Interface NavNode<M,​N extends NavNode<M,​N>>

  • All Superinterfaces:
    Cloneable, Serializable, TreeNode
    All Known Implementing Classes:
    NavTreeNode, NavTreeTableNode

    public interface NavNode<M,​N extends NavNode<M,​N>>
    extends Cloneable, TreeNode, Serializable
    Definition of a node with a optional childLoador to build childs of node. A node is identified by an getId() of an associated data of type getInternalClass(). Note:

    While using a childLoador, we can not know before node was loaded the exact count of his childs. As a matter of facts, real leaf nodes appears at the beginning in ui as a not leaf (there is a root handler). When node was loaded, a leaf node will be then displayed as required.

    Why NavNode is generic ?

    In a project, you should implements your own Node extending with one like this :
     class MyNode extends NavNode<MyNode> { ... }
     
    While in this class, you overrides every method with a node return type, co-variance you'll be able to use this code :
     MyNode parentNode = new MyNode();
     MyNode node = parentNode.getFirstNode();
     
    So for final application this generic type avoid any cast for your own node type, this is quite convinient. Even if in your project, you wants to have a heriarchy of nodes, this will still works (if you use a genercic type on your abstract nodes).

    Internal states

    • internalClass : the type of data associated with the node
    • context : an optinal context to distinguish different types of node with same internalclass
    • id : id of the data associated with the node
    • dirty : flag sets to true when node render MUST be recomputed
    • loaded : flag sets to true when node was loaded
    • childLoador : optional loador of childs

    Static nodes

    Some nodes do not need auto-loading, we call them static nodes. The method isStaticNode() gives this state. Note: A static node has no childLoador.

    Node loading

    Initialy node has no data child nodes, (isLoaded() equals false). when model requires node's childs, it can load them via method populateNode(NavBridge, NavDataProvider, boolean) and populateChilds(NavBridge, NavDataProvider) methods.

    Node rendering

    the AbstractNavTreeCellRenderer looks the isDirty() state to know when render should be (re-)compute and set back the state to false. Each time, a node is modified, the isDirty() should be set to true.
    Since:
    2.1
    Author:
    Tony Chemit - dev@tchemit.fr
    • Method Detail

      • getContext

        String getContext()
      • getInternalClass

        Class<?> getInternalClass()
      • isLoaded

        boolean isLoaded()
      • isDirty

        boolean isDirty()
      • isStringNode

        boolean isStringNode()
        Convinient method to known if the node is a String typed.
        Returns:
        true if the type of node if
      • isStaticNode

        boolean isStaticNode()
        To know if the node is static. A static node has no childLoador.
        Returns:
        true when the node is static : says, the node has no childLoador.
      • getContainerNode

        N getContainerNode()
        Gets the first node form this one to the root which has a none String type.
        Returns:
        the first concrete node type
      • findNodeById

        N findNodeById​(String id,
                       NavBridge<M,​N> bridge,
                       NavDataProvider provider)
        Given an id, obtain the child with matching id. If node is NOT loaded, then first loads it (method populateChilds(NavBridge, NavDataProvider)) then do search on direct childs of the node recursivly.
        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
      • getChild

        N getChild​(String id,
                   NavBridge<M,​N> bridge,
                   NavDataProvider provider)
        Given an id, obtain the child with matching id. If node is NOT loaded, then first loads it (method populateChilds(NavBridge, NavDataProvider)) then return on direct childs of the node.
        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

        void setDirty​(boolean dirty)
        Changes the isDirty() state. As a side effect, when a renderer will use this node, it will force to reload the render from the NavDataProvider.
        Parameters:
        dirty - the new dirty value
      • isLeaf

        boolean isLeaf()
        Specified by:
        isLeaf in interface TreeNode
      • getUserObject

        Object getUserObject()
      • populateNode

        void populateNode​(NavBridge<M,​N> bridge,
                          NavDataProvider provider,
                          boolean populateChilds)
        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.
        Parameters:
        bridge - 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

        void populateChilds​(NavBridge<M,​N> bridge,
                            NavDataProvider provider)
        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.
        Parameters:
        bridge - model owner of the node
        provider - data provider
      • isRoot

        boolean isRoot()
      • add

        void add​(N node)
      • remove

        void remove​(N node)
      • insert

        void insert​(N node,
                    int position)