public class KTreeModelTreeAdapter extends Object implements TreeModel, KTreeModelListener
JTree
to be used with the
StaticTreeModel
and DynamicTreeModel
data models.
The adapter translates messages and events between the JTree
and the ITreeModel
implementation.JTree
,
KTreeModel
Modifier and Type | Field and Description |
---|---|
private static int[] |
emptyIndexList |
private static Object[] |
emptyObjectList |
private JTree |
jtree |
private Vector |
listeners |
private KTreeModel |
model |
private TreeExpansionListener |
treeExpansionListener |
private TreeWillExpandListener |
treeWillExpandListener |
Constructor and Description |
---|
KTreeModelTreeAdapter(JTree jtree)
Construct a new tree model tree adapter.
|
Modifier and Type | Method and Description |
---|---|
void |
addTreeModelListener(TreeModelListener listener)
Add a tree model listener.
|
void |
dataChanged(KTreeModelEvent evt)
Invoked when the structure of the entire model has changed.
|
void |
dispose()
Dispose of the adapter.
|
protected void |
fireTreeNodesChanged(Object parent,
int startIndex,
int endIndex)
Fire a tree nodes changed event.
|
protected void |
fireTreeNodesInserted(Object parent,
int startIndex,
int endIndex)
Fire a tree nodes inserted event.
|
protected void |
fireTreeNodesRemoved(Object parent,
int startIndex,
int endIndex)
Fire a tree nodes removed event.
|
protected void |
fireTreeStructureChanged(Object node)
Fire a tree structure changed event.
|
Object |
getChild(Object parent,
int index)
Get the child of a node.
|
int |
getChildCount(Object parent)
Get the child count of a node.
|
int |
getIndexOfChild(Object parent,
Object child)
Get the index of a child within its parent.
|
TreePath |
getPathForNode(Object node)
Compute a
TreePath for a given node. |
Object |
getRoot()
Get the root of the tree.
|
KTreeModel |
getTreeModel()
Get the tree model in use by this adapter.
|
boolean |
isLeaf(Object node)
Determine if a node is a leaf.
|
void |
nodesAdded(KTreeModelEvent evt)
Invoked when nodes are added to the model.
|
void |
nodesChanged(KTreeModelEvent evt)
Invoked when nodes are changed in the model.
|
void |
nodesRemoved(KTreeModelEvent evt)
Invoked when nodes are removed from the model.
|
void |
removeTreeModelListener(TreeModelListener listener)
Remove a tree model listener.
|
void |
setTreeModel(KTreeModel model)
Set the tree model to be used by this adapter.
|
void |
structureChanged(KTreeModelEvent evt)
Invoked when the structure of a portion of the model is changed.
|
void |
valueForPathChanged(TreePath path,
Object newValue)
Handle
JTree events. |
private KTreeModel model
private TreeWillExpandListener treeWillExpandListener
private TreeExpansionListener treeExpansionListener
private static final int[] emptyIndexList
private static final Object[] emptyObjectList
public KTreeModelTreeAdapter(JTree jtree)
jtree
- The JFC tree component to be associated with this adapter.public void setTreeModel(KTreeModel model)
model
- The model to set.getTreeModel()
public KTreeModel getTreeModel()
null
if no
model has been set).setTreeModel(kiwi.ui.model.KTreeModel)
public void addTreeModelListener(TreeModelListener listener)
TreeModelListener
to this
adapter's list of tree model listeners.addTreeModelListener
in interface TreeModel
listener
- The listener to add.removeTreeModelListener(javax.swing.event.TreeModelListener)
public void removeTreeModelListener(TreeModelListener listener)
TreeModelListener
from this adapter's list of tree model listeners.removeTreeModelListener
in interface TreeModel
listener
- The listener to remove.addTreeModelListener(javax.swing.event.TreeModelListener)
public void nodesAdded(KTreeModelEvent evt)
nodesAdded
in interface KTreeModelListener
public void nodesRemoved(KTreeModelEvent evt)
nodesRemoved
in interface KTreeModelListener
public void nodesChanged(KTreeModelEvent evt)
nodesChanged
in interface KTreeModelListener
public void structureChanged(KTreeModelEvent evt)
structureChanged
in interface KTreeModelListener
public void dataChanged(KTreeModelEvent evt)
dataChanged
in interface KTreeModelListener
public Object getChild(Object parent, int index)
TreeModel
.)public int getChildCount(Object parent)
TreeModel
.)getChildCount
in interface TreeModel
public boolean isLeaf(Object node)
TreeModel
.)public void valueForPathChanged(TreePath path, Object newValue)
JTree
events. (Implementation of
TreeModel
.)valueForPathChanged
in interface TreeModel
public int getIndexOfChild(Object parent, Object child)
TreeModel
.)getIndexOfChild
in interface TreeModel
public TreePath getPathForNode(Object node)
TreePath
for a given node.node
- The node.TreePath
to the given node.TreePath
protected void fireTreeNodesInserted(Object parent, int startIndex, int endIndex)
JTree
that new nodes have been added to the tree data model.parent
- The parent of the new nodes.startIndex
- The offset of the first node in the range of nodes that
were added.endIndex
- The offset of the last node in the range of nodes that
were added.protected void fireTreeNodesRemoved(Object parent, int startIndex, int endIndex)
JTree
that a node has been removed from the tree data model.parent
- The parent of the nodes that were removed.startIndex
- The offset of the first node in the range of nodes that
were removed.endIndex
- The offset of the last node in the range of nodes that
were removed.protected void fireTreeNodesChanged(Object parent, int startIndex, int endIndex)
JTree
that a node has changed in some way.parent
- The parent of the nodes that changed.startIndex
- The offset of the first node in the range of nodes that
changed.endIndex
- The offset of the last node in the range of nodes that
changed.protected void fireTreeStructureChanged(Object node)
JTree
that the subtree rooted at a given node has changed in
some major way.node
- The node that is the root of the subtree that changed.public void dispose()
JTree
component, and then null out its
references to the JTree
and to the associated
KTreeModel
.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses