|
jrworkspace by jTEM |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jtem.jrworkspace.plugin.simplecontroller.widget.AbstractTreeModel
public abstract class AbstractTreeModel
Baseclass for TreeModel implementations. Manages listeners and
provides fireXXX methods for notifying them.
The valueForPathChanged
method is implemented as no-op which comes handy for immutable trees
and trees where the editor<->node communication is already enough.
Constructor Summary | |
---|---|
protected |
AbstractTreeModel(Object root)
Construct a tree model with the given root object. |
Method Summary | |
---|---|
void |
addTreeModelListener(TreeModelListener l)
|
protected void |
fireNodesAdded(Object parent,
int[] indices,
Object[] child)
|
protected void |
fireNodesAdded(Object parent,
Object[] child)
|
protected void |
fireNodesChanged(Object parent,
int[] indices,
Object[] child)
|
protected void |
fireNodesChanged(Object parent,
Object[] child)
|
protected void |
fireNodesRemoved(Object parent,
int[] indices,
Object[] child)
|
protected void |
fireTreeStructureChanged(Object parent)
|
abstract Object |
getChild(Object parent,
int index)
Must be implemented by subclasses, return the child of parent at index. |
abstract int |
getChildCount(Object parent)
Must be implemented by subclasses, return number of children. |
int |
getIndexOfChild(Object parent,
Object child)
Defaults to a linear search for the child. |
protected int[] |
getIndicesFor(Object parent,
Object[] child)
Used by event instance creation. |
abstract Object |
getParent(Object o)
Must be implemented by subclasses, return the parent of a node. |
TreePath |
getPathTo(Object o)
Used by event instance creation. |
Object |
getRoot()
Returns the root object specified in the constructor. |
boolean |
isLeaf(Object node)
Returns getChildCount(node)==0 , should be overridden
if the semantics of leaf nodes differs. |
void |
removeTreeModelListener(TreeModelListener l)
|
void |
valueForPathChanged(TreePath path,
Object newValue)
Simply does nothing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AbstractTreeModel(Object root)
getRoot()
method to return the
dynamic root object. And don't forget to call the
fireNodesChanged
method each time
the root node is replaced.
Method Detail |
---|
public void addTreeModelListener(TreeModelListener l)
addTreeModelListener
in interface TreeModel
protected void fireNodesAdded(Object parent, int[] indices, Object[] child)
protected void fireNodesAdded(Object parent, Object[] child)
protected void fireNodesChanged(Object parent, int[] indices, Object[] child)
protected void fireNodesChanged(Object parent, Object[] child)
protected void fireNodesRemoved(Object parent, int[] indices, Object[] child)
protected void fireTreeStructureChanged(Object parent)
public abstract Object getChild(Object parent, int index)
getChild
in interface TreeModel
TreeModel.getChild(Object,int)
public abstract int getChildCount(Object parent)
getChildCount
in interface TreeModel
TreeModel.getChildCount(Object)
public int getIndexOfChild(Object parent, Object child)
getIndexOfChild
in interface TreeModel
protected int[] getIndicesFor(Object parent, Object[] child)
getIndexOfChild
for every array entry.
Should be overridden if more efficient methods are available.
public abstract Object getParent(Object o)
getPathTo(Object)
and therefore does not require a valid implementation if
the getPathTo()
method is overridden with an
implementation that does not call it's super impl.
public TreePath getPathTo(Object o)
getParent
until the root object is reached.
Should be overridden if more efficient methods are available.
public Object getRoot()
getRoot
in interface TreeModel
public boolean isLeaf(Object node)
getChildCount(node)==0
, should be overridden
if the semantics of leaf nodes differs.
isLeaf
in interface TreeModel
public void removeTreeModelListener(TreeModelListener l)
removeTreeModelListener
in interface TreeModel
public void valueForPathChanged(TreePath path, Object newValue)
valueForPathChanged
in interface TreeModel
|
jrworkspace by jTEM |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |