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>>
childrenfuture
The children future (result of next search).protected boolean
dirty
Flag to indicate that children were added / removed during ongoing search (->restart search).protected AsyncTreeModel
model
The tree model.protected ITreeNode
parent
The parent node.protected boolean
recurse
Flag to indicate recursive refresh.protected boolean
searching
Flag 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 void
addChild(int index, ITreeNode node)
Add a child and update the tree.void
addChild(ITreeNode node)
Add a child and update the tree.protected boolean
checkChildren(java.util.List oldcs, java.util.List newcs)
Check the children for validity.void
dispose()
Called when the node is removed or the tree is closed.boolean
equals(java.lang.Object obj)
Test if two nodes are equal.protected void
expandChildren(boolean dorecurse, java.util.List<ITreeNode> children)
java.util.List<ITreeNode>
getCachedChildren()
Get the cached children, i.e.ITreeNode
getChild(int index)
Get the given child.int
getChildCount()
Get the child count.IFuture<java.util.List<ITreeNode>>
getChildren()
Get the current children, i.e.abstract byte[]
getIcon()
Get the icon for a node.int
getIndexOfChild(ITreeNode child)
Get the index of a child.AsyncTreeModel
getModel()
Get the model.ITreeNode
getParent()
Get the parent node.abstract java.lang.String
getTooltipText()
Get tooltip text.int
hashCode()
Generate a has code.boolean
hasProperties()
True, if the node has properties that can be displayed.boolean
isLeaf()
Check if the node is a leaf.void
refresh(boolean recurse)
Refresh the node.void
removeAllChildren()
Remove all children.void
removeChild(ITreeNode node)
Remove a child and update the tree.protected abstract void
searchChildren()
Asynchronously search for children.protected void
setChildren(java.util.List<? extends ITreeNode> newchildren)
Set the children.void
setParent(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:
getChildCount
in 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:
getIndexOfChild
in 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:
getCachedChildren
in 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:
getChildren
in interfaceITreeNode
-
hasProperties
public boolean hasProperties()
True, if the node has properties that can be displayed.- Specified by:
hasProperties
in interfaceITreeNode
-
getIcon
public abstract byte[] getIcon()
Get the icon for a node.
-
getTooltipText
public abstract java.lang.String getTooltipText()
Get tooltip text.- Specified by:
getTooltipText
in 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Generate a has code.- Overrides:
hashCode
in classjava.lang.Object
-
-