DefaultDragDropDriver
A TransferHandler to handle both drags originating in the source view, and drops onto the source view that come from the same source view, another source view, or anywhere else.
A derived class may want to override some of the methods to handle
additional drag flavors. The methods to consider overriding include:
isDragSupported()
getInsertionPosition()
getInsertionString()
Generally, I would discourage overriding anything else.
Object
DefaultDragDropDriver
SourceViewDragDropDriver
IDragDropDriver
Nested Class Summary |
Nested classes from com.bea.ide.core.datatransfer. |
|
Field Summary |
protected |
|
protected |
|
protected |
|
Constructor Summary |
Method Summary |
public void |
|
public void |
|
public void | |
public int |
|
public boolean |
|
public |
|
protected int |
|
protected |
|
protected int |
|
protected boolean |
|
protected void |
|
Methods from class java.lang. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods from interface com.bea.ide.core.datatransfer. |
|
Field Detail |
protected ISourceDocument
_sourceDoc
protected ISourceView
_sourceView
protected JTextComponent
_textView
Constructor Detail |
public SourceViewDragDropDriver(ISourceDocument
doc)
Method Detail |
public void attach(ISourceView
sv,JTextComponent
view)
public void dragComplete(Called on the source driver when a drag is done, whether or not it was ever dropped. If the drag succeeded, and the action was a move (rather than a copy), then the source text should be removed from the document.Transferable
t, boolean success, int action,Component
c)
DefaultDragDropDriver.dragComplete(Transferable, boolean, int, Component)
Related Topics
DefaultDragDropDriver.dragComplete(Transferable, boolean, int, Component)
public void dragExit(Component
c)
Called on the target driver when a drag is cancelled, or at least
temporarily disabled because the mouse has moved outside of the component.
DefaultDragDropDriver.dragExit(Component)
Related Topics
DefaultDragDropDriver.dragExit(Component)
public int dragOver(IDragDropContext
dc)
Called during a drag to confirm that this target driver can accept
the dragged object.
Do not override this method. Rather, override SourceViewDragDropDriver.isDragSupported(IDragDropContext)
and
SourceViewDragDropDriver.getInsertionPosition(IDragDropContext)
to indicate what and how data may
be dragged.
DefaultDragDropDriver.dragOver(IDragDropContext)
Related Topics
DefaultDragDropDriver.dragOver(IDragDropContext)
public boolean drop(IDragDropContext
dc)
Called on the target driver when something is dropped on it.
Do not override this method. Rather, override
SourceViewDragDropDriver.getInsertionString(IDragDropContext)
and
SourceViewDragDropDriver.getInsertionPosition(IDragDropContext)
to indicate what string to insert and where to insert it, or to
indicate that the drop should be cancelled.
DefaultDragDropDriver.drop(IDragDropContext)
Related Topics
DefaultDragDropDriver.drop(IDragDropContext)
publicCalled on the source driver to initiate a drag.IDragDropDriver.IDragSourceInfo
getDragInfo(Component
c,Point
pt)
DefaultDragDropDriver.getDragInfo(Component, Point)
Related Topics
DefaultDragDropDriver.getDragInfo(Component, Point)
protected int getInsertionPosition(IDragDropContext
dc)
When something is being dragged over the source view, SourceViewDragDropDriver.dragOver(IDragDropContext)
calls this method to ascertain where to show a drop caret. The drop
caret indicates the precise position in the document at which the
dropped text would be inserted.
This method is only called after calling SourceViewDragDropDriver.isDragSupported(IDragDropContext)
,
so there is a presumption that a drop would be valid.
Note that when dragging and dropping within one source view, if the position returned is inside of the selection being dragged, then the drag-drop will do nothing.
protectedCalled byString
getInsertionString(IDragDropContext
dc)
SourceViewDragDropDriver.drop(IDragDropContext)
to convert a drag-drop context into a string
to insert into the document.
By default, we only support string flavors.
If derived classes add more formats to SourceViewDragDropDriver.isDragSupported(IDragDropContext)
,
then those classes need to override this method as well to convert
those other formats to strings.
If the derived class doesn't want to insert anything, but instead wants to launch a wizard or something, they should launch the wizard from within this method, and then return null.
"" may be returned if no text should be inserted.
Return null to indicate the drop actually failed.
protected int isDragSupported(IDragDropContext
dc)
When something is being dragged over the source view, SourceViewDragDropDriver.dragOver(IDragDropContext)
calls this method to ascertain whether or not it may be dropped into
our view.
The default implementation is to only support drag-dropping of strings.
Derived classes may recognize other data flavors, constrain drop coordinates, or whatever.
Related Topics
protected boolean isSourceAndTarget()Determines if the user is dragging an object within a single view.
protected void updateInsertionCaret(int pos)Tells the TextView to draw a special caret icon where the dragged text would be dropped. This will look slightly different than the cursor, so as not to confuse the user.
if pos is negative, the drop caret is hidden.