dsto.dfc.swing.tree
Class AbstractDfcTreeModel

java.lang.Object
  extended by dsto.dfc.swing.tree.BasicTreeModelEventSource
      extended by dsto.dfc.swing.tree.AbstractDfcTreeModel
All Implemented Interfaces:
DfcTreeModel, Disposable, Serializable, TreeModel
Direct Known Subclasses:
CommandViewTreeModel

public abstract class AbstractDfcTreeModel
extends BasicTreeModelEventSource
implements DfcTreeModel

Base class for clients implementing DfcTreeModel.

Version:
$Revision$
See Also:
Serialized Form

Constructor Summary
AbstractDfcTreeModel()
           
 
Method Summary
 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.
 Transferable copyEntry(Object entry)
          Copy an entry into a transferable.
abstract  Object getChild(Object parent, int index)
           
abstract  int getChildCount(Object parent)
           
abstract  int getIndexOfChild(Object parent, Object child)
           
abstract  Object getParent(Object entry)
          Get the parent for a given entry, or null if the entry is the root.
 Object[] getPathForEntry(Object entry)
          Basic implementation using getRoot () and getParent ().
abstract  Object getRoot()
           
 boolean isAncestor(Object ancestor, Object entry)
           
abstract  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 removeEntry(Object entry)
          Remove an entry and any children.
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, removeTreeModelListener
 

Constructor Detail

AbstractDfcTreeModel

public AbstractDfcTreeModel()
Method Detail

isAncestor

public boolean isAncestor(Object ancestor,
                          Object entry)

getRoot

public abstract Object getRoot()
Specified by:
getRoot in interface TreeModel

getChild

public abstract Object getChild(Object parent,
                                int index)
Specified by:
getChild in interface TreeModel

getChildCount

public abstract int getChildCount(Object parent)
Specified by:
getChildCount in interface TreeModel

isLeaf

public abstract boolean isLeaf(Object entry)
Specified by:
isLeaf in interface TreeModel

getIndexOfChild

public abstract int getIndexOfChild(Object parent,
                                    Object child)
Specified by:
getIndexOfChild in interface TreeModel

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Specified by:
valueForPathChanged in interface TreeModel

getParent

public abstract Object getParent(Object entry)
Description copied from interface: DfcTreeModel
Get the parent for a given entry, or null if the entry is the root.

Specified by:
getParent in interface DfcTreeModel

getPathForEntry

public Object[] getPathForEntry(Object entry)
Basic implementation using getRoot () and getParent (). Superclasses may want to provide a more efficient implementation.

Specified by:
getPathForEntry in interface DfcTreeModel
Returns:
the path for the entry or null if entry does not exist in the tree.

isMutable

public boolean isMutable()
Description copied from interface: DfcTreeModel
True if the tree can be changed. The can* methods indicate what operations are permitted.

Specified by:
isMutable in interface DfcTreeModel

canAddEntry

public boolean canAddEntry(Object parent,
                           Object entry,
                           int index)
Description copied from interface: DfcTreeModel
Test if a child can be added at a given index.

Specified by:
canAddEntry in interface DfcTreeModel
Parameters:
parent - The parent entry.
entry - The child entry.
index - The index to add the child at. Use -1 to add child at end.

addEntry

public void addEntry(Object parent,
                     Object entry,
                     int index)
              throws UnsupportedOperationException,
                     IndexOutOfBoundsException
Description copied from interface: DfcTreeModel
Add a child to parent at a given index.

Specified by:
addEntry in interface DfcTreeModel
Parameters:
parent - The parent entry.
entry - The child entry.
index - The index to add the child at. Use -1 to add child at end.
Throws:
UnsupportedOperationException
IndexOutOfBoundsException

canRemoveEntry

public boolean canRemoveEntry(Object entry)
Description copied from interface: DfcTreeModel
Test if an entry may be removed.

Specified by:
canRemoveEntry in interface DfcTreeModel

removeEntry

public void removeEntry(Object entry)
                 throws UnsupportedOperationException
Description copied from interface: DfcTreeModel
Remove an entry and any children.

Specified by:
removeEntry in interface DfcTreeModel
Throws:
UnsupportedOperationException

canMoveEntry

public boolean canMoveEntry(Object entry,
                            Object newParent,
                            int newIndex)
Specified by:
canMoveEntry in interface DfcTreeModel

moveEntry

public void moveEntry(Object entry,
                      Object newParent,
                      int newIndex)
               throws UnsupportedOperationException,
                      IndexOutOfBoundsException
Description copied from interface: DfcTreeModel
Move a child from one location to another. In the case where the old and new parents are the same, newIndex refers to the index space before any changes has been made.

Specified by:
moveEntry in interface DfcTreeModel
Throws:
UnsupportedOperationException
IndexOutOfBoundsException

canPasteEntry

public boolean canPasteEntry(Object parent,
                             int index,
                             Transferable transferable)
Description copied from interface: DfcTreeModel
Test if a transferable may be pasted.

Specified by:
canPasteEntry in interface DfcTreeModel
Parameters:
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.

pasteEntry

public void pasteEntry(Object parent,
                       int index,
                       Transferable transferable)
                throws UnsupportedOperationException,
                       UnsupportedFlavorException,
                       CloneNotSupportedException,
                       IOException
Description copied from interface: DfcTreeModel
Paste transferable data into the tree.

Specified by:
pasteEntry in interface DfcTreeModel
Parameters:
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.
Throws:
UnsupportedOperationException
UnsupportedFlavorException
CloneNotSupportedException
IOException

canCopyEntry

public boolean canCopyEntry(Object entry)
Description copied from interface: DfcTreeModel
Test if an entry may be copied into a transferable.

Specified by:
canCopyEntry in interface DfcTreeModel
Parameters:
entry - The entry to copy.

copyEntry

public Transferable copyEntry(Object entry)
                       throws UnsupportedOperationException,
                              CloneNotSupportedException
Description copied from interface: DfcTreeModel
Copy an entry into a transferable.

Specified by:
copyEntry in interface DfcTreeModel
Parameters:
entry - The entry to copy.
Throws:
UnsupportedOperationException
CloneNotSupportedException


Copyright © 2008 Commonwealth of Australia