public class ObjectTreeModel
extends java.lang.Object
implements javax.swing.tree.TreeModel
Modifier and Type | Class and Description |
---|---|
class |
ObjectTreeModel.ObjectInspectorNode
TreeModel node for java object inspection
|
static class |
ObjectTreeModel.ObjectTreeCellRenderer
OAV tree cell renderer displays right icons.
|
Modifier and Type | Field and Description |
---|---|
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 boolean |
notify
The pending notification flag.
|
protected ObjectTreeModel.ObjectInspectorNode |
root
The root node.
|
protected int |
uuidcounter
UUID counter
|
Constructor and Description |
---|
ObjectTreeModel(java.lang.Object root)
Create new OAV tree model.
|
Modifier and Type | Method and Description |
---|---|
void |
addTreeModelListener(javax.swing.event.TreeModelListener l)
Add a listener to the model.
|
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
|
void |
removeTreeModelListener(javax.swing.event.TreeModelListener l)
Remove a listener from the model.
|
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 ObjectTreeModel.ObjectInspectorNode root
protected java.util.Set listeners
protected boolean notify
protected java.util.List inspectors
protected int uuidcounter
public ObjectTreeModel(java.lang.Object root)
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
- protected static boolean isInspectable(java.lang.Object obj)
protected static boolean isInspectable(java.lang.Class clazz, boolean inspectObjectClass)