public final class TreeModelSupport extends Object
TreeModel
s.
The changed/inserted/removed is expressed in terms of a TreePath
,
it's up to the client model to build it as appropriate.
This is inspired by AbstractTreeModel
from Christian Kaufhold,
www.chka.de.
TODO - implement and test precondition failure of added/removed notificationModifier and Type | Field and Description |
---|---|
protected EventListenerList |
listeners |
private TreeModel |
treeModel |
Constructor and Description |
---|
TreeModelSupport(TreeModel model)
Creates the support class for the given
TreeModel . |
Modifier and Type | Method and Description |
---|---|
void |
addTreeModelListener(TreeModelListener l) |
private TreeModelEvent |
createStructureChangedEvent(TreePath parentPath)
Creates and returns a TreeModelEvent for structureChanged
event notification.
|
private TreeModelEvent |
createTreeModelEvent(TreePath parentPath,
int[] indices,
Object[] children)
Creates and returns a TreeModelEvent for changed/inserted/removed
event notification.
|
void |
fireChildAdded(TreePath parentPath,
int index,
Object child)
Notifies registered TreeModelListeners that the child has been added to
the the node identified by the given parent path at the given position.
|
void |
fireChildChanged(TreePath parentPath,
int index,
Object child)
Notifies registered TreeModelListeners that the given child of
the node identified by the given parent path has been modified.
|
void |
fireChildRemoved(TreePath parentPath,
int index,
Object child)
Notifies registered TreeModelListeners that the child has been removed
from the node identified by the given parent path from the given position.
|
void |
fireChildrenAdded(TreePath parentPath,
int[] indices,
Object[] children)
Notifies registered TreeModelListeners that the given children have been
added to the the node identified by the given parent path at the given
locations.
|
void |
fireChildrenChanged(TreePath parentPath,
int[] indices,
Object[] children)
Notifies registered TreeModelListeners that the given children of
the node identified by the given parent path have been modified.
|
void |
fireChildrenRemoved(TreePath parentPath,
int[] indices,
Object[] children)
Notifies registered TreeModelListeners that the given children have been
removed to the the node identified by the given parent path from the
given locations.
|
void |
fireNewRoot()
Notifies registered TreeModelListeners that the tree's root has
been replaced.
|
void |
firePathChanged(TreePath path)
Notifies registered TreeModelListeners that the
the node identified by the given path has been modified.
|
void |
firePathLeafStateChanged(TreePath path)
Call when a node has changed its leaf state.
|
void |
fireTreeStructureChanged(TreePath subTreePath)
Notifies registered TreeModelListeners that the structure
below the node identified by the given path has been
completely changed.
|
TreeModelListener[] |
getTreeModelListeners() |
void |
removeTreeModelListener(TreeModelListener l) |
protected EventListenerList listeners
public TreeModelSupport(TreeModel model)
TreeModel
.model
- the model to supportNullPointerException
- if model
is null
public void fireNewRoot()
public void firePathLeafStateChanged(TreePath path)
PENDING: rename? Do we need it?
path
- the path to the node with changed leaf state.public void fireTreeStructureChanged(TreePath subTreePath)
NOTE: the subtree path maybe null if the root is null. If not null, it must contain at least one element (the root).
subTreePath
- the path to the root of the subtree
whose structure was changed.NullPointerException
- if the path is not null but empty
or contains null elements.public void firePathChanged(TreePath path)
path
- the path to the node that has been modified,
must not be null and must not contain null path elements.public void fireChildChanged(TreePath parentPath, int index, Object child)
parentPath
- the path to the parent of the modified children.index
- the position of the childchild
- child node that has been modified, must not be nullpublic void fireChildrenChanged(TreePath parentPath, int[] indices, Object[] children)
The exception to these rules is if the root itself has been modified (which has no parent by definition). In this case the path must be the path to the root and both indices and children arrays must be null.
parentPath
- the path to the parent of the modified children.indices
- the positions of the modified childrenchildren
- the modified childrenpublic void fireChildAdded(TreePath parentPath, int index, Object child)
parentPath
- the path to the parent of added child.index
- the position of the added childrenchild
- the added childpublic void fireChildRemoved(TreePath parentPath, int index, Object child)
parentPath
- the path to the parent of removed child.index
- the position of the removed children before the removalchild
- the removed childpublic void fireChildrenAdded(TreePath parentPath, int[] indices, Object[] children)
parentPath
- the path to the parent of the added children.indices
- the positions of the added children.children
- the added children.public void fireChildrenRemoved(TreePath parentPath, int[] indices, Object[] children)
parentPath
- the path to the parent of the removed children.indices
- the positions of the removed children before the removalchildren
- the removed childrenprivate TreeModelEvent createStructureChangedEvent(TreePath parentPath)
parentPath
- the path to the root of the changed structure,
may be null to indicate setting a null root.TreeModelEvent
,
TreeModelListener
private TreeModelEvent createTreeModelEvent(TreePath parentPath, int[] indices, Object[] children)
parentPath
- path to parent of modified nodeindices
- the indices of the modified children (before the change)children
- the array of modified childrenTreeModelEvent
,
TreeModelListener
public void addTreeModelListener(TreeModelListener l)
public TreeModelListener[] getTreeModelListeners()
public void removeTreeModelListener(TreeModelListener l)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses