public class TreeModel
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
boolean |
allowsChildren
flag used to determine if a node is a leaf or a folder.
|
Constructor and Description |
---|
TreeModel()
Constructor to create an empty tree model with allowsChildren is true.
|
TreeModel(boolean allowsChildren)
Constructor to create an empty tree model that use allowsChildren to determine the leaf node, if and only if
allowsChildren is true.
|
TreeModel(Node root)
Constructor to create a tree model with the specified root node and with allowsChildren is true.
|
TreeModel(Node root,
boolean allowsChildren)
Constructor to create a tree model with the specified root node and with the specified allowsChildren flag.
|
Modifier and Type | Method and Description |
---|---|
void |
addNode(Node parent,
Node newNode)
Method to add a node to the parent node at the specified position.
|
void |
clear()
Method to clear this model.
|
Node |
getRoot()
Method to return the root node of this tree model.
|
void |
insertNode(Node parent,
Node newNode,
int index)
Method to insert a node to the parent node at the specified position.
|
void |
modifyNode(Node node,
java.lang.Object userObject)
Method to modify a node userObject and notify the tree of the changes.
|
void |
reload()
Method to notify the tree to reload.
|
void |
removeNode(Node parent,
Node node)
Method to remove a node from the tree.
|
void |
setRoot(Node root)
Method to set the root node of this tree model and notify the tree to reload the tree.
|
void |
setTree(Tree tree)
Method to set the tree (For internal use only) This method register the tree to this model, so when the user add,
delete, or modify a node, the tree view will be notify and updated.
|
public boolean allowsChildren
public TreeModel(Node root, boolean allowsChildren)
public TreeModel(Node root)
public TreeModel()
public TreeModel(boolean allowsChildren)
allowsChildren
- true to use allowwsChildren to determine a leaf node.public void setTree(Tree tree)
tree
- the tree (view) that is associated with this model.public void clear()
public void reload()
public Node getRoot()
public void setRoot(Node root)
root
- the new root node of this tree model.public void insertNode(Node parent, Node newNode, int index)
parent
- the parent node of the node to insert.newNode
- the new node to insert into this tree model.index
- the index to insert the node intopublic void addNode(Node parent, Node newNode)
parent
- the parent node of the node to insert.newNode
- the new node to insert into this tree model.public void removeNode(Node parent, Node node)
parent
- the parent node of the node to remove.node
- the node to remove from this tree model.public void modifyNode(Node node, java.lang.Object userObject)
node
- the node to modify.userObject
- the new user object.