ptolemy.vergil.basic
Class EditorDropTarget

java.lang.Object
  extended byjava.awt.dnd.DropTarget
      extended byptolemy.vergil.basic.EditorDropTarget
All Implemented Interfaces:
java.awt.dnd.DropTargetListener, java.util.EventListener, java.io.Serializable

public class EditorDropTarget
extends java.awt.dnd.DropTarget

This class provides drag-and-drop support. When this drop target receives a transferable object containing a ptolemy entity, it creates a new instance of the object, and adds it to the given graph. If the drop location falls on top of an icon associated with an instance of NamedObj, then the object is deposited inside that instance (so the instance becomes its container). Otherwise, the object is deposited inside the model associated with the target graph. In either case, if the target container implements the DropListener interface, then it is informed of the drop by calling its dropped() method.

Sometimes, you will want to disable the feature that a drop onto a NamedObj results in the dropped object being placed inside that NamedObj. To disable this feature, call setDropIntoEnabled() with a false argument.

Since:
Ptolemy II 2.0
Version:
$Id: EditorDropTarget.java,v 1.33 2004/04/13 03:49:38 cxh Exp $
Author:
Steve Neuendorffer and Edward A. Lee, Contributor: Michael Shilman
See Also:
Serialized Form
Accepted Rating:
Red (johnr)
Proposed Rating:
Red (eal)

Nested Class Summary
 
Nested classes inherited from class java.awt.dnd.DropTarget
java.awt.dnd.DropTarget.DropTargetAutoScroller
 
Constructor Summary
EditorDropTarget(JGraph graph)
          Construct a new graph target to operate on the given JGraph.
 
Method Summary
 boolean isDropIntoEnabled()
          Return true if the feature is enabled that a a drop onto an instance of NamedObj results in that NamedObj containing the dropped object.
 void setDropIntoEnabled(boolean enabled)
          If the argument is false, then disable the feature that a a drop onto an instance of NamedObj results in that NamedObj containing the dropped object.
 
Methods inherited from class java.awt.dnd.DropTarget
addDropTargetListener, addNotify, clearAutoscroll, createDropTargetAutoScroller, createDropTargetContext, dragEnter, dragExit, dragOver, drop, dropActionChanged, getComponent, getDefaultActions, getDropTargetContext, getFlavorMap, initializeAutoscrolling, isActive, removeDropTargetListener, removeNotify, setActive, setComponent, setDefaultActions, setFlavorMap, updateAutoscroll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EditorDropTarget

public EditorDropTarget(JGraph graph)
Construct a new graph target to operate on the given JGraph.

Parameters:
graph - The diva graph panel.
Method Detail

isDropIntoEnabled

public boolean isDropIntoEnabled()
Return true if the feature is enabled that a a drop onto an instance of NamedObj results in that NamedObj containing the dropped object. Otherwise, return false.


setDropIntoEnabled

public void setDropIntoEnabled(boolean enabled)
If the argument is false, then disable the feature that a a drop onto an instance of NamedObj results in that NamedObj containing the dropped object. If the argument is true, then reenable the feature. The feature is enabled by default.

Parameters:
enabled - False to disable the drop into feature.