|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdsto.dfc.swing.tree.BasicTreeModelEventSource
dsto.dfc.swing.tree.DefaultDfcTreeModel
public class DefaultDfcTreeModel
Default implementation of DfcTreeModel using HashMap and ArrayList.
Note that the entries in this tree model are the data items
themselves, which are internally mapped to tree node structure
(see getNodeForEntry(java.lang.Object)
). This is convenient in many
cases, but means that objects cannot appear more than once in
the model. If this is a problem, see DfcSwingTreeModel
for a fully node-based model that avoids this problem.
Nested Class Summary | |
---|---|
static class |
DefaultDfcTreeModel.Node
A node in the tree. |
Constructor Summary | |
---|---|
DefaultDfcTreeModel()
|
|
DefaultDfcTreeModel(Object rootEntry)
|
|
DefaultDfcTreeModel(TreeModel srcModel,
Object srcRoot)
|
Method Summary | |
---|---|
DefaultDfcTreeModel.Node |
addChild(DefaultDfcTreeModel.Node parent,
Object entry)
|
DefaultDfcTreeModel.Node |
addChild(DefaultDfcTreeModel.Node parent,
Object entry,
int index)
|
void |
addEntry(Object parent,
Object child,
int index)
Add a child to parent at a given index. |
void |
addSubtree(Object trgRoot,
int trgIndex,
TreeModel srcModel,
Object srcRoot)
Copy a subtree into this model. |
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. |
DfcTreeModel |
clone(Object srcRoot)
Clone a subtree of this model. |
protected DefaultDfcTreeModel.Node |
cloneNodes(DefaultDfcTreeModel.Node node)
Clone a tree of nodes and add them to this models entry to node map. |
Transferable |
copyEntry(Object entry)
Copy an entry into a transferable. |
protected void |
copyFromSubtree(DefaultDfcTreeModel.Node trgRoot,
int trgIndex,
TreeModel srcModel,
Object srcRoot)
Copy a subtree from a TreeModel into this model. |
Object |
getChild(Object parent,
int index)
|
int |
getChildCount(Object parent)
|
int |
getIndexOfChild(Object parent,
Object child)
|
DefaultDfcTreeModel.Node |
getNodeForEntry(Object entry)
|
DefaultDfcTreeModel.Node |
getNodeForPath(Object[] path)
|
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. |
Object[] |
getPathForNode(DefaultDfcTreeModel.Node node)
|
Object |
getRoot()
|
DefaultDfcTreeModel.Node |
getRootNode()
Get the root node of the tree. |
TreePath |
getTreePathForEntry(Object entry)
|
boolean |
isLeaf(Object entry)
|
boolean |
isMutable()
True if the tree can be changed. |
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 entries from tree. |
void |
removeAllChildren(DefaultDfcTreeModel.Node node)
Remove all children of a node. |
void |
removeEntry(Object entry)
Remove an entry and any children. |
protected void |
removeEntryMappings(DefaultDfcTreeModel.Node node)
Remove all entry to node mappings for a node tree. |
void |
removeNode(DefaultDfcTreeModel.Node node)
|
void |
setMutable(boolean newValue)
|
void |
valueForPathChanged(TreePath path,
Object newValue)
|
Methods inherited from class dsto.dfc.swing.tree.BasicTreeModelEventSource |
---|
addTreeModelListener, dispose, fireTreeNodeChanged, fireTreeNodeInserted, fireTreeNodeRemoved, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeStructureChanged, getTreeModelListenerCount, removeTreeModelListener |
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, removeTreeModelListener |
Constructor Detail |
---|
public DefaultDfcTreeModel()
public DefaultDfcTreeModel(Object rootEntry)
public DefaultDfcTreeModel(TreeModel srcModel, Object srcRoot) throws CloneNotSupportedException
CloneNotSupportedException
Method Detail |
---|
public DefaultDfcTreeModel.Node getRootNode()
public boolean isMutable()
DfcTreeModel
isMutable
in interface DfcTreeModel
public void setMutable(boolean newValue)
public Object getParent(Object entry)
DfcTreeModel
getParent
in interface DfcTreeModel
public final Object[] getPathForNode(DefaultDfcTreeModel.Node node)
public final DefaultDfcTreeModel.Node getNodeForPath(Object[] path)
public DefaultDfcTreeModel.Node getNodeForEntry(Object entry)
public TreePath getTreePathForEntry(Object entry)
public Object[] getPathForEntry(Object entry)
DfcTreeModel
getPathForEntry
in interface DfcTreeModel
public DefaultDfcTreeModel.Node addChild(DefaultDfcTreeModel.Node parent, Object entry)
public DefaultDfcTreeModel.Node addChild(DefaultDfcTreeModel.Node parent, Object entry, int index)
public void removeAll()
public void removeAllChildren(DefaultDfcTreeModel.Node node)
public Object getRoot()
getRoot
in interface TreeModel
public Object getChild(Object parent, int index)
getChild
in interface TreeModel
public int getChildCount(Object parent)
getChildCount
in interface TreeModel
public boolean isLeaf(Object entry)
isLeaf
in interface TreeModel
public void valueForPathChanged(TreePath path, Object newValue)
valueForPathChanged
in interface TreeModel
public int getIndexOfChild(Object parent, Object child)
getIndexOfChild
in interface TreeModel
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 child, int index) throws UnsupportedOperationException
DfcTreeModel
addEntry
in interface DfcTreeModel
parent
- The parent entry.child
- The child entry.index
- The index to add the child at. Use -1 to add child
at end.
UnsupportedOperationException
public boolean canRemoveEntry(Object entry)
DfcTreeModel
canRemoveEntry
in interface DfcTreeModel
public void removeEntry(Object entry) throws UnsupportedOperationException
DfcTreeModel
removeEntry
in interface DfcTreeModel
UnsupportedOperationException
public void removeNode(DefaultDfcTreeModel.Node node)
protected final void removeEntryMappings(DefaultDfcTreeModel.Node node)
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 DfcTreeModel clone(Object srcRoot) throws CloneNotSupportedException
srcRoot
- The root node in this tree to copy from.
CloneNotSupportedException
- if the tree or any of its entries
are not cloneable.protected final DefaultDfcTreeModel.Node cloneNodes(DefaultDfcTreeModel.Node node) throws CloneNotSupportedException
CloneNotSupportedException
public void addSubtree(Object trgRoot, int trgIndex, TreeModel srcModel, Object srcRoot) throws CloneNotSupportedException
trgRoot
- The node in this tree to add children to.trgIndex
- The index in trgRoot to add the new subtree at.srcModel
- The source model to copy from.srcRoot
- The root node in the source model to copy children
from.
CloneNotSupportedException
protected final void copyFromSubtree(DefaultDfcTreeModel.Node trgRoot, int trgIndex, TreeModel srcModel, Object srcRoot) throws CloneNotSupportedException
trgRoot
- The root node to add new subtree to.trgIndex
- The Index to add the subtree at.srcModel
- The model to copy from.srcRoot
- The root entry in srcModel to start copying at.
CloneNotSupportedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |