Package jadex.base.gui.asynctree
Class AsyncTreeModel
- java.lang.Object
-
- jadex.base.gui.asynctree.AsyncTreeModel
-
- Direct Known Subclasses:
AsyncSwingTreeModel
public class AsyncTreeModel extends java.lang.Object
Tree model, which dynamically represents running components.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Object,ITreeNode>
added
The added nodes.protected MultiCollection<ITreeNode,ITreeNode>
changed
The changed nodes (delayed update for improving perceived speed).protected java.util.List<TreeModelListener>
listeners
The tree listeners.protected java.util.List<INodeListener>
nodelisteners
The node listeners.protected java.util.Map<java.lang.Object,ITreeNode>
nodes
The node lookup table.protected java.util.List<INodeHandler>
overlays
The icon overlays.protected ITreeNode
root
The root node.protected java.util.Map<java.lang.Object,java.lang.Integer>
zombies
The zombie node ids (id->remove counter).
-
Constructor Summary
Constructors Constructor Description AsyncTreeModel()
Create a component tree model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNode(ITreeNode node)
Add a node.void
addNodeHandler(INodeHandler overlay)
Add a node handler.void
addNodeListener(INodeListener listener)
Register a node listener.void
addTreeModelListener(TreeModelListener l)
Add a listener.void
addZombieNode(java.lang.Object id)
Add a zombie node or increase the counter.java.util.List<ITreeNode>
buildTreePath(ITreeNode node)
Build a tree path to the given node.void
deregisterNode(ITreeNode node)
Remove a node registration.void
dispose()
Called when the tree is removed.void
fireNodeAdded(ITreeNode parent, ITreeNode child, int index)
Inform listeners that a node has been addedvoid
fireNodeChanged(ITreeNode node)
Inform listeners that a node has changed.void
fireNodeRemoved(ITreeNode parent, ITreeNode child, int index)
Inform listeners that a node has been removedvoid
fireNodesRemoved(ITreeNode parent, ITreeNode[] childs, int[] indices)
Inform listeners that a node has been removedvoid
fireTreeChanged(ITreeNode node)
Inform listeners that tree has changed from given node on.ITreeNode
getAddedNode(java.lang.Object id)
Get a node by its id.ITreeNode
getChild(java.lang.Object parent, int index)
Get the given child of a node.int
getChildCount(java.lang.Object parent)
Get the number of children of a node.int
getIndexOfChild(java.lang.Object parent, java.lang.Object child)
Get the index of a child.ITreeNode
getNode(java.lang.Object id)
Get a node by its id.INodeHandler[]
getNodeHandlers()
Get the node handlers.ITreeNode
getNodeOrAddZombie(java.lang.Object id)
Get a node for removal.ITreeNode
getRoot()
Get the root node.boolean
isLeaf(java.lang.Object node)
Test if the node is a leaf.boolean
isZombieNode(java.lang.Object id)
Check, if a node is a zombie.void
registerNode(ITreeNode node)
Register a node.void
removeNodeListener(INodeListener listener)
Deregister a node listener.void
removeTreeModelListener(TreeModelListener l)
Remove a listener.void
removeZombieNode(ITreeNode node)
Remove a zombie node.void
setRoot(ITreeNode root)
Set the root node.
-
-
-
Field Detail
-
root
protected ITreeNode root
The root node.
-
listeners
protected final java.util.List<TreeModelListener> listeners
The tree listeners.
-
nodelisteners
protected final java.util.List<INodeListener> nodelisteners
The node listeners.
-
nodes
protected final java.util.Map<java.lang.Object,ITreeNode> nodes
The node lookup table.
-
added
protected final java.util.Map<java.lang.Object,ITreeNode> added
The added nodes.
-
zombies
protected final java.util.Map<java.lang.Object,java.lang.Integer> zombies
The zombie node ids (id->remove counter).
-
overlays
protected final java.util.List<INodeHandler> overlays
The icon overlays.
-
changed
protected MultiCollection<ITreeNode,ITreeNode> changed
The changed nodes (delayed update for improving perceived speed).
-
-
Method Detail
-
getRoot
public ITreeNode getRoot()
Get the root node.
-
getChild
public ITreeNode getChild(java.lang.Object parent, int index)
Get the given child of a node.
-
getChildCount
public int getChildCount(java.lang.Object parent)
Get the number of children of a node.
-
getIndexOfChild
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
Get the index of a child.
-
isLeaf
public boolean isLeaf(java.lang.Object node)
Test if the node is a leaf.
-
addTreeModelListener
public void addTreeModelListener(TreeModelListener l)
Add a listener.
-
removeTreeModelListener
public void removeTreeModelListener(TreeModelListener l)
Remove a listener.
-
setRoot
public void setRoot(ITreeNode root)
Set the root node.
-
fireTreeChanged
public void fireTreeChanged(ITreeNode node)
Inform listeners that tree has changed from given node on.
-
fireNodeChanged
public void fireNodeChanged(ITreeNode node)
Inform listeners that a node has changed.
-
fireNodeRemoved
public void fireNodeRemoved(ITreeNode parent, ITreeNode child, int index)
Inform listeners that a node has been removed
-
fireNodesRemoved
public void fireNodesRemoved(ITreeNode parent, ITreeNode[] childs, int[] indices)
Inform listeners that a node has been removed
-
fireNodeAdded
public void fireNodeAdded(ITreeNode parent, ITreeNode child, int index)
Inform listeners that a node has been added
-
buildTreePath
public java.util.List<ITreeNode> buildTreePath(ITreeNode node)
Build a tree path to the given node.- Parameters:
desc
- The node.- Returns:
- The path items.
-
registerNode
public void registerNode(ITreeNode node)
Register a node. Nodes can be registered for easy access.
-
addNode
public void addNode(ITreeNode node)
Add a node. Informs listeners.
-
getNode
public ITreeNode getNode(java.lang.Object id)
Get a node by its id.
-
getAddedNode
public ITreeNode getAddedNode(java.lang.Object id)
Get a node by its id.
-
deregisterNode
public void deregisterNode(ITreeNode node)
Remove a node registration.
-
addNodeHandler
public void addNodeHandler(INodeHandler overlay)
Add a node handler.
-
getNodeHandlers
public INodeHandler[] getNodeHandlers()
Get the node handlers.
-
addNodeListener
public void addNodeListener(INodeListener listener)
Register a node listener.
-
removeNodeListener
public void removeNodeListener(INodeListener listener)
Deregister a node listener.
-
isZombieNode
public boolean isZombieNode(java.lang.Object id)
Check, if a node is a zombie.
-
dispose
public void dispose()
Called when the tree is removed.
-
getNodeOrAddZombie
public ITreeNode getNodeOrAddZombie(java.lang.Object id)
Get a node for removal. Add a zombie node, if node does not exist.
-
addZombieNode
public void addZombieNode(java.lang.Object id)
Add a zombie node or increase the counter.
-
removeZombieNode
public void removeZombieNode(ITreeNode node)
Remove a zombie node.
-
-