Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


oracle.javatools.editor.plugins
Class DropTargetPlugin

java.lang.Object
  extended by oracle.javatools.editor.plugins.DropTargetPlugin

All Implemented Interfaces:
java.awt.dnd.DropTargetListener, java.beans.PropertyChangeListener, java.util.EventListener, EditorPlugin
Direct Known Subclasses:
DragDropPlugin

public class DropTargetPlugin
extends java.lang.Object
implements java.awt.dnd.DropTargetListener, EditorPlugin

The DropTargetPlugin is an editor plugin which adds drop support to the BasicEditorPane so that it can accept drop operations for Drag-n-Drop. This does not provide support for initiating a drag operation from the editor however.


Field Summary
protected static EditDescriptor DROP_DESCRIPTOR
          The edit (undo) descriptor for a drop operation.
protected static int DROP_RECT_WIDTH
          The width of the drop rectangle to paint - since drawRect() is used, a width of 1 is a thickness of 2.
protected  java.awt.dnd.DropTarget dropTarget
          The drop target associated with the editor.
protected  BasicEditorPane editor
          The editor that this plugin is installed into.
protected  java.awt.Rectangle lastDropRect
          The last drop rectangle that was painted.
protected static java.awt.datatransfer.DataFlavor PLAIN_FLAVOR
          The plain text flavor to use.
protected static java.awt.datatransfer.DataFlavor STRING_FLAVOR
          The string flavor to use.

 

Constructor Summary
DropTargetPlugin()
          Constructs a new DropTargetPlugin instance that adds drop capability to the editor for text drops.

 

Method Summary
protected  void cancelDragEvent(java.awt.dnd.DropTargetEvent event)
          Utility method to handle case where the drop is cancelled because the drag has left the component.
protected  void clearDropLocation()
          Utility method to force a repaint of the last drop location that was painted (if any.)
 void deinstall(BasicEditorPane editor)
          Called when the plugin is being removed from the BasicEditorPane (for example when the editor is closed.) This is used to notify plugins that they should unregister any listeners that were attached.
 void dragEnter(java.awt.dnd.DropTargetDragEvent event)
          Called when a drag operation has encountered the DropTarget.
 void dragExit(java.awt.dnd.DropTargetEvent event)
          The drag operation has departed the DropTarget without dropping.
 void dragOver(java.awt.dnd.DropTargetDragEvent event)
          Called when a drag operation is ongoing on the DropTarget.
 void drop(java.awt.dnd.DropTargetDropEvent event)
          The drag operation has terminated with a drop on this DropTarget.
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
          Called if the user has modified the current drop gesture.
protected  BasicDocument getDocument()
          Fetch the document of the editor.
protected  java.awt.Rectangle getDropRectangle(java.awt.Point location)
          Utility method to fetch the rectangle corresponding to a given location.
protected  java.awt.datatransfer.DataFlavor getPreferredDataFlavor(java.awt.datatransfer.Transferable transferable)
          Utility method to choose the data flavor to use for the transfer based on the transferable in the drag/drop operation.
protected  java.awt.datatransfer.DataFlavor[] getSupportedFlavors()
          Fetch the DataFlavors that can be accepted by this drop target.
protected  java.lang.String getTransferText(java.awt.datatransfer.Transferable transferable)
          Utility method to fetch the text to drop based on the transferable in the drag and drop operation
protected  void handleDragEvent(java.awt.dnd.DropTargetDragEvent event)
          Utility method to handle the various drag events that occur prior to the actual drop.
protected  void handleDropEvent(java.awt.dnd.DropTargetDropEvent event)
          Utility method to handle the actual drop event that occurred.
 void install(BasicEditorPane editor)
          Called when this plugin is being installed into the BasicEditorPane.
protected  boolean isDataFlavorSupported(java.awt.dnd.DropTargetDragEvent event)
          Utility method to check if the data flavor of the transferable in the drag and drop operation is supported by us.
protected  boolean isDataFlavorSupported(java.awt.dnd.DropTargetDropEvent event)
          Utility method to check if the data flavor of the transferable in the drag and drop operation is supported by us.
protected  boolean isDropActionSupported(int requestedAction)
          Utility method to check if the requested drop operation (i.e., COPY) is supported.
protected  void paintDropLocation(java.awt.Point newLocation)
          Utility method to request a repaint of the new drop location specified by the given location.
 void propertyChange(java.beans.PropertyChangeEvent event)
          This method gets called when a bound property is changed.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

editor

protected BasicEditorPane editor
The editor that this plugin is installed into.

dropTarget

protected java.awt.dnd.DropTarget dropTarget
The drop target associated with the editor.

lastDropRect

protected java.awt.Rectangle lastDropRect
The last drop rectangle that was painted.

DROP_RECT_WIDTH

protected static final int DROP_RECT_WIDTH
The width of the drop rectangle to paint - since drawRect() is used, a width of 1 is a thickness of 2.
See Also:
Constant Field Values

STRING_FLAVOR

protected static final java.awt.datatransfer.DataFlavor STRING_FLAVOR
The string flavor to use.

PLAIN_FLAVOR

protected static final java.awt.datatransfer.DataFlavor PLAIN_FLAVOR
The plain text flavor to use.

DROP_DESCRIPTOR

protected static final EditDescriptor DROP_DESCRIPTOR
The edit (undo) descriptor for a drop operation.

Constructor Detail

DropTargetPlugin

public DropTargetPlugin()
Constructs a new DropTargetPlugin instance that adds drop capability to the editor for text drops.

Method Detail

install

public void install(BasicEditorPane editor)
Called when this plugin is being installed into the BasicEditorPane.
Specified by:
install in interface EditorPlugin
Parameters:
editor - the editor pane

deinstall

public void deinstall(BasicEditorPane editor)
Called when the plugin is being removed from the BasicEditorPane (for example when the editor is closed.) This is used to notify plugins that they should unregister any listeners that were attached.
Specified by:
deinstall in interface EditorPlugin
Parameters:
editor - the editor pane

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - A PropertyChangeEvent object describing the event source and the property that has changed.

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent event)
Called when a drag operation has encountered the DropTarget.
Specified by:
dragEnter in interface java.awt.dnd.DropTargetListener
Parameters:
event - the DropTargetDragEvent that occurred

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent event)
Called when a drag operation is ongoing on the DropTarget.
Specified by:
dragOver in interface java.awt.dnd.DropTargetListener
Parameters:
event - the DropTargetDragEvent that occurred

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
Called if the user has modified the current drop gesture.
Specified by:
dropActionChanged in interface java.awt.dnd.DropTargetListener
Parameters:
event - the DropTargetDragEvent that occurred

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent event)
The drag operation has departed the DropTarget without dropping.
Specified by:
dragExit in interface java.awt.dnd.DropTargetListener
Parameters:
event - the DropTargetEvent that occurred

drop

public void drop(java.awt.dnd.DropTargetDropEvent event)
The drag operation has terminated with a drop on this DropTarget. This method is responsible for undertaking the transfer of the data associated with the gesture. The DropTargetDropEvent provides a means to obtain a Transferable object that represents the data object(s) to be transfered.

From this method, the DropTargetListener shall accept or reject the drop via the acceptDrop(int dropAction) or rejectDrop() methods of the DropTargetDropEvent parameter.

Subsequent to acceptDrop(), but not before, DropTargetDropEvent's getTransferable() method may be invoked, and data transfer may be performed via the returned Transferable's getTransferData() method.

At the completion of a drop, an implementation of this method is required to signal the success/failure of the drop by passing an appropriate boolean to the DropTargetDropEvent's dropComplete(boolean success) method.

Note: The actual processing of the data transfer is not required to finish before this method returns. It may be deferred until later.

Specified by:
drop in interface java.awt.dnd.DropTargetListener
Parameters:
event - the DropTargetDropEvent that occurred

getDocument

protected BasicDocument getDocument()
Fetch the document of the editor.
Returns:
the editor document

getDropRectangle

protected java.awt.Rectangle getDropRectangle(java.awt.Point location)
Utility method to fetch the rectangle corresponding to a given location. This can be used to paint a drop location for example.
Parameters:
location - the location to get the rectangle for
Returns:
a rectangle for the given offset location

clearDropLocation

protected void clearDropLocation()
Utility method to force a repaint of the last drop location that was painted (if any.)

paintDropLocation

protected void paintDropLocation(java.awt.Point newLocation)
Utility method to request a repaint of the new drop location specified by the given location.
Parameters:
newLocation - the new location to paint

cancelDragEvent

protected void cancelDragEvent(java.awt.dnd.DropTargetEvent event)
Utility method to handle case where the drop is cancelled because the drag has left the component. This gives us a chance to clean up anything we need to.
Parameters:
event - the event that occurred

handleDropEvent

protected void handleDropEvent(java.awt.dnd.DropTargetDropEvent event)
Utility method to handle the actual drop event that occurred.
Parameters:
event - the actual drop event that occurred

getTransferText

protected java.lang.String getTransferText(java.awt.datatransfer.Transferable transferable)
Utility method to fetch the text to drop based on the transferable in the drag and drop operation
Parameters:
transferable - the transferable involved
Returns:
the text contained in the transferable

getPreferredDataFlavor

protected java.awt.datatransfer.DataFlavor getPreferredDataFlavor(java.awt.datatransfer.Transferable transferable)
Utility method to choose the data flavor to use for the transfer based on the transferable in the drag/drop operation.
Parameters:
transferable - the transferable involved
Returns:
the preferred data flavor

handleDragEvent

protected void handleDragEvent(java.awt.dnd.DropTargetDragEvent event)
Utility method to handle the various drag events that occur prior to the actual drop.
Parameters:
event - the event that occurred

isDropActionSupported

protected boolean isDropActionSupported(int requestedAction)
Utility method to check if the requested drop operation (i.e., COPY) is supported.
Parameters:
requestedAction - the requested drag/drop operation
Returns:
if the requested drag/drop operation is supported

isDataFlavorSupported

protected boolean isDataFlavorSupported(java.awt.dnd.DropTargetDragEvent event)
Utility method to check if the data flavor of the transferable in the drag and drop operation is supported by us.
Parameters:
event - the drag event that occurred
Returns:
if this is a supported data flavor

isDataFlavorSupported

protected boolean isDataFlavorSupported(java.awt.dnd.DropTargetDropEvent event)
Utility method to check if the data flavor of the transferable in the drag and drop operation is supported by us.
Parameters:
event - the drag event that occurred
Returns:
if this is a supported data flavor

getSupportedFlavors

protected java.awt.datatransfer.DataFlavor[] getSupportedFlavors()
Fetch the DataFlavors that can be accepted by this drop target. The order of the DataFlavors indicates preference by this target.
Returns:
an array of the data flavors supported by this target

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


Copyright © 1997, 2012, Oracle. All rights reserved.