Package jadex.rules.tools.stateviewer
Class OAVTreeModel
- java.lang.Object
- 
- jadex.rules.tools.stateviewer.OAVTreeModel
 
- 
- All Implemented Interfaces:
- javax.swing.tree.TreeModel
 - Direct Known Subclasses:
- ObjectInspectorTreeModelTest
 
 public class OAVTreeModel extends java.lang.Object implements javax.swing.tree.TreeModelSwing Tree model for an OAV state. Enables displaying an oav state in a swing tree.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classOAVTreeModel.AttributeNodeA node representing an attribute value.static classOAVTreeModel.OAVTreeCellRendererOAV tree cell renderer displays right icons.classOAVTreeModel.ObjectInspectorNodeTreeModel node for java object inspectionclassOAVTreeModel.ObjectNodeA node representing an object.classOAVTreeModel.RootNodeThe root node containing the nodes for the root objects of the state.
 - 
Field SummaryFields Modifier and Type Field Description protected CopyStatecopyThe local copy of the state (synchronized to swing thread).protected static booleanenableObjectInspectionflag to indicate if java objects should be inspectable in the tree TO DO: make configurable via GUI?protected static javax.swing.UIDefaultsiconsThe image icons.protected java.util.Listinspectorslist for all created Attribute inspector nodesprotected java.util.SetlistenersThe listeners.protected java.util.MapnodesNodes for objects to allow fine-tuned tree redraw (object-id -> {node1, node2, ...}).protected booleannotifyThe pending notification flag.protected OAVTreeModel.RootNoderootThe root node.protected static java.util.ListtimerListThe list of timers to update the object inspector tree nodes
 - 
Constructor SummaryConstructors Constructor Description OAVTreeModel(IOAVState state)Create new OAV tree model.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidaddRefreshTimer(javax.swing.Timer t)Add a timer to the static refresh timer listvoidaddTreeModelListener(javax.swing.event.TreeModelListener l)Add a listener to the model.voiddispose()Dispose the model and remove all listeners.protected voidfireTreeStructureChanged(java.lang.Object[] treePath)Regenerate subtree if a node was replacedjava.lang.ObjectgetChild(java.lang.Object parent, int index)Get the given child of a node.intgetChildCount(java.lang.Object parent)Get the number of children of the given node.protected intgetIndexForChild(java.util.List children, java.lang.Object child)Get the index for a child in children list, beginning with index=0protected intgetIndexForChild(java.util.List children, java.lang.Object child, int start)Returns the FIRST occurrence of child in given children list.intgetIndexOfChild(java.lang.Object parent, java.lang.Object child)Get the index of a given child.protected intgetNextNodeUUID()Generate a unique id for ObjectNode'sjava.lang.ObjectgetRoot()Get the root node of the tree.protected static booleanisInspectable(java.lang.Class clazz, boolean inspectObjectClass)Decide if java object should be inspectable.protected static booleanisInspectable(java.lang.Object obj)Decide if java object should be inspectable.booleanisLeaf(java.lang.Object node)Check if a node is a leaf node.protected voidrefreshInspectorNodes()Refresh all displayed attributesprotected static voidremoveRefreshTimer(javax.swing.Timer t)Remove a timer from the static refresh timer listvoidremoveTreeModelListener(javax.swing.event.TreeModelListener l)Remove a listener from the model.static voidsetRefreshDelay(int millis)Sets the refresh delay for the ObjectInspector refresh A value equal or lower to 0 disables the refresh and stop the timersprotected booleantestInspectorNodesListEquals(java.util.List l1, java.util.List l2)Tests if two lists of Inspector nodes (e.g.voidvalueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)Called by user changes (when the tree is editable).
 
- 
- 
- 
Field Detail- 
enableObjectInspectionprotected static final boolean enableObjectInspection flag to indicate if java objects should be inspectable in the tree TO DO: make configurable via GUI?- See Also:
- Constant Field Values
 
 - 
iconsprotected static final javax.swing.UIDefaults icons The image icons.
 - 
timerListprotected static java.util.List timerList The list of timers to update the object inspector tree nodes
 - 
rootprotected OAVTreeModel.RootNode root The root node.
 - 
copyprotected CopyState copy The local copy of the state (synchronized to swing thread).
 - 
listenersprotected java.util.Set listeners The listeners.
 - 
notifyprotected boolean notify The pending notification flag.
 - 
nodesprotected java.util.Map nodes Nodes for objects to allow fine-tuned tree redraw (object-id -> {node1, node2, ...}). Because the state is a (possibly cyclic) graph, there may be more than one node for a single object!
 - 
inspectorsprotected java.util.List inspectors list for all created Attribute inspector nodes
 
- 
 - 
Constructor Detail- 
OAVTreeModelpublic OAVTreeModel(IOAVState state) Create new OAV tree model.- Parameters:
- id- The root object id.
- state- The OAV state.
- showempty- Flag, if empty attributes should be shown.
 
 
- 
 - 
Method Detail- 
getRootpublic java.lang.Object getRoot() Get the root node of the tree.- Specified by:
- getRootin interface- javax.swing.tree.TreeModel
 
 - 
getChildCountpublic int getChildCount(java.lang.Object parent) Get the number of children of the given node.- Specified by:
- getChildCountin interface- javax.swing.tree.TreeModel
 
 - 
getChildpublic java.lang.Object getChild(java.lang.Object parent, int index)Get the given child of a node.- Specified by:
- getChildin interface- javax.swing.tree.TreeModel
 
 - 
getIndexOfChildpublic int getIndexOfChild(java.lang.Object parent, java.lang.Object child)Get the index of a given child.- Specified by:
- getIndexOfChildin interface- javax.swing.tree.TreeModel
 
 - 
isLeafpublic boolean isLeaf(java.lang.Object node) Check if a node is a leaf node.- Specified by:
- isLeafin interface- javax.swing.tree.TreeModel
 
 - 
addTreeModelListenerpublic void addTreeModelListener(javax.swing.event.TreeModelListener l) Add a listener to the model.- Specified by:
- addTreeModelListenerin interface- javax.swing.tree.TreeModel
 
 - 
removeTreeModelListenerpublic void removeTreeModelListener(javax.swing.event.TreeModelListener l) Remove a listener from the model.- Specified by:
- removeTreeModelListenerin interface- javax.swing.tree.TreeModel
 
 - 
valueForPathChangedpublic void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)Called by user changes (when the tree is editable).- Specified by:
- valueForPathChangedin interface- javax.swing.tree.TreeModel
 
 - 
getNextNodeUUIDprotected int getNextNodeUUID() Generate a unique id for ObjectNode's- Returns:
- synchronized call to System.currentTimeMillis();
 
 - 
fireTreeStructureChangedprotected void fireTreeStructureChanged(java.lang.Object[] treePath) Regenerate subtree if a node was replaced- Parameters:
- treePath- The Path to the node that was changed
 
 - 
testInspectorNodesListEqualsprotected boolean testInspectorNodesListEquals(java.util.List l1, java.util.List l2)Tests if two lists of Inspector nodes (e.g. children) are semantically equals- Parameters:
- l1- list to test
- l2- list to test
- Returns:
- true if the lists are the same or contains the semantically same objects in the same order
 
 - 
getIndexForChildprotected int getIndexForChild(java.util.List children, java.lang.Object child)Get the index for a child in children list, beginning with index=0
 - 
getIndexForChildprotected int getIndexForChild(java.util.List children, java.lang.Object child, int start)Returns the FIRST occurrence of child in given children list. Be sure to remove the child from the list or to save the index to find additional occurrences of the child in later searches.- Parameters:
- children- List to search for the child.
- child- The child to search for.
- Returns:
- the FIRST index for the child in the children list
 - 
refreshInspectorNodesprotected void refreshInspectorNodes() Refresh all displayed attributes- Parameters:
- oldRoot-
 
 - 
disposepublic void dispose() Dispose the model and remove all listeners.
 - 
isInspectableprotected static boolean isInspectable(java.lang.Object obj) Decide if java object should be inspectable.
 - 
isInspectableprotected static boolean isInspectable(java.lang.Class clazz, boolean inspectObjectClass)Decide if java object should be inspectable. This method test if clazz.isAssignableFrom([String|Number|Character|])
 - 
setRefreshDelaypublic 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
 - 
addRefreshTimerprotected static void addRefreshTimer(javax.swing.Timer t) Add a timer to the static refresh timer list- Parameters:
- t-
 
 - 
removeRefreshTimerprotected static void removeRefreshTimer(javax.swing.Timer t) Remove a timer from the static refresh timer list- Parameters:
- t-
 
 
 
- 
 
-