CubeTwister 2.0alpha141 2011-10-13

ch.randelshofer.gui.tree
Interface MutableTreeModel

All Superinterfaces:
javax.swing.tree.TreeModel
All Known Implementing Classes:
DefaultMutableTreeModel, DocumentModel

public interface MutableTreeModel
extends javax.swing.tree.TreeModel

Specifies the requirements for a mutable tree model.

The mutable list model adds support for the following operations to the javax.swing.tree.TreeModel interface:

Version:
3.2 2011-01-23 Adds property change support.
3.1 2009-12-22 Methods createNodeAt and importTransferable return paths of inserted nodes. Use DefaultMutableTreeNode instead of MutableTreeNode. Adds undo support.
3.0 2004-05-16 Revised.
2.3 2002-04-08 Interface streamlined. Support for Transferables added.
2.0.1 2002-04-07 Method getInsertableRowTypes added.
2.0 2001-07-18
Author:
Werner Randelshofer

Field Summary
static java.lang.String ENABLED_PROPERTY
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a PropertyChangeListener.
 void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
          Adds an UndoableEditListener.
 javax.swing.tree.TreePath createNodeAt(java.lang.Object type, javax.swing.tree.DefaultMutableTreeNode parent, int index)
          Creates the specified element type at the specified position in this list Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
 java.awt.datatransfer.Transferable exportTransferable(javax.swing.tree.DefaultMutableTreeNode[] nodes)
          Creates a Transferable to use as the source for a data transfer of the specified elements.
 void fireUndoableEdit(javax.swing.undo.UndoableEdit edit)
          Notify all listeners that have registered interest for notification on this event type.
 java.lang.Object getCreatableNodeType(java.lang.Object parent)
          Returns the default type of children that can be created at the specified node.
 java.lang.Object[] getCreatableNodeTypes(java.lang.Object parent)
          Returns the types of children that may be created at this node.
 javax.swing.Action[] getNodeActions(javax.swing.tree.DefaultMutableTreeNode[] nodes)
          Gets actions for the specified nodes.
 java.util.List<javax.swing.tree.TreePath> importTransferable(java.awt.datatransfer.Transferable t, int action, javax.swing.tree.DefaultMutableTreeNode parent, int index)
          Causes a transfer to the model from a clipboard or a DND drop operation.
 boolean isImportable(java.awt.datatransfer.DataFlavor[] transferFlavors, int action, javax.swing.tree.DefaultMutableTreeNode parent, int index)
          Indicates whether the model would accept an import of the given set of data flavors prior to actually attempting to import it.
 boolean isNodeAddable(javax.swing.tree.DefaultMutableTreeNode parent, int index)
          Returns whether a node may be added.
 boolean isNodeEditable(javax.swing.tree.DefaultMutableTreeNode node)
          Returns wether the specified node may be edited.
 boolean isNodeRemovable(javax.swing.tree.DefaultMutableTreeNode node)
          Returns whether the specified node may be removed.
 void removeNodeFromParent(javax.swing.tree.DefaultMutableTreeNode node)
          Message this to remove a child from its parent.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a PropertyChangeListener.
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
          Removes an UndoableEditListener.
 
Methods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, getChild, getChildCount, getIndexOfChild, getRoot, isLeaf, removeTreeModelListener, valueForPathChanged
 

Field Detail

ENABLED_PROPERTY

static final java.lang.String ENABLED_PROPERTY
See Also:
Constant Field Values
Method Detail

getCreatableNodeTypes

java.lang.Object[] getCreatableNodeTypes(java.lang.Object parent)
Returns the types of children that may be created at this node.

Parameters:
parent - a node from the tree, obtained from this data source.
Returns:
an array of objects that specify a child type that may be added to the node. Returns an empty array for nodes that cannot have additional children.

getCreatableNodeType

java.lang.Object getCreatableNodeType(java.lang.Object parent)
Returns the default type of children that can be created at the specified node.

Parameters:
parent - a node from the tree, obtained from this data source.
Returns:
an Object that specifies the default child type that can be inserted at the insertion point. Returns null if no children can be inserted here. The value must be one of the types returned by operation getCreatableNodeTypes.

createNodeAt

javax.swing.tree.TreePath createNodeAt(java.lang.Object type,
                                       javax.swing.tree.DefaultMutableTreeNode parent,
                                       int index)
                                       throws java.lang.IllegalStateException
Creates the specified element type at the specified position in this list Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

This method may create a node at a different location.

Parameters:
type - the type of the new child to be created, obtained from getCreatableChildren
parent - a node from the tree, obtained from this data source.
index - index of the child.
Returns:
The path pointing to the newly created node.
Throws:
java.lang.IllegalArgumentException - if the type is not contained in the array returned by getInsertableTypes(int).
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).
java.lang.IllegalStateException

isNodeAddable

boolean isNodeAddable(javax.swing.tree.DefaultMutableTreeNode parent,
                      int index)
Returns whether a node may be added.

Parameters:
parent - a node from the tree, obtained from this data source.
index - the insertion index.

isNodeRemovable

boolean isNodeRemovable(javax.swing.tree.DefaultMutableTreeNode node)
Returns whether the specified node may be removed.

Parameters:
node - a node from the tree, obtained from this data source.

removeNodeFromParent

void removeNodeFromParent(javax.swing.tree.DefaultMutableTreeNode node)
Message this to remove a child from its parent.

Parameters:
node - a node from the tree, obtained from this data source.
Throws:
java.lang.IllegalStateException - if the node may not be removed.

isNodeEditable

boolean isNodeEditable(javax.swing.tree.DefaultMutableTreeNode node)
Returns wether the specified node may be edited.

Parameters:
node - a node from the tree, obtained from this data source.

getNodeActions

javax.swing.Action[] getNodeActions(javax.swing.tree.DefaultMutableTreeNode[] nodes)
Gets actions for the specified nodes.

Parameters:
nodes - The nodes.

exportTransferable

java.awt.datatransfer.Transferable exportTransferable(javax.swing.tree.DefaultMutableTreeNode[] nodes)
Creates a Transferable to use as the source for a data transfer of the specified elements. Returns the representation of the rows to be transferred, or null if transfer is not possible.

Parameters:
nodes - The nodes.

isImportable

boolean isImportable(java.awt.datatransfer.DataFlavor[] transferFlavors,
                     int action,
                     javax.swing.tree.DefaultMutableTreeNode parent,
                     int index)
Indicates whether the model would accept an import of the given set of data flavors prior to actually attempting to import it.

Parameters:
transferFlavors - the data formats available
action - the action, this is either COPY, MOVE or LINK.
parent - a node from the tree, obtained from this data source.
index - The insertion point.
Returns:
true if the data can be inserted into the component, false otherwise

importTransferable

java.util.List<javax.swing.tree.TreePath> importTransferable(java.awt.datatransfer.Transferable t,
                                                             int action,
                                                             javax.swing.tree.DefaultMutableTreeNode parent,
                                                             int index)
                                                             throws java.awt.datatransfer.UnsupportedFlavorException,
                                                                    java.io.IOException
Causes a transfer to the model from a clipboard or a DND drop operation.

Parameters:
t - The transfer data.
parent - a node from the tree, obtained from this data source.
index - The insertion point.
Returns:
The paths of the imported nodes.
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

removeUndoableEditListener

void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
Removes an UndoableEditListener.


addUndoableEditListener

void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
Adds an UndoableEditListener.


fireUndoableEdit

void fireUndoableEdit(javax.swing.undo.UndoableEdit edit)
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.


removePropertyChangeListener

void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener.


addPropertyChangeListener

void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener.


(c) Werner Randelshofer.
All rights reserved.