edu.northwestern.at.utils.swing
Class TreeDragSource

java.lang.Object
  extended by edu.northwestern.at.utils.swing.XDragSource
      extended by edu.northwestern.at.utils.swing.TreeDragSource
All Implemented Interfaces:
java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.util.EventListener

public abstract class TreeDragSource
extends XDragSource

An abstract base class for JTree drag source components.

Dragging multiple node selections is supported. This class takes care of building the drag image. The concrete subclass takes care of building the drag data via the getTransferable method which it must implement.


Constructor Summary
TreeDragSource(javax.swing.JTree tree)
          Constructs a new tree drag source.
 
Method Summary
 void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
          Handles drag gesture recognized events.
abstract  java.awt.datatransfer.Transferable getTransferable()
          Gets the drag data.
 
Methods inherited from class edu.northwestern.at.utils.swing.XDragSource
dragDropEnd, dragEnter, dragExit, dragOver, dropActionChanged, getCurrentDragData, getCurrentDragSource, getTriggerEvent, startDrag, startDrag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeDragSource

public TreeDragSource(javax.swing.JTree tree)
Constructs a new tree drag source.

Parameters:
tree - The tree.
Method Detail

dragGestureRecognized

public void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
Handles drag gesture recognized events.

If the drag originated in a non-selected node, that node is selected. Otherwise the selection is unchanged.

Builds a drag image for all the selected tree nodes, asks the subclass to build the drag data, then invokes XDragSource.startDrag to start the drag.

Specified by:
dragGestureRecognized in interface java.awt.dnd.DragGestureListener
Specified by:
dragGestureRecognized in class XDragSource
Parameters:
dge - The event.

getTransferable

public abstract java.awt.datatransfer.Transferable getTransferable()
Gets the drag data.

Returns:
The drag data.