|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swt.dnd.DropTargetAdapter org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter
public class EditingDomainViewerDropAdapter
This implementation of a drop target listener is designed to turn a drag and drop
operation into a Command
based on the model objects of an
EditingDomain
and created by DragAndDropCommand.create(org.eclipse.emf.edit.domain.EditingDomain, java.lang.Object, float, int, int, java.util.Collection>)
. It is
designed to do early data transfer so the the enablement and feedback of the
drag and drop interaction can intimately depend on the state of the model objects
involved. On some platforms, however, early data transfer is not available, so this
feedback cannot be provided.
The base implementation of this class should be sufficient for most applications.
Any change in behaviour is typically accomplished by overriding
ItemProviderAdapter
.createDragAndDropCommand
to return a derived implementation of DragAndDropCommand
.
This is how one these adapters is typically hooked up:
viewer.addDropSupport (DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK, new Transfer [] { LocalTransfer.getInstance() }, EditingDomainViewerDropAdapter(viewer));
This implementation prefers to use a LocalTransfer
,
which short-circuits the transfer process for simple transfers within the workbench,
the method getDragSource(org.eclipse.swt.dnd.DropTargetEvent)
can be overridden to change the behaviour.
The implementation also only handles an IStructuredSelection
,
but the method extractDragSource(java.lang.Object)
can be overridden to change the behaviour.
SWT's auto-scroll
and auto-expand
(hover) are enabled by default. The method getAutoFeedback()
can be overridden
to change this behaviour.
Nested Class Summary | |
---|---|
protected static class |
EditingDomainViewerDropAdapter.DragAndDropCommandInformation
This holds all of the information used to create a DragAndDropCommand , but does not need to be disposed. |
Field Summary | |
---|---|
protected Command |
command
This is the command created during dragging which provides the feedback and will carry out the action upon completion. |
protected java.lang.Object |
commandTarget
This records the object for which the command was created. |
protected EditingDomain |
domain
This is the domain in which drag and drop commands will be executed. |
protected EditingDomainViewerDropAdapter.DragAndDropCommandInformation |
dragAndDropCommandInformation
This keeps track of the information used to create command , but
does not need to be disposed. |
protected static boolean |
IS_MOTIF
This indicates whether the current platform is motif, which needs special treatment, since it cannot do early data transfer, but doesn't cleanly return null either. |
protected int |
originalOperation
This keeps track of the original operation that the user requested, before we started changing the event.detail. |
protected java.util.Collection<?> |
source
This is the collection of source objects being dragged. |
protected Viewer |
viewer
This is the viewer for which this is a drop target listener. |
Constructor Summary | |
---|---|
EditingDomainViewerDropAdapter(EditingDomain domain,
Viewer viewer)
This creates an instance with the given domain and viewer. |
Method Summary | |
---|---|
void |
dragEnter(DropTargetEvent event)
This is called when the mouse first enters or starts dragging in the viewer. |
void |
dragLeave(DropTargetEvent event)
This is called when the mouse leaves or stops dragging in the viewer, whether the operation was aborted or is about to do a dropAccept and drop. |
void |
dragOperationChanged(DropTargetEvent event)
This is called when the operation has changed in some way, typically because the user changes keyboard modifiers. |
void |
dragOver(DropTargetEvent event)
This is called repeatedly, as the mouse moves over the viewer. |
void |
drop(DropTargetEvent event)
This is called to indicate that the drop action should be invoked. |
void |
dropAccept(DropTargetEvent event)
This is called when the mouse is released over the viewer to initiate a drop, between dragLeave and drop. |
protected java.util.Collection<?> |
extractDragSource(java.lang.Object object)
This extracts a collection of dragged source objects from the given object retrieved from the transfer agent. |
protected java.lang.Object |
extractDropTarget(Widget item)
This extracts an object from the given item widget, providing the special support required by an ExtendedTableTreeViewer.ExtendedTableTreeItem . |
protected int |
getAutoFeedback()
This returns the bitwise OR'ed flags for desired auto-feedback effects. |
protected java.util.Collection<?> |
getDragSource(DropTargetEvent event)
This attempts to extract the drag source from the event early, i.e., before the drop method. |
protected float |
getLocation(DropTargetEvent event)
This returns the location of the mouse in the vertical direction, relative to the item widget, from 0 (top) to 1 (bottom). |
protected void |
helper(DropTargetEvent event)
This method is called the same way for each of the DropTargetListener methods, except for leave
and drop. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final boolean IS_MOTIF
protected Viewer viewer
protected EditingDomain domain
protected java.util.Collection<?> source
protected Command command
protected java.lang.Object commandTarget
command
was created.
protected int originalOperation
protected EditingDomainViewerDropAdapter.DragAndDropCommandInformation dragAndDropCommandInformation
command
, but
does not need to be disposed. This allows us to dispose of the command
in dragLeave, and then, if we need to execute it, recreate it in drop.
Constructor Detail |
---|
public EditingDomainViewerDropAdapter(EditingDomain domain, Viewer viewer)
Method Detail |
---|
public void dragEnter(DropTargetEvent event)
dragEnter
in interface DropTargetListener
dragEnter
in class DropTargetAdapter
public void dragLeave(DropTargetEvent event)
dragLeave
in interface DropTargetListener
dragLeave
in class DropTargetAdapter
public void dragOperationChanged(DropTargetEvent event)
dragOperationChanged
in interface DropTargetListener
dragOperationChanged
in class DropTargetAdapter
public void dragOver(DropTargetEvent event)
dragOver
in interface DropTargetListener
dragOver
in class DropTargetAdapter
public void dropAccept(DropTargetEvent event)
dropAccept
in interface DropTargetListener
dropAccept
in class DropTargetAdapter
public void drop(DropTargetEvent event)
drop
in interface DropTargetListener
drop
in class DropTargetAdapter
protected void helper(DropTargetEvent event)
DropTargetListener
methods, except for leave
and drop. If the source is available early, it creates or revalidates
the DragAndDropCommand
, and updates the event's detail (operation)
and feedback (drag under effect), appropriately.
protected int getAutoFeedback()
auto-scroll
and
auto-expand
(hover).
protected java.util.Collection<?> getDragSource(DropTargetEvent event)
LocalTransfer
. If the data is not yet
available (e.g. on platforms other than win32), it just returns null.
protected java.util.Collection<?> extractDragSource(java.lang.Object object)
protected java.lang.Object extractDropTarget(Widget item)
ExtendedTableTreeViewer.ExtendedTableTreeItem
.
protected float getLocation(DropTargetEvent event)
|
Copyright 2001-2012 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |