Package docking.widgets.tree

# Class GTreeLazyNode

java.lang.Object
docking.widgets.tree.GTreeNode
docking.widgets.tree.GTreeLazyNode

All Implemented Interfaces:
  `Cloneable`, `Comparable<GTreeNode>`

Direct Known Subclasses:
  `DomainFolderNode`, `GTreeSlowLoadingNode`

public abstract class GTreeLazyNode extends GTreeNode
Base class for GTreeNodes that populate their children on demand (typically when expanded). Also, children of this node can be unloaded by calling `unloadChildren()`. This can be used by nodes in large trees to save memory by unloading children that are no longer in the current tree view (collapsed). Of course, that decision would need to be balanced against the extra time to reload the nodes in the event that a filter is applied. Also, if some external event occurs that changes the set of children for a GTreeLazyNode, you can call `unloadChildren()` to clear any previously loaded children.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GTreeLazyNode()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addNode(int index, GTreeNode node)`
  Adds the given node at the given index as a child to this node
  `void`
  `addNode(GTreeNode node)`
  Adds the given node as a child to this node.
  `void`
  `addNodes(List<GTreeNode> nodes)`
  Adds the given nodes as children to this node
  `protected final List<GTreeNode>`
  `children()`
  `GTreeNode`
  `clone()`
  Creates a clone of this node.
  `void`
  `dispose()`
  `protected void`
  `doAddNode(int index, GTreeNode node)`
  Adds a node to this node's children at the given index and notifies the tree.
  `protected void`
  `doAddNode(GTreeNode node)`
  Adds a node to this node's children.
  `protected void`
  `doAddNodes(List<GTreeNode> nodes)`
  Adds the given nodes to this node's children.
  `protected void`
  `doFireNodeAdded(GTreeNode newNode)`
  `protected void`
  `doFireNodeChanged()`
  `protected void`
  `doFireNodeRemoved(GTreeNode removedNode, int index)`
  `protected void`
  `doFireNodeStructureChanged()`
  `protected void`
  `doRemoveNode(GTreeNode node)`
  Removes the node from this node's children and notifies the tree.
  `protected void`
  `doSetChildren(List<GTreeNode> childList)`
  Sets the children of this node to the given list of child nodes, but does not notify the tree.
  `protected void`
  `doSetChildrenAndFireEvent(List<GTreeNode> childList)`
  Sets the children of this node to the given list of child nodes and fires the appropriate tree event to kick the tree to update the display.
  `protected abstract List<GTreeNode>`
  `generateChildren()`
  Subclasses must be able to generate their children nodes on demand by implementing this method.
  `final GTreeNode`
  `getParent()`
  Returns the parent of this node.
  `GTree`
  `getTree()`
  Returns the GTree that this node is attached to
  `final boolean`
  `isInProgress()`
  Returns true if the node is in the process of loading its children.
  `boolean`
  `isLoaded()`
  True if the children for this node have been loaded yet.
  `final boolean`
  `isRoot()`
  Returns true if this is a root node of a GTree
  `void`
  `removeAll()`
  Removes all children from this node.
  `void`
  `removeNode(GTreeNode node)`
  Remove the given node from this node
  `void`
  `unloadChildren()`
  Sets this lazy node back to the "unloaded" state such that if its children are accessed, it will reload its children as needed.

  ### Methods inherited from class docking.widgets.tree.GTreeNode

  `collapse, compareTo, equals, expand, filter, fireNodeChanged, fireNodeStructureChanged, getChild, getChild, getChild, getChildCount, getChildren, getDisplayText, getIcon, getIndexInParent, getIndexOfChild, getLeafCount, getName, getNodeCount, getRoot, getToolTip, getTreePath, hashCode, isAncestor, isAutoExpandPermitted, isEditable, isExpanded, isLeaf, iterator, loadAll, setChildren, stream, toString, valueChanged`

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### GTreeLazyNode

    public GTreeLazyNode()

- ## Method Details

  - ### generateChildren

    protected abstract List<GTreeNode> generateChildren()
    Subclasses must be able to generate their children nodes on demand by implementing this method.
    Overrides:
      `generateChildren` in class `GTreeNode`
    Returns:
      the list of GTreeNodes that make up the children for this node.

  - ### unloadChildren

    public void unloadChildren()
    Sets this lazy node back to the "unloaded" state such that if its children are accessed, it will reload its children as needed.

  - ### addNode

    public void addNode(GTreeNode node)
    Description copied from class: `GTreeNode`
    Adds the given node as a child to this node. Note: this method may be inefficient so if you have many nodes to add, you should use either `GTreeNode.addNodes(List)` or `GTreeNode.setChildren(List)`
    Overrides:
      `addNode` in class `GTreeNode`
    Parameters:
      `node` - the node to add as a child

  - ### addNode

    public void addNode(int index, GTreeNode node)
    Description copied from class: `GTreeNode`
    Adds the given node at the given index as a child to this node
    Overrides:
      `addNode` in class `GTreeNode`
    Parameters:
      `index` - the index to place the node
      `node` - the node to add as a child of this node

  - ### addNodes

    public void addNodes(List<GTreeNode> nodes)
    Description copied from class: `GTreeNode`
    Adds the given nodes as children to this node
    Overrides:
      `addNodes` in class `GTreeNode`
    Parameters:
      `nodes` - the nodes to add

  - ### removeAll

    public void removeAll()
    Description copied from class: `GTreeNode`
    Removes all children from this node. The children nodes will be disposed.
    Overrides:
      `removeAll` in class `GTreeNode`

  - ### removeNode

    public void removeNode(GTreeNode node)
    Description copied from class: `GTreeNode`
    Remove the given node from this node
    Overrides:
      `removeNode` in class `GTreeNode`
    Parameters:
      `node` - the to be removed

  - ### getParent

    public final GTreeNode getParent()
    Returns the parent of this node. Note: this method is deliberately not synchronized (See comments above)
    Returns:
      the parent of this node.

  - ### isRoot

    public final boolean isRoot()
    Returns true if this is a root node of a GTree
    Returns:
      true if this is a root node of a GTree

  - ### children

    protected final List<GTreeNode> children()

  - ### doSetChildrenAndFireEvent

    protected void doSetChildrenAndFireEvent(List<GTreeNode> childList)
    Sets the children of this node to the given list of child nodes and fires the appropriate tree event to kick the tree to update the display. Note: This method must be called from the swing thread because it will notify the underlying JTree.
    Parameters:
      `childList` - the list of child nodes to assign as children to this node
    See Also:
      - `if calling from a background thread.`

  - ### doSetChildren

    protected void doSetChildren(List<GTreeNode> childList)
    Sets the children of this node to the given list of child nodes, but does not notify the tree. This method does not have to be called from the swing thread. It is intended to be used by background threads that want to populate all or part of the tree, but wait until the bulk operations are completed before notifying the tree.
    Parameters:
      `childList` - the list of child nodes to assign as children to this node

  - ### doAddNode

    protected void doAddNode(GTreeNode node)
    Adds a node to this node's children. Must be called from the swing thread.
    Parameters:
      `node` - the node to add as a child to this node

  - ### doAddNode

    protected void doAddNode(int index, GTreeNode node)
    Adds a node to this node's children at the given index and notifies the tree. Must be called from the swing thread.
    Parameters:
      `index` - the index at which to add the new node
      `node` - the node to add as a child to this node

  - ### doRemoveNode

    protected void doRemoveNode(GTreeNode node)
    Removes the node from this node's children and notifies the tree. Must be called from the swing thread.
    Parameters:
      `node` - the node to remove

  - ### doAddNodes

    protected void doAddNodes(List<GTreeNode> nodes)
    Adds the given nodes to this node's children. Must be called from the swing thread.
    Parameters:
      `nodes` - the nodes to add to the children this node

  - ### clone

    public GTreeNode clone() throws CloneNotSupportedException
    Creates a clone of this node. The clone should contain a shallow copy of all the node's attributes except that the parent and children are null.
    Overrides:
      `clone` in class `Object`
    Returns:
      the clone of this object.
    Throws:
      `CloneNotSupportedException` - if some implementation prevents itself from being cloned.

  - ### dispose

    public void dispose()

  - ### isInProgress

    public final boolean isInProgress()
    Returns true if the node is in the process of loading its children. See `GTreeSlowLoadingNode`
    Returns:
      true if the node is in the process of loading its children.

  - ### isLoaded

    public boolean isLoaded()
    True if the children for this node have been loaded yet. Some GTree nodes are lazy in that they don't load their children until needed. Nodes that have the IN_PROGRESS node as it child is considered loaded if in the swing thread, otherwise they are considered not loaded.
    Returns:
      true if the children for this node have been loaded.

  - ### getTree

    public GTree getTree()
    Returns the GTree that this node is attached to
    Returns:
      the GTree that this node is attached to

  - ### doFireNodeAdded

    protected void doFireNodeAdded(GTreeNode newNode)

  - ### doFireNodeRemoved

    protected void doFireNodeRemoved(GTreeNode removedNode, int index)

  - ### doFireNodeStructureChanged

    protected void doFireNodeStructureChanged()

  - ### doFireNodeChanged

    protected void doFireNodeChanged()