|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.javatools.editor.plugins.DropTargetPlugin
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 |
protected BasicEditorPane editor
protected java.awt.dnd.DropTarget dropTarget
protected java.awt.Rectangle lastDropRect
protected static final int DROP_RECT_WIDTH
protected static final java.awt.datatransfer.DataFlavor STRING_FLAVOR
protected static final java.awt.datatransfer.DataFlavor PLAIN_FLAVOR
protected static final EditDescriptor DROP_DESCRIPTOR
Constructor Detail |
public DropTargetPlugin()
DropTargetPlugin
instance that
adds drop capability to the editor for text drops.
Method Detail |
public void install(BasicEditorPane editor)
install
in interface EditorPlugin
editor
- the editor panepublic void deinstall(BasicEditorPane editor)
deinstall
in interface EditorPlugin
editor
- the editor panepublic void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
event
- A PropertyChangeEvent object describing the event source
and the property that has changed.public void dragEnter(java.awt.dnd.DropTargetDragEvent event)
DropTarget
.
dragEnter
in interface java.awt.dnd.DropTargetListener
event
- the DropTargetDragEvent that occurredpublic void dragOver(java.awt.dnd.DropTargetDragEvent event)
DropTarget
.
dragOver
in interface java.awt.dnd.DropTargetListener
event
- the DropTargetDragEvent that occurredpublic void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
dropActionChanged
in interface java.awt.dnd.DropTargetListener
event
- the DropTargetDragEvent that occurredpublic void dragExit(java.awt.dnd.DropTargetEvent event)
DropTarget
without dropping.
dragExit
in interface java.awt.dnd.DropTargetListener
event
- the DropTargetEvent that occurredpublic void drop(java.awt.dnd.DropTargetDropEvent event)
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.
drop
in interface java.awt.dnd.DropTargetListener
event
- the DropTargetDropEvent that occurredprotected BasicDocument getDocument()
protected java.awt.Rectangle getDropRectangle(java.awt.Point location)
location
- the location to get the rectangle for
protected void clearDropLocation()
protected void paintDropLocation(java.awt.Point newLocation)
newLocation
- the new location to paintprotected void cancelDragEvent(java.awt.dnd.DropTargetEvent event)
event
- the event that occurredprotected void handleDropEvent(java.awt.dnd.DropTargetDropEvent event)
event
- the actual drop event that occurredprotected java.lang.String getTransferText(java.awt.datatransfer.Transferable transferable)
transferable
- the transferable involved
protected java.awt.datatransfer.DataFlavor getPreferredDataFlavor(java.awt.datatransfer.Transferable transferable)
transferable
- the transferable involved
protected void handleDragEvent(java.awt.dnd.DropTargetDragEvent event)
event
- the event that occurredprotected boolean isDropActionSupported(int requestedAction)
requestedAction
- the requested drag/drop operation
protected boolean isDataFlavorSupported(java.awt.dnd.DropTargetDragEvent event)
event
- the drag event that occurred
protected boolean isDataFlavorSupported(java.awt.dnd.DropTargetDropEvent event)
event
- the drag event that occurred
protected java.awt.datatransfer.DataFlavor[] getSupportedFlavors()
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.