public abstract class AbstractTreeModel extends Object implements TreeModel
valueForPathChanged
method is implemented as no-op which comes handy for immutable trees
and trees where the editor<->node communication is already enough.Modifier and Type | Method and Description |
---|---|
void |
addTreeModelListener(TreeModelListener l) |
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.
|
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.
|
public void addTreeModelListener(TreeModelListener l)
addTreeModelListener
in interface TreeModel
public void removeTreeModelListener(TreeModelListener l)
removeTreeModelListener
in interface TreeModel
public TreePath getPathTo(Object o)
getParent
until the root object is reached.
Should be overridden if more efficient methods are available.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
public Object getRoot()
public boolean isLeaf(Object node)
getChildCount(node)==0
, should be overridden
if the semantics of leaf nodes differs.public void valueForPathChanged(TreePath path, Object newValue)
valueForPathChanged
in interface TreeModel
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.