Class IdTreeModel<T>

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.tree.TreeModel

    public class IdTreeModel<T>
    extends javax.swing.tree.DefaultTreeModel
    Tree model that allows looking up nodes per id.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​IdTreeNode<T>> nodes
      The id map (id -> node).
      • Fields inherited from class javax.swing.tree.DefaultTreeModel

        asksAllowsChildren, listenerList, root
    • Constructor Summary

      Constructors 
      Constructor Description
      IdTreeModel()
      Create a new tree model.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNode​(IdTreeNode<T> node)
      Add a new node.
      protected boolean deregisterAll​(IdTreeNode<T> node)
      Deregister a node and all its children.
      IdTreeNode<T> getNode​(java.lang.String id)
      Get a node per id.
      java.util.Map<java.lang.String,​IdTreeNode<T>> getNodes()
      Get a node per id.
      protected void registerAll​(IdTreeNode<T> node)
      Register a node and all its children.
      boolean removeNode​(IdTreeNode<T> node)
      Remove a node.
      • Methods inherited from class javax.swing.tree.DefaultTreeModel

        addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nodes

        protected java.util.Map<java.lang.String,​IdTreeNode<T>> nodes
        The id map (id -> node).
    • Constructor Detail

      • IdTreeModel

        public IdTreeModel()
        Create a new tree model.
    • Method Detail

      • addNode

        public void addNode​(IdTreeNode<T> node)
        Add a new node.
        Parameters:
        node - The node.
      • removeNode

        public boolean removeNode​(IdTreeNode<T> node)
        Remove a node.
        Parameters:
        node - The node.
      • registerAll

        protected void registerAll​(IdTreeNode<T> node)
        Register a node and all its children.
        Parameters:
        node - The node.
      • deregisterAll

        protected boolean deregisterAll​(IdTreeNode<T> node)
        Deregister a node and all its children.
        Parameters:
        node - The node.
      • getNode

        public IdTreeNode<T> getNode​(java.lang.String id)
        Get a node per id.
        Parameters:
        id - The node id.
        Returns:
        The node.
      • getNodes

        public java.util.Map<java.lang.String,​IdTreeNode<T>> getNodes()
        Get a node per id.
        Parameters:
        id - The node id.
        Returns:
        The node.