com.dlsc.flexgantt.swing.treetable
Class TreeTableDragAndDropManager

java.lang.Object
  extended by com.dlsc.flexgantt.swing.treetable.TreeTableDragAndDropManager
All Implemented Interfaces:
ICommandStackListener, java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener, java.beans.PropertyChangeListener, java.util.EventListener

public class TreeTableDragAndDropManager
extends java.lang.Object
implements java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener, java.awt.dnd.DragGestureListener, ICommandStackListener, java.beans.PropertyChangeListener

A manager for the tree table that deals with anything related to drag and drop operations within or between tree tables. The manager listens for drag gestures, drag source events, and drop target events.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
INodeDragAndDropPolicy.getDragActions(Object, ITreeTableModel), INodeDragAndDropPolicy.getDropActions(Object, Object, ITreeTableModel, Object, ITreeTableModel), INodeDragAndDropPolicy.getDragAndDropCommand(Object, Object, ITreeTableModel, int, Object, ITreeTableModel, int, int), ITreeTableNode.getDragActions(), ITreeTableNode.getDropActions(ITreeTableNode)

Constructor Summary
TreeTableDragAndDropManager(TreeTable table)
          Constructs a new drag and drop manager for the given table.
 
Method Summary
 void commandStackChanged(CommandStackEvent e)
          Gets called whenever the command stack changed.
protected  java.awt.Image createDragImage(TreeTableNode node)
          Creates a drag image for the given tree table node.
 void dragDropEnd(java.awt.dnd.DragSourceDropEvent e)
           
 void dragEnter(java.awt.dnd.DragSourceDragEvent e)
           
 void dragEnter(java.awt.dnd.DropTargetDragEvent dtde)
           
 void dragExit(java.awt.dnd.DragSourceEvent dse)
           
 void dragExit(java.awt.dnd.DropTargetEvent dte)
           
 void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
           
 void dragOver(java.awt.dnd.DragSourceDragEvent dsde)
           
 void dragOver(java.awt.dnd.DropTargetDragEvent dtde)
           
 void drop(java.awt.dnd.DropTargetDropEvent dtde)
           
 void dropActionChanged(java.awt.dnd.DragSourceDragEvent dsde)
           
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent dtde)
           
 TreeTableNode getDraggedNode()
          Returns the dragged tree table node.
 java.awt.Point getDragLocation()
          Returns the current drag location.
 int getDropRow()
          Returns the row where the drop will occure when the user finishes the drop.
 TreeTable getTreeTable()
          Returns the tree table that is being managed by the DnD manager.
 boolean isAnimatingDrop()
          Determines if the drop shall be animated by the tree table.
 boolean isDragOK(java.awt.dnd.DropTargetDragEvent dtde)
          Performs all the necessary checks in order to find out whether the given drop target event specifies a valid drop location.
 boolean isValidDropLocation()
          Determines whether the current drag location is a valid drop location.
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void setAnimatingDrop(boolean animating)
          Specifies if the drop shall be animated by the tree table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeTableDragAndDropManager

public TreeTableDragAndDropManager(TreeTable table)
Constructs a new drag and drop manager for the given table.

Parameters:
table - the table that will be managed
Since:
1.0
Method Detail

getTreeTable

public TreeTable getTreeTable()
Returns the tree table that is being managed by the DnD manager.

Returns:
the managed tree table
Since:
1.0

dragEnter

public void dragEnter(java.awt.dnd.DragSourceDragEvent e)
Specified by:
dragEnter in interface java.awt.dnd.DragSourceListener

dragOver

public void dragOver(java.awt.dnd.DragSourceDragEvent dsde)
Specified by:
dragOver in interface java.awt.dnd.DragSourceListener

dropActionChanged

public void dropActionChanged(java.awt.dnd.DragSourceDragEvent dsde)
Specified by:
dropActionChanged in interface java.awt.dnd.DragSourceListener

dragExit

public void dragExit(java.awt.dnd.DragSourceEvent dse)
Specified by:
dragExit in interface java.awt.dnd.DragSourceListener

dragDropEnd

public void dragDropEnd(java.awt.dnd.DragSourceDropEvent e)
Specified by:
dragDropEnd in interface java.awt.dnd.DragSourceListener

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent dtde)
Specified by:
dragEnter in interface java.awt.dnd.DropTargetListener

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent dtde)
Specified by:
dragOver in interface java.awt.dnd.DropTargetListener

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent dtde)
Specified by:
dropActionChanged in interface java.awt.dnd.DropTargetListener

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent dte)
Specified by:
dragExit in interface java.awt.dnd.DropTargetListener

drop

public void drop(java.awt.dnd.DropTargetDropEvent dtde)
Specified by:
drop in interface java.awt.dnd.DropTargetListener

dragGestureRecognized

public void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
Specified by:
dragGestureRecognized in interface java.awt.dnd.DragGestureListener

getDropRow

public int getDropRow()
Returns the row where the drop will occure when the user finishes the drop.

Returns:
the drop row
Since:
1.0

getDraggedNode

public TreeTableNode getDraggedNode()
Returns the dragged tree table node.

Returns:
the dragged node
Since:
1.0

getDragLocation

public java.awt.Point getDragLocation()
Returns the current drag location.

Returns:
the drag location
Since:
1.0

createDragImage

protected java.awt.Image createDragImage(TreeTableNode node)
Creates a drag image for the given tree table node. Some operating systems (e.g. MacOS X) support drag images that are shown at the cursor location during a drag and drop operation. Usually the image shows the dragged object. This method will look up the standard renderer for the key value of the dragged node. The renderer will be invoked with Integer.MIN_VALUE for the column index so that the renderer knows that it is rendering the drag image.

Parameters:
node - the node that is being dragged
Returns:
an image representation of the dragged node
Since:
1.0
See Also:
DragSource.isDragImageSupported()

commandStackChanged

public void commandStackChanged(CommandStackEvent e)
Description copied from interface: ICommandStackListener
Gets called whenever the command stack changed. The event object that is passed to this method contains information about the type of event and a reference to the command that caused the event.

Specified by:
commandStackChanged in interface ICommandStackListener
Parameters:
e - the event issued by the command stack

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

isDragOK

public boolean isDragOK(java.awt.dnd.DropTargetDragEvent dtde)
Performs all the necessary checks in order to find out whether the given drop target event specifies a valid drop location. The method will return FALSE if the drop row equals -1, if the dragged node equals the node at the drop location, or if the user drop action is not supported by the drop location.

Parameters:
dtde - the drop target drag event
Returns:
TRUE if the drag is OK and the node can be dropped
Since:
1.0

isAnimatingDrop

public boolean isAnimatingDrop()
Determines if the drop shall be animated by the tree table.

Returns:
TRUE if the drop is animated with a fade-in effect
Since:
1.0

setAnimatingDrop

public void setAnimatingDrop(boolean animating)
Specifies if the drop shall be animated by the tree table.

Parameters:
animating - if TRUE the drop will be animated with a fade-in effect
Since:
1.0

isValidDropLocation

public boolean isValidDropLocation()
Determines whether the current drag location is a valid drop location. The tree table can use this information to provide visual feedback about the validity of a drag location.

Returns:
TRUE if the current drag location is a valid drop location
Since:
1.0