Package jadex.base.gui.asynctree
Class AbstractTreeNode
- java.lang.Object
-
- jadex.base.gui.asynctree.AbstractTreeNode
-
- All Implemented Interfaces:
ITreeNode
- Direct Known Subclasses:
AbstractSwingTreeNode
public abstract class AbstractTreeNode extends java.lang.Object implements ITreeNode
Basic node object.
-
-
Field Summary
Fields Modifier and Type Field Description protected Future<java.util.List<ITreeNode>>childrenfutureThe children future (result of next search).protected booleandirtyFlag to indicate that children were added / removed during ongoing search (->restart search).protected AsyncTreeModelmodelThe tree model.protected ITreeNodeparentThe parent node.protected booleanrecurseFlag to indicate recursive refresh.protected booleansearchingFlag to indicate search in progress.
-
Constructor Summary
Constructors Constructor Description AbstractTreeNode(ITreeNode parent, AsyncTreeModel model)Create a node.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChild(int index, ITreeNode node)Add a child and update the tree.voidaddChild(ITreeNode node)Add a child and update the tree.protected booleancheckChildren(java.util.List oldcs, java.util.List newcs)Check the children for validity.voiddispose()Called when the node is removed or the tree is closed.booleanequals(java.lang.Object obj)Test if two nodes are equal.protected voidexpandChildren(boolean dorecurse, java.util.List<ITreeNode> children)java.util.List<ITreeNode>getCachedChildren()Get the cached children, i.e. do not start any background processes for updating the children.ITreeNodegetChild(int index)Get the given child.intgetChildCount()Get the child count.IFuture<java.util.List<ITreeNode>>getChildren()Get the current children, i.e. start a new update process and provide the result as a future.abstract byte[]getIcon()Get the icon for a node.intgetIndexOfChild(ITreeNode child)Get the index of a child.AsyncTreeModelgetModel()Get the model.ITreeNodegetParent()Get the parent node.abstract java.lang.StringgetTooltipText()Get tooltip text.inthashCode()Generate a has code.booleanhasProperties()True, if the node has properties that can be displayed.booleanisLeaf()Check if the node is a leaf.voidrefresh(boolean recurse)Refresh the node.voidremoveAllChildren()Remove all children.voidremoveChild(ITreeNode node)Remove a child and update the tree.protected abstract voidsearchChildren()Asynchronously search for children.protected voidsetChildren(java.util.List<? extends ITreeNode> newchildren)Set the children.voidsetParent(ITreeNode parent)The dirty to set.
-
-
-
Field Detail
-
parent
protected ITreeNode parent
The parent node.
-
model
protected final AsyncTreeModel model
The tree model.
-
searching
protected boolean searching
Flag to indicate search in progress.
-
recurse
protected boolean recurse
Flag to indicate recursive refresh.
-
dirty
protected boolean dirty
Flag to indicate that children were added / removed during ongoing search (->restart search).
-
-
Constructor Detail
-
AbstractTreeNode
public AbstractTreeNode(ITreeNode parent, AsyncTreeModel model)
Create a node.
-
-
Method Detail
-
dispose
public void dispose()
Called when the node is removed or the tree is closed.
-
getParent
public ITreeNode getParent()
Get the parent node.
-
setParent
public void setParent(ITreeNode parent)
The dirty to set.- Parameters:
dirty- The dirty to set
-
getChildCount
public int getChildCount()
Get the child count.- Specified by:
getChildCountin interfaceITreeNode
-
getChild
public ITreeNode getChild(int index)
Get the given child.
-
getIndexOfChild
public int getIndexOfChild(ITreeNode child)
Get the index of a child.- Specified by:
getIndexOfChildin interfaceITreeNode
-
isLeaf
public boolean isLeaf()
Check if the node is a leaf.
-
refresh
public void refresh(boolean recurse)
Refresh the node.
-
getCachedChildren
public java.util.List<ITreeNode> getCachedChildren()
Get the cached children, i.e. do not start any background processes for updating the children.- Specified by:
getCachedChildrenin interfaceITreeNode
-
getChildren
public IFuture<java.util.List<ITreeNode>> getChildren()
Get the current children, i.e. start a new update process and provide the result as a future.- Specified by:
getChildrenin interfaceITreeNode
-
hasProperties
public boolean hasProperties()
True, if the node has properties that can be displayed.- Specified by:
hasPropertiesin interfaceITreeNode
-
getIcon
public abstract byte[] getIcon()
Get the icon for a node.
-
getTooltipText
public abstract java.lang.String getTooltipText()
Get tooltip text.- Specified by:
getTooltipTextin interfaceITreeNode
-
searchChildren
protected abstract void searchChildren()
Asynchronously search for children. Called once for each node. Should call setChildren() once children are found.
-
setChildren
protected void setChildren(java.util.List<? extends ITreeNode> newchildren)
Set the children. No children should be represented as empty list to avoid ongoing search for children.
-
expandChildren
protected void expandChildren(boolean dorecurse, java.util.List<ITreeNode> children)
-
checkChildren
protected boolean checkChildren(java.util.List oldcs, java.util.List newcs)Check the children for validity. I.e. it is not allowed to have two equal children in the list or to alter the ordering of existing children.
-
getModel
public AsyncTreeModel getModel()
Get the model.
-
addChild
public void addChild(int index, ITreeNode node)Add a child and update the tree. Must be called from swing thread.
-
addChild
public void addChild(ITreeNode node)
Add a child and update the tree.
-
removeChild
public void removeChild(ITreeNode node)
Remove a child and update the tree.
-
removeAllChildren
public void removeAllChildren()
Remove all children.
-
equals
public boolean equals(java.lang.Object obj)
Test if two nodes are equal.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Generate a has code.- Overrides:
hashCodein classjava.lang.Object
-
-