public class DefaultKTreeModel extends Object implements KTreeModel
KTreeModel
.Modifier and Type | Class and Description |
---|---|
protected class |
DefaultKTreeModel.TreeNode
Internal wrapper object for nodes.
|
Modifier and Type | Field and Description |
---|---|
private static Icon |
DOCUMENT_ICON |
protected static DefaultKTreeModel.TreeNode[] |
emptyList |
private static Icon |
FOLDER_CLOSED_ICON |
private static Icon |
FOLDER_OPEN_ICON |
private Vector |
listeners |
protected TreeMap |
nodeMap
The object-to-node map.
|
protected DefaultKTreeModel.TreeNode |
rootNode
The model's root node.
|
protected KTreeModelSupport |
support |
COLUMN_NAMES_PROPERTY, COLUMN_TYPES_PROPERTY
Constructor and Description |
---|
DefaultKTreeModel()
Construct a new, static
DefaultKTreeModel . |
Modifier and Type | Method and Description |
---|---|
void |
addChild(Object parent,
Object node)
Add a new child node to the given parent node.
|
void |
addChild(Object parent,
Object node,
int index)
Add a new child node to the given parent node.
|
void |
addTreeModelListener(KTreeModelListener listener)
Add a
TreeModelListener to this model's list of listeners. |
protected void |
destroyNode(DefaultKTreeModel.TreeNode node)
Destroy a node, and recursively destroy all its descendants.
|
Object |
getChild(Object parent,
int index)
Get a child of a node.
|
int |
getChildCount(Object node)
Get a child count for a node.
|
Iterator |
getChildren(Object parent)
Get the children of a node.
|
Icon |
getIcon(Object node,
boolean isExpanded)
May be overridden by subclasses to provide custom icons.
|
int |
getIndexOfChild(Object parent,
Object node)
Get the index of a child node in its parent's list of children.
|
String |
getLabel(Object node)
May be overridden by subclasses to provide custom labels.
|
Object |
getParent(Object node)
Get the parent of a node.
|
Object |
getRoot()
Get the root node.
|
Object |
getValueForProperty(Object node,
String property)
Get the value of an arbitrary property for a given node.
|
boolean |
isExpandable(Object node)
Determine if a node is expandable.
|
protected void |
loadChildren(DefaultKTreeModel.TreeNode node)
Load the children for a given node.
|
protected DefaultKTreeModel.TreeNode |
makeNode(Object object,
DefaultKTreeModel.TreeNode parent)
Create a node for an object.
|
protected DefaultKTreeModel.TreeNode |
nodeForObject(Object item)
Look up a node for a given object.
|
void |
preloadChildren(Object item)
Preload the children of a given node.
|
void |
releaseChildren(Object parent)
Release the children of a given parent node.
|
void |
removeChild(Object parent,
int index)
Remove a child node of a given parent node.
|
void |
removeChildren(Object parent)
Remove all of the children of a given parent node.
|
void |
removeTreeModelListener(KTreeModelListener listener)
Remove a
TreeModelListener from this model's list of
listeners. |
void |
setRoot(Object root)
Set the root node.
|
void |
updateChildren(Object parent)
Indicate to listeners that the list of children of the specified node
has changed.
|
void |
updateNode(Object node)
Indicate to listeners that the specified node has changed.
|
protected KTreeModelSupport support
protected static final DefaultKTreeModel.TreeNode[] emptyList
private static final Icon FOLDER_OPEN_ICON
private static final Icon FOLDER_CLOSED_ICON
private static final Icon DOCUMENT_ICON
protected DefaultKTreeModel.TreeNode rootNode
public DefaultKTreeModel()
DefaultKTreeModel
.protected DefaultKTreeModel.TreeNode makeNode(Object object, DefaultKTreeModel.TreeNode parent)
protected void destroyNode(DefaultKTreeModel.TreeNode node)
public Object getRoot()
KTreeModel
getRoot
in interface KTreeModel
public void setRoot(Object root)
KTreeModel
setRoot
in interface KTreeModel
root
- The new root node.public int getChildCount(Object node)
KTreeModel
getChildCount
in interface KTreeModel
node
- The parent node.public Object getChild(Object parent, int index)
KTreeModel
getChild
in interface KTreeModel
parent
- The parent node.index
- The index of the child within the parent's list of children.null
if no such node exists.public Iterator getChildren(Object parent)
KTreeModel
getChildren
in interface KTreeModel
parent
- The parent node.public int getIndexOfChild(Object parent, Object node)
KTreeModel
getIndexOfChild
in interface KTreeModel
parent
- The parent node.node
- The child node.public void removeChildren(Object parent)
KTreeModel
removeChildren
in interface KTreeModel
parent
- The parent node.public void removeChild(Object parent, int index)
KTreeModel
removeChild
in interface KTreeModel
parent
- The parent node.index
- The index of the child to remove within the parent's list of
children.public void addChild(Object parent, Object node)
KTreeModel
addChild
in interface KTreeModel
parent
- The parent node.node
- The new child node.public void addChild(Object parent, Object node, int index)
KTreeModel
addChild
in interface KTreeModel
parent
- The parent node.node
- The new child node.index
- The offset in the list of children at which the new node
should be inserted.public Object getParent(Object node)
KTreeModel
getParent
in interface KTreeModel
node
- The child node.
return The parent of the specified child node.public boolean isExpandable(Object node)
KTreeModel
isExpandable
in interface KTreeModel
node
- The node to test.true
if the node is expandable, false
otherwise.public Icon getIcon(Object node, boolean isExpanded)
getIcon
in interface KTreeModel
node
- The node.isExpanded
- The current expanded state for the node.public String getLabel(Object node)
getLabel
in interface KTreeModel
node
- The node.public void updateNode(Object node)
KTreeModel
updateNode
in interface KTreeModel
node
- The node.public void updateChildren(Object parent)
KTreeModel
updateChildren
in interface KTreeModel
parent
- The parent node.public void releaseChildren(Object parent)
KTreeModel
releaseChildren
in interface KTreeModel
parent
- The root node of the subtree that should be released.public Object getValueForProperty(Object node, String property)
getValueForProperty
in interface KTreeModel
node
- The node.property
- The name of the property.null
if
there is no value for this property.public void addTreeModelListener(KTreeModelListener listener)
TreeModelListener
to this model's list of listeners.addTreeModelListener
in interface KTreeModel
listener
- The listener to be added.removeTreeModelListener(kiwi.event.KTreeModelListener)
public void removeTreeModelListener(KTreeModelListener listener)
TreeModelListener
from this model's list of
listeners.removeTreeModelListener
in interface KTreeModel
listener
- The listener to remove.addTreeModelListener(kiwi.event.KTreeModelListener)
protected DefaultKTreeModel.TreeNode nodeForObject(Object item)
public void preloadChildren(Object item)
KTreeModel
preloadChildren
in interface KTreeModel
item
- The node for which children should be preloaded.protected void loadChildren(DefaultKTreeModel.TreeNode node)
node
- The parent node.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses