Package docking.widgets.tree
Class GTreeLazyNode
- java.lang.Object
-
- docking.widgets.tree.AbstractGTreeNode
-
- docking.widgets.tree.GTreeLazyNode
-
- All Implemented Interfaces:
GTreeNode,java.lang.Comparable<GTreeNode>,java.lang.Iterable<GTreeNode>
- Direct Known Subclasses:
DomainFolderNode
public abstract class GTreeLazyNode extends AbstractGTreeNode
Base class for GTNodes that want to use a lazy loading approach. By using lazy nodes, you don't have to create all the nodes up front and the nodes will only be created as needed. If you extend this base class, you have to implement one additional method than if you extended AbstractGTreeNode and that is generateChildren(). The generateChildren() method will be called automatically when needed.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class docking.widgets.tree.AbstractGTreeNode
AbstractGTreeNode.AllPathsIterator
-
-
Constructor Summary
Constructors Constructor Description GTreeLazyNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddNode(int index, GTreeNode node)Adds the given node at the given index as a child to this node.voiddispose()Disposes this node and all of its descendants.protected voiddoAddNode(int index, GTreeNode child)protected java.util.List<GTreeNode>doGetActiveChildren()protected intdoGetAllChildCount()protected java.util.List<GTreeNode>doGetAllChildren()protected GTreeNodedoGetChild(int index)protected intdoGetChildCount()protected intdoGetIndexOfChild(GTreeNode node)protected intdoGetIndexOfChild(GTreeNode node, java.util.List<GTreeNode> children)Subclasses can override this method to perform faster lookups of a node; for example, if the subclass has a sorted list of children, then a binary search can be used.protected voiddoResetActiveChildren()Convenience method to clear any filtered items by restoring the active children of this node to be the complete set of children.protected voiddoSetActiveChildren(java.util.List<GTreeNode> childList)protected voiddoSetChildren(java.util.List<GTreeNode> childList, boolean notify)voidfireNodeChanged(GTreeNode parentNode, GTreeNode node)Notifies the tree that a node has changed.voidfireNodeStructureChanged(GTreeNode node)Notifies the tree that the node has different children.protected abstract java.util.List<GTreeNode>generateChildren()java.util.List<GTreeNode>getAllChildrenIfLoaded()A convenience method to return this node's children if they are loaded; an empty list if they are not loaded.GTreeNodegetParent()Returns the parent of this node.protected booleanisChildrenLoaded()booleanisChildrenLoadedOrInProgress()booleanisInProgress()Returns true if this node is currently being modified.protected voidloadChildren()This will be called when it is time to load children.voidremoveNode(GTreeNode node)Remove the given node from this node.protected voidsetInProgress()protected voidswingSetChildren(java.util.List<GTreeNode> childList, boolean notify, boolean onlyIfInProgress)-
Methods inherited from class docking.widgets.tree.AbstractGTreeNode
addNode, allPaths, clearFilter, compareTo, filter, getAllChildCount, getAllChildren, getChild, getChild, getChildCount, getChildren, getFilter, getIndexInParent, getIndexOfChild, getLeafCount, getNodeCount, getRoot, getTree, getTreePath, hashCode, isAncestor, isEditable, isFilteredOut, iterator, removeAll, setChildren, toString, valueChanged
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface docking.widgets.tree.GTreeNode
getIcon, getName, getToolTip, isLeaf
-
-
-
-
Method Detail
-
generateChildren
protected abstract java.util.List<GTreeNode> generateChildren()
-
loadChildren
protected final void loadChildren()
Description copied from class:AbstractGTreeNodeThis will be called when it is time to load children. Some subclasses may not use this method, but may instead have children externally added.- Overrides:
loadChildrenin classAbstractGTreeNode
-
addNode
public void addNode(int index, GTreeNode node)Description copied from interface:GTreeNodeAdds the given node at the given index as a child to this node.- Specified by:
addNodein interfaceGTreeNode- Overrides:
addNodein classAbstractGTreeNode- Parameters:
index- the index to place the node.node- the node to add as a child of this node.
-
getAllChildrenIfLoaded
public java.util.List<GTreeNode> getAllChildrenIfLoaded()
A convenience method to return this node's children if they are loaded; an empty list if they are not loaded. This allows clients that don't care either way to use the list returned here without checking for null.- Returns:
- the loaded children
-
getParent
public GTreeNode getParent()
Description copied from interface:GTreeNodeReturns the parent of this node.
-
dispose
public void dispose()
Description copied from interface:GTreeNodeDisposes this node and all of its descendants.
-
isInProgress
public boolean isInProgress()
Description copied from interface:GTreeNodeReturns true if this node is currently being modified.- Specified by:
isInProgressin interfaceGTreeNode- Returns:
- true if this node is currently being modified.
-
setInProgress
protected void setInProgress()
-
isChildrenLoadedOrInProgress
public boolean isChildrenLoadedOrInProgress()
-
isChildrenLoaded
protected boolean isChildrenLoaded()
-
doGetChildCount
protected int doGetChildCount()
-
doGetAllChildCount
protected int doGetAllChildCount()
-
doGetAllChildren
protected java.util.List<GTreeNode> doGetAllChildren()
-
doGetActiveChildren
protected java.util.List<GTreeNode> doGetActiveChildren()
-
doGetChild
protected GTreeNode doGetChild(int index)
-
doGetIndexOfChild
protected int doGetIndexOfChild(GTreeNode node)
-
doGetIndexOfChild
protected int doGetIndexOfChild(GTreeNode node, java.util.List<GTreeNode> children)
Subclasses can override this method to perform faster lookups of a node; for example, if the subclass has a sorted list of children, then a binary search can be used.- Parameters:
node- the node whose index we seekchildren- the children who contain the given node (may be null)- Returns:
- the index of the given child in the given list
-
doAddNode
protected void doAddNode(int index, GTreeNode child)
-
removeNode
public void removeNode(GTreeNode node)
Description copied from interface:GTreeNodeRemove the given node from this node.- Specified by:
removeNodein interfaceGTreeNode- Parameters:
node- the to be removed.
-
doSetChildren
protected void doSetChildren(java.util.List<GTreeNode> childList, boolean notify)
-
swingSetChildren
protected void swingSetChildren(java.util.List<GTreeNode> childList, boolean notify, boolean onlyIfInProgress)
-
doSetActiveChildren
protected void doSetActiveChildren(java.util.List<GTreeNode> childList)
-
doResetActiveChildren
protected void doResetActiveChildren()
Convenience method to clear any filtered items by restoring the active children of this node to be the complete set of children.
-
fireNodeChanged
public void fireNodeChanged(GTreeNode parentNode, GTreeNode node)
Description copied from interface:GTreeNodeNotifies the tree that a node has changed.- Specified by:
fireNodeChangedin interfaceGTreeNode- Parameters:
parentNode- the node that contains the node that was changed.node- the that changed.
-
fireNodeStructureChanged
public void fireNodeStructureChanged(GTreeNode node)
Description copied from interface:GTreeNodeNotifies the tree that the node has different children. This method- Specified by:
fireNodeStructureChangedin interfaceGTreeNode- Parameters:
node- the node that has changed.
-
-