org.archiviststoolkit.swing.jTreeDnD
Class NodeMoveTransferHandler

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by org.archiviststoolkit.swing.jTreeDnD.NodeMoveTransferHandler
All Implemented Interfaces:
java.io.Serializable

public class NodeMoveTransferHandler
extends javax.swing.TransferHandler

NodeMoveTransferHandler.java

Transfer handler implementation that supports to move a selected tree node within a JTree.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, MOVE, NONE
 
Constructor Summary
NodeMoveTransferHandler()
          constructor
 
Method Summary
protected  java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent c)
          create a transferable that contains all paths that are currently selected in a given tree
protected  void exportDone(javax.swing.JComponent source, java.awt.datatransfer.Transferable data, int action)
          move selected paths when export of drag is done
 java.awt.image.BufferedImage getDragImage(javax.swing.JTree tree)
          get a drag image from the currently dragged node (if any)
 int getSourceActions(javax.swing.JComponent c)
          Returns the type of transfer actions supported by the source.
 
Methods inherited from class javax.swing.TransferHandler
canImport, exportAsDrag, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getVisualRepresentation, importData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeMoveTransferHandler

public NodeMoveTransferHandler()
constructor

Method Detail

createTransferable

protected java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent c)
create a transferable that contains all paths that are currently selected in a given tree

Overrides:
createTransferable in class javax.swing.TransferHandler
Returns:
all selected paths in the given tree (or null if the given component is not a tree)
See Also:
TransferHandler.createTransferable(javax.swing.JComponent)

exportDone

protected void exportDone(javax.swing.JComponent source,
                          java.awt.datatransfer.Transferable data,
                          int action)
move selected paths when export of drag is done

Overrides:
exportDone in class javax.swing.TransferHandler
Parameters:
source - the component that was the source of the data
data - the data that was transferred or possibly null if the action is NONE.
action - the actual action that was performed

getSourceActions

public int getSourceActions(javax.swing.JComponent c)
Returns the type of transfer actions supported by the source. This transfer handler supports moving of tree nodes so it returns MOVE.

Overrides:
getSourceActions in class javax.swing.TransferHandler
Returns:
TransferHandler.MOVE

getDragImage

public java.awt.image.BufferedImage getDragImage(javax.swing.JTree tree)
get a drag image from the currently dragged node (if any)

Parameters:
tree - the tree showing the node
Returns:
the image to draw during drag