|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.tree.DefaultTreeModel
dsto.dfc.swing.tree.DfcSwingTreeModel
public class DfcSwingTreeModel
An implementation of a node-based tree DfcTreeModel using Swing's
DefaultTreeModel as the base. Unlike DefaultDfcTreeModel, entries
in this tree are TreeNode's (or more usefully DfcTreeNode
)
- the data entries are stored in the userObject property of each
node.
Field Summary |
---|
Fields inherited from class javax.swing.tree.DefaultTreeModel |
---|
asksAllowsChildren, listenerList, root |
Constructor Summary | |
---|---|
DfcSwingTreeModel()
|
|
DfcSwingTreeModel(TreeNode root)
|
Method Summary | |
---|---|
DfcTreeNode |
addChild(MutableTreeNode parent,
Object entry)
Shortcut to add a user object to a node in the tree. |
DfcTreeNode |
addChild(MutableTreeNode parent,
Object entry,
int index)
Shortcut to add a user object to a node in the tree. |
void |
addEntry(Object parent,
Object entry,
int index)
Add a child to parent at a given index. |
boolean |
canAddEntry(Object parent,
Object entry,
int index)
Test if a child can be added at a given index. |
boolean |
canCopyEntry(Object entry)
Test if an entry may be copied into a transferable. |
boolean |
canMoveEntry(Object entry,
Object newParent,
int newIndex)
|
boolean |
canPasteEntry(Object parent,
int index,
Transferable transferable)
Test if a transferable may be pasted. |
boolean |
canRemoveEntry(Object entry)
Test if an entry may be removed. |
Object |
clone()
Create a completely separate copy of this object and any mutable objects owned by the object. |
DfcSwingTreeModel |
clone(TreeNode node)
Clone a subtree of this model. |
static MutableTreeNode |
cloneNodes(TreeNode root)
Clone a tree of nodes. |
Transferable |
copyEntry(Object entry)
Copy an entry into a transferable. |
void |
dispose()
Calls dispose on all Disposable nodes in the model. |
protected void |
fireTreeNodeChanged(DfcTreeNode node)
Convenience method to fire the correct event when a node has changed. |
Object[] |
getObjectPathToRoot(DfcTreeNode node)
Like getPathToRoot() except that the returned path is defined in terms of the user objects associated with the nodes. |
Object |
getParent(Object entry)
Get the parent for a given entry, or null if the entry is the root. |
Object[] |
getPathForEntry(Object entry)
Get the path for a given entry. |
DfcTreeNode |
getRootNode()
|
boolean |
isMutable()
True if the tree can be changed. |
DfcTreeNode[] |
makeNodePath(Object[] objectPath)
Convert a path defined in terms of user objects to one in this tree defined in terms of tree node's. |
static Object[] |
makeObjectPath(Object[] nodePath)
Create a path defined in terms of user objects from a path defined by nodes. |
void |
moveEntry(Object entry,
Object newParent,
int newIndex)
Move a child from one location to another. |
void |
pasteEntry(Object parent,
int index,
Transferable transferable)
Paste transferable data into the tree. |
void |
removeAll()
Remove all children of the root node. |
void |
removeAllChildren(MutableTreeNode node)
Remove all children of a node. |
void |
removeEntry(Object entry)
Remove an entry and any children. |
void |
setMutable(boolean newValue)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.swing.tree.TreeModel |
---|
addTreeModelListener, getChild, getChildCount, getIndexOfChild, getRoot, isLeaf, removeTreeModelListener, valueForPathChanged |
Constructor Detail |
---|
public DfcSwingTreeModel()
public DfcSwingTreeModel(TreeNode root)
Method Detail |
---|
public void dispose()
Disposable
nodes in the model.
Trees.disposeNodes(TreeNode)
public DfcTreeNode getRootNode()
public DfcTreeNode addChild(MutableTreeNode parent, Object entry)
parent
- The node to add the new child node to.entry
- The entry (user object) for the new child.
public DfcTreeNode addChild(MutableTreeNode parent, Object entry, int index)
parent
- The node to add the new child node to.entry
- The entry (user object) for the new child.index
- The index to insert the child at.
public void removeAll()
removeAllChildren(javax.swing.tree.MutableTreeNode)
public void removeAllChildren(MutableTreeNode node)
removeAll()
public Object[] getObjectPathToRoot(DfcTreeNode node)
makeNodePath(java.lang.Object[])
public DfcTreeNode[] makeNodePath(Object[] objectPath) throws IllegalArgumentException
IllegalArgumentException
- if objectPath did not match a
path in the tree.getObjectPathToRoot(dsto.dfc.swing.tree.DfcTreeNode)
,
makeObjectPath(java.lang.Object[])
public static Object[] makeObjectPath(Object[] nodePath) throws ClassCastException
ClassCastException
- if an entry in nodePath is not a
DfcTreeNode.makeNodePath(java.lang.Object[])
protected void fireTreeNodeChanged(DfcTreeNode node)
public boolean isMutable()
DfcTreeModel
isMutable
in interface DfcTreeModel
public void setMutable(boolean newValue)
public Object getParent(Object entry)
DfcTreeModel
getParent
in interface DfcTreeModel
public Object[] getPathForEntry(Object entry)
DfcTreeModel
getPathForEntry
in interface DfcTreeModel
public boolean canAddEntry(Object parent, Object entry, int index)
DfcTreeModel
canAddEntry
in interface DfcTreeModel
parent
- The parent entry.entry
- The child entry.index
- The index to add the child at. Use -1 to add child
at end.public void addEntry(Object parent, Object entry, int index) throws UnsupportedOperationException, IndexOutOfBoundsException
DfcTreeModel
addEntry
in interface DfcTreeModel
parent
- The parent entry.entry
- The child entry.index
- The index to add the child at. Use -1 to add child
at end.
UnsupportedOperationException
IndexOutOfBoundsException
public boolean canRemoveEntry(Object entry)
DfcTreeModel
canRemoveEntry
in interface DfcTreeModel
public void removeEntry(Object entry) throws UnsupportedOperationException
DfcTreeModel
removeEntry
in interface DfcTreeModel
UnsupportedOperationException
public boolean canMoveEntry(Object entry, Object newParent, int newIndex)
canMoveEntry
in interface DfcTreeModel
public void moveEntry(Object entry, Object newParent, int newIndex) throws UnsupportedOperationException, IndexOutOfBoundsException
DfcTreeModel
moveEntry
in interface DfcTreeModel
UnsupportedOperationException
IndexOutOfBoundsException
public boolean canPasteEntry(Object parent, int index, Transferable transferable)
DfcTreeModel
canPasteEntry
in interface DfcTreeModel
parent
- The parent entry to paste at.index
- The index of the new entry in parent (may be -1 to
add last).transferable
- The data to paste.public void pasteEntry(Object parent, int index, Transferable transferable) throws UnsupportedOperationException, UnsupportedFlavorException, CloneNotSupportedException, IOException
DfcTreeModel
pasteEntry
in interface DfcTreeModel
parent
- The parent entry to paste at.index
- The index of the new entry in parent (may be -1 to
add last).transferable
- The data to paste.
UnsupportedOperationException
UnsupportedFlavorException
CloneNotSupportedException
IOException
public boolean canCopyEntry(Object entry)
DfcTreeModel
canCopyEntry
in interface DfcTreeModel
entry
- The entry to copy.public Transferable copyEntry(Object entry) throws UnsupportedOperationException, CloneNotSupportedException
DfcTreeModel
copyEntry
in interface DfcTreeModel
entry
- The entry to copy.
UnsupportedOperationException
CloneNotSupportedException
public Object clone() throws CloneNotSupportedException
Copyable
NOTE: subclasses should not remove the CloneNotSupportedException throws clause if they themselves support subclassing: removing the CloneNotSupportedException declaration stops subclasses from indicating that a clone was not possible.
clone
in interface Copyable
clone
in class Object
CloneNotSupportedException
- if the clone failed or is not
possible.public DfcSwingTreeModel clone(TreeNode node) throws CloneNotSupportedException
node
- The root node in this tree to copy from.
CloneNotSupportedException
- if the tree or any of its
entries are not cloneable.public static MutableTreeNode cloneNodes(TreeNode root) throws CloneNotSupportedException
CloneNotSupportedException
Trees.cloneNodes(javax.swing.tree.TreeNode)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |