public class OAVTreeModel
extends java.lang.Object
implements javax.swing.tree.TreeModel
Modifier and Type | Class and Description |
---|---|
class |
OAVTreeModel.AttributeNode
A node representing an attribute value.
|
static class |
OAVTreeModel.OAVTreeCellRenderer
OAV tree cell renderer displays right icons.
|
class |
OAVTreeModel.ObjectInspectorNode
TreeModel node for java object inspection
|
class |
OAVTreeModel.ObjectNode
A node representing an object.
|
class |
OAVTreeModel.RootNode
The root node containing the nodes for the root objects of the state.
|
Modifier and Type | Field and Description |
---|---|
protected CopyState |
copy
The local copy of the state (synchronized to swing thread).
|
protected static boolean |
enableObjectInspection
flag to indicate if java objects should be inspectable in the tree
TO DO: make configurable via GUI?
|
protected static javax.swing.UIDefaults |
icons
The image icons.
|
protected java.util.List |
inspectors
list for all created Attribute inspector nodes
|
protected java.util.Set |
listeners
The listeners.
|
protected java.util.Map |
nodes
Nodes for objects to allow fine-tuned tree redraw (object-id -> {node1, node2, ...}).
|
protected boolean |
notify
The pending notification flag.
|
protected OAVTreeModel.RootNode |
root
The root node.
|
protected static java.util.List |
timerList
The list of timers to update the object inspector tree nodes
|
Constructor and Description |
---|
OAVTreeModel(jadex.rules.state.IOAVState state)
Create new OAV tree model.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
addRefreshTimer(javax.swing.Timer t)
Add a timer to the static refresh timer list
|
void |
addTreeModelListener(javax.swing.event.TreeModelListener l)
Add a listener to the model.
|
void |
dispose()
Dispose the model and remove all listeners.
|
protected void |
fireTreeStructureChanged(java.lang.Object[] treePath)
Regenerate subtree if a node was replaced
|
java.lang.Object |
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 the given node.
|
protected int |
getIndexForChild(java.util.List children,
java.lang.Object child)
Get the index for a child in children list, beginning with index=0
|
protected int |
getIndexForChild(java.util.List children,
java.lang.Object child,
int start)
Returns the FIRST occurrence of child in given children list.
|
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
Get the index of a given child.
|
protected int |
getNextNodeUUID()
Generate a unique id for ObjectNode's
|
java.lang.Object |
getRoot()
Get the root node of the tree.
|
protected static boolean |
isInspectable(java.lang.Class clazz,
boolean inspectObjectClass)
Decide if java object should be inspectable.
|
protected static boolean |
isInspectable(java.lang.Object obj)
Decide if java object should be inspectable.
|
boolean |
isLeaf(java.lang.Object node)
Check if a node is a leaf node.
|
protected void |
refreshInspectorNodes()
Refresh all displayed attributes
|
protected static void |
removeRefreshTimer(javax.swing.Timer t)
Remove a timer from the static refresh timer list
|
void |
removeTreeModelListener(javax.swing.event.TreeModelListener l)
Remove a listener from the model.
|
static void |
setRefreshDelay(int millis)
Sets the refresh delay for the ObjectInspector refresh
A value equal or lower to 0 disables the refresh and stop the timers
|
protected boolean |
testInspectorNodesListEquals(java.util.List l1,
java.util.List l2)
Tests if two lists of Inspector nodes (e.g.
|
void |
valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
Called by user changes (when the tree is editable).
|
protected static final boolean enableObjectInspection
protected static final javax.swing.UIDefaults icons
protected static java.util.List timerList
protected OAVTreeModel.RootNode root
protected CopyState copy
protected java.util.Set listeners
protected boolean notify
protected java.util.Map nodes
protected java.util.List inspectors
public OAVTreeModel(jadex.rules.state.IOAVState state)
id
- The root object id.state
- The OAV state.showempty
- Flag, if empty attributes should be shown.public java.lang.Object getRoot()
getRoot
in interface javax.swing.tree.TreeModel
public int getChildCount(java.lang.Object parent)
getChildCount
in interface javax.swing.tree.TreeModel
public java.lang.Object getChild(java.lang.Object parent, int index)
getChild
in interface javax.swing.tree.TreeModel
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
getIndexOfChild
in interface javax.swing.tree.TreeModel
public boolean isLeaf(java.lang.Object node)
isLeaf
in interface javax.swing.tree.TreeModel
public void addTreeModelListener(javax.swing.event.TreeModelListener l)
addTreeModelListener
in interface javax.swing.tree.TreeModel
public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
removeTreeModelListener
in interface javax.swing.tree.TreeModel
public void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
valueForPathChanged
in interface javax.swing.tree.TreeModel
protected int getNextNodeUUID()
protected void fireTreeStructureChanged(java.lang.Object[] treePath)
treePath
- The Path to the node that was changedprotected boolean testInspectorNodesListEquals(java.util.List l1, java.util.List l2)
l1
- list to testl2
- list to testprotected int getIndexForChild(java.util.List children, java.lang.Object child)
protected int getIndexForChild(java.util.List children, java.lang.Object child, int start)
This method is using the "equals(Object o, boolean checkUID)" method to find a child with the checkUID parameter set to false and can be used to find a semantically equal child.
children
- List to search for the child.child
- The child to search for.protected void refreshInspectorNodes()
oldRoot
- public void dispose()
protected static boolean isInspectable(java.lang.Object obj)
protected static boolean isInspectable(java.lang.Class clazz, boolean inspectObjectClass)
public static void setRefreshDelay(int millis)
protected static void addRefreshTimer(javax.swing.Timer t)
t
- protected static void removeRefreshTimer(javax.swing.Timer t)
t
-