Extension SDK 10.1.2

oracle.javatools.editor.plugins
Class DragDropPlugin

java.lang.Object
  extended byoracle.javatools.editor.plugins.DropTargetPlugin
      extended byoracle.javatools.editor.plugins.DragDropPlugin
All Implemented Interfaces:
java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener, EditorPlugin, java.util.EventListener, java.beans.PropertyChangeListener

public class DragDropPlugin
extends DropTargetPlugin
implements java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener

The DragDropPlugin is an editor plugin which extends the DropTargetPlugin to support full Drag-N-Drop functionality for the BasicEditorPane.


Nested Class Summary
protected  class DragDropPlugin.DragCaret
          The DragCaret class extends the editor caret implementation to support the initiation of dragging without moving the cursor.
protected  class DragDropPlugin.DragTransferable
          The DragTransferable class provides extra information like the editor and offset where the data comes from.
 
Field Summary
protected static EditDescriptor DRAG_DESCRIPTOR
          The edit (undo) descriptor for a drag operation.
protected static EditDescriptor DRAGDROP_DESCRIPTOR
          The edit (undo) descriptor for a drag and drop operation within the same editor.
protected  boolean dragInProgress
          Whether a drag operation was actually started.
protected  java.awt.dnd.DragGestureRecognizer dragRecognizer
          The drag gesture recognizer associated with this editor.
protected  int dropOffset
          The offset where the drop occurred.
protected  boolean focusWasGained
          Whether the focus was just gained.
protected  javax.swing.text.Caret originalCaret
          Preserve the old caret that was used before the Drag plugin was installed.
protected static java.awt.datatransfer.DataFlavor OUR_FLAVOR
          Our custom data flavor which has extra information, like the editor and offset info.
protected  boolean queuedPopupTrigger
          Whether an "isPopupTrigger = true" from a mousePressed has been queued due to us eating the mousePressed for drag and drop.
protected  boolean selectionClicked
          Whether the current mouse press occurred in a selection.
 
Fields inherited from class oracle.javatools.editor.plugins.DropTargetPlugin
DROP_DESCRIPTOR, DROP_RECT_WIDTH, dropTarget, editor, lastDropRect, PLAIN_FLAVOR, STRING_FLAVOR
 
Constructor Summary
DragDropPlugin()
          Constructs a new DragDropPlugin instance that adds drag-n-drop capability to the editor.
 
Method Summary
protected  void cancelDragEvent(java.awt.dnd.DragSourceEvent event)
          Utility method to handle the case where the drag cursor has exited a viable DropTarget - note that this does not mean that the drag operation has been cancelled completely though.
 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.
protected  void deinstallDragCaret()
          Utility method to swap out our custom drag caret when this plugin is deinstalled.
 void dragDropEnd(java.awt.dnd.DragSourceDropEvent event)
          This method is invoked to signify that the Drag and Drop operation is complete.
 void dragEnter(java.awt.dnd.DragSourceDragEvent event)
          Called as the hotspot enters a platform dependent drop site.
 void dragExit(java.awt.dnd.DragSourceEvent event)
          Called as the hotspot exits a platform dependent drop site.
 void dragGestureRecognized(java.awt.dnd.DragGestureEvent event)
          A DragGestureRecognizer has detected a platform-dependent drag initiating gesture and is notifying this listener in order for it to initiate the action for the user.
 void dragOver(java.awt.dnd.DragSourceDragEvent event)
          Called as the hotspot moves over a platform dependent drop site.
 void dropActionChanged(java.awt.dnd.DragSourceDragEvent event)
          Called when the user has modified the drop gesture.
protected  void exchangeCaret(javax.swing.text.Caret oldCaret, javax.swing.text.Caret newCaret)
          Utility method to swap editor carets.
protected  void handleDragEvent(java.awt.dnd.DragSourceDragEvent event)
          Utility method to handle the various drag events that occur on the DragSource side before the actual drop occurs.
protected  void handleDropEvent(java.awt.dnd.DragSourceDropEvent event)
          Utility method to handle the actual drop event for the DragSource side of things.
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  void installDragCaret()
          Utility method to install and swap in our custom drag caret to support drag functionality.
 void propertyChange(java.beans.PropertyChangeEvent event)
          This method gets called when a bound property is changed.
protected  void removeSelectedText()
          Utility method to remove the selected text of editor.
protected  void updateDragCursor(java.awt.dnd.DragSourceEvent event, int dropAction)
          Utility method to update the drag cursor based on the given event.
 
Methods inherited from class oracle.javatools.editor.plugins.DropTargetPlugin
cancelDragEvent, clearDropLocation, dragEnter, dragExit, dragOver, drop, dropActionChanged, getDocument, getDropRectangle, getPreferredDataFlavor, getSupportedFlavors, getTransferText, handleDragEvent, isDataFlavorSupported, isDataFlavorSupported, isDropActionSupported, paintDropLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

originalCaret

protected javax.swing.text.Caret originalCaret
Preserve the old caret that was used before the Drag plugin was installed.


dragRecognizer

protected java.awt.dnd.DragGestureRecognizer dragRecognizer
The drag gesture recognizer associated with this editor.


selectionClicked

protected boolean selectionClicked
Whether the current mouse press occurred in a selection. This can be true ONLY between the mousePressed() and mouseReleased().


queuedPopupTrigger

protected boolean queuedPopupTrigger
Whether an "isPopupTrigger = true" from a mousePressed has been queued due to us eating the mousePressed for drag and drop. The isPopupTrigger will be set by us in the subsequent mousePressed event we generate.


dragInProgress

protected boolean dragInProgress
Whether a drag operation was actually started. If it was, then we basically just ignore any mouse events.


dropOffset

protected int dropOffset
The offset where the drop occurred. This is used only when the drag and the drop are both in the same editor - the drop operation records the offset where the drop occurs, and lets the drag portion take care of the entire operation.


DRAG_DESCRIPTOR

protected static final EditDescriptor DRAG_DESCRIPTOR
The edit (undo) descriptor for a drag operation.


DRAGDROP_DESCRIPTOR

protected static final EditDescriptor DRAGDROP_DESCRIPTOR
The edit (undo) descriptor for a drag and drop operation within the same editor.


focusWasGained

protected boolean focusWasGained
Whether the focus was just gained. In JDK 1.3.1_02, the mousePressed() can occur after the focusGained(), and the dragGesture still picked up.


OUR_FLAVOR

protected static final java.awt.datatransfer.DataFlavor OUR_FLAVOR
Our custom data flavor which has extra information, like the editor and offset info.

Constructor Detail

DragDropPlugin

public DragDropPlugin()
Constructs a new DragDropPlugin instance that adds drag-n-drop capability to the editor.

Method Detail

install

public void install(BasicEditorPane editor)
Called when this plugin is being installed into the BasicEditorPane.

Specified by:
install in interface EditorPlugin
Overrides:
install in class DropTargetPlugin
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
Overrides:
deinstall in class DropTargetPlugin
Parameters:
editor - the editor pane

installDragCaret

protected void installDragCaret()
Utility method to install and swap in our custom drag caret to support drag functionality.


deinstallDragCaret

protected void deinstallDragCaret()
Utility method to swap out our custom drag caret when this plugin is deinstalled.


exchangeCaret

protected void exchangeCaret(javax.swing.text.Caret oldCaret,
                             javax.swing.text.Caret newCaret)
Utility method to swap editor carets. This will take care of restoring things like blink rates, dots, marks, and so on.

Parameters:
oldCaret - the old caret that is currently in the editor
newCaret - the new caret to be installed into the editor

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
Overrides:
propertyChange in class DropTargetPlugin
Parameters:
event - A PropertyChangeEvent object describing the event source and the property that has changed.

dragGestureRecognized

public void dragGestureRecognized(java.awt.dnd.DragGestureEvent event)
A DragGestureRecognizer has detected a platform-dependent drag initiating gesture and is notifying this listener in order for it to initiate the action for the user.

Specified by:
dragGestureRecognized in interface java.awt.dnd.DragGestureListener
Parameters:
event - the event describing the gesture that has just occurred

dragEnter

public void dragEnter(java.awt.dnd.DragSourceDragEvent event)
Called as the hotspot enters a platform dependent drop site.

Specified by:
dragEnter in interface java.awt.dnd.DragSourceListener
Parameters:
event - the drag source event

dragOver

public void dragOver(java.awt.dnd.DragSourceDragEvent event)
Called as the hotspot moves over a platform dependent drop site.

Specified by:
dragOver in interface java.awt.dnd.DragSourceListener
Parameters:
event - the drag source event

dropActionChanged

public void dropActionChanged(java.awt.dnd.DragSourceDragEvent event)
Called when the user has modified the drop gesture.

Specified by:
dropActionChanged in interface java.awt.dnd.DragSourceListener
Parameters:
event - the drag source event

dragExit

public void dragExit(java.awt.dnd.DragSourceEvent event)
Called as the hotspot exits a platform dependent drop site.

Specified by:
dragExit in interface java.awt.dnd.DragSourceListener
Parameters:
event - the drag source event

dragDropEnd

public void dragDropEnd(java.awt.dnd.DragSourceDropEvent event)
This method is invoked to signify that the Drag and Drop operation is complete.

Specified by:
dragDropEnd in interface java.awt.dnd.DragSourceListener
Parameters:
event - the drag source event

handleDragEvent

protected void handleDragEvent(java.awt.dnd.DragSourceDragEvent event)
Utility method to handle the various drag events that occur on the DragSource side before the actual drop occurs.

Parameters:
event - the event that occurred

cancelDragEvent

protected void cancelDragEvent(java.awt.dnd.DragSourceEvent event)
Utility method to handle the case where the drag cursor has exited a viable DropTarget - note that this does not mean that the drag operation has been cancelled completely though.

Parameters:
event - the drag event that occurred

handleDropEvent

protected void handleDropEvent(java.awt.dnd.DragSourceDropEvent event)
Utility method to handle the actual drop event for the DragSource side of things.

Parameters:
event - the actual drop event that occurred

removeSelectedText

protected void removeSelectedText()
Utility method to remove the selected text of editor. This is the text that was dragged.


handleDropEvent

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

Overrides:
handleDropEvent in class DropTargetPlugin
Parameters:
event - the actual drop event that occurred

updateDragCursor

protected void updateDragCursor(java.awt.dnd.DragSourceEvent event,
                                int dropAction)
Utility method to update the drag cursor based on the given event.

Parameters:
event - the event that occurred
dropAction - the current drop action

Extension SDK

 

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