public abstract class DropHandlerPlugin extends java.lang.Object implements EditorPlugin
DropHandlerPlugin
is an abstract class that allows code editor clients to extend the drop functionality of Drag & Drop for the code editor to support additional data flavors or even custom drop behavior.
Since this is an EditorPlugin
implementation, it should be installed into an editor through an EditorPluginsFactory
instance.
Constructor and Description |
---|
DropHandlerPlugin()
Constructs a new
DropHandlerPlugin instance. |
Modifier and Type | Method and Description |
---|---|
protected void |
cancelDragEvent(java.awt.dnd.DropTargetEvent event)
Hook called when the drop area has been exited or the drop is over.
|
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 BasicDocument |
getDocument()
Fetch the document of the editor.
|
protected java.awt.Point |
getDropLocationToPaint(java.awt.dnd.DropTargetDragEvent event)
Gets the location in the code editor's
BasicEditorPane where the drop location should be painted. |
protected BasicEditorPane |
getEditorPane()
Fetch the editor.
|
void |
install(BasicEditorPane editor)
Called when this plugin is being installed into the BasicEditorPane.
|
protected abstract boolean |
performDrop(java.awt.dnd.DropTargetDropEvent event)
Perform the actual drop operation for the given drop event.
|
void |
propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.
|
protected void |
raiseEditorToFront()
Utility routine which will raise the window containing the editor to the front, and place focus in the editor.
|
protected abstract int |
shouldAllowDrag(java.awt.dnd.DropTargetDragEvent event)
Hook for the plugin to decide whether it would like to handle a drop with the given data at the given spot.
|
protected abstract int |
shouldAllowDrop(java.awt.dnd.DropTargetDropEvent event)
Hook for the plugin to decide whether it would like to handle a drop with the given data at the given spot.
|
public DropHandlerPlugin()
DropHandlerPlugin
instance.public final void install(BasicEditorPane editor)
install
in interface EditorPlugin
editor
- the editor panepublic void deinstall(BasicEditorPane editor)
deinstall
in interface EditorPlugin
editor
- the editor paneprotected final BasicEditorPane getEditorPane()
protected final BasicDocument getDocument()
public 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.protected final void raiseEditorToFront()
protected abstract int shouldAllowDrag(java.awt.dnd.DropTargetDragEvent event)
event
- Drag event in questionDnDConstants.ACTION_NONE
to say that we don't want to allow this drop, or a mask of DnDConstants actions that we want to accept.protected abstract int shouldAllowDrop(java.awt.dnd.DropTargetDropEvent event)
event
- Drop event in questionDnDConstants.ACTION_NONE
to say that we don't want to handle the drop, or the single specific action constant (copy, move, link) of the want to accept.protected void cancelDragEvent(java.awt.dnd.DropTargetEvent event)
event
- drop eventprotected java.awt.Point getDropLocationToPaint(java.awt.dnd.DropTargetDragEvent event)
BasicEditorPane
where the drop location should be painted. This is only called on the plugin that returned non-zero from shouldAllowDrag(java.awt.dnd.DropTargetDragEvent)
during drag. The default implementation just returns the location of the event. Subclasses may override this to show a different location, like if the drop will actually occur somewhere else nearby. They may also return null
to indicate not to paint the drop location.event
- drag eventnull
for noneprotected abstract boolean performDrop(java.awt.dnd.DropTargetDropEvent event)
shouldAllowDrop(java.awt.dnd.DropTargetDropEvent)
. Note that this method must not call acceptDrop, rejectDrop, or dropComplete; the code editor takes care of this.event
- drop event