|
|||||||||
PREV CLASS SOURCE NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.swt.dnd.DropTargetAdapter | +--org.eclipse.emf.edit.ui.dnd.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 involed.
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 overriden to change the behaviour.
The implementation also only handles an IStructuredSelection
,
but the method extractDragSource(java.lang.Object)
can be overriden to change the behaviour.
You can call setHoverThreshold(int)
to set the amount of time, in milliseconds,
to hover over an item before hover(java.lang.Object)
is called;
the default is 1500 milliseconds.
Inner Class Summary | |
protected static class |
EditingDomainViewerDropAdapter.DragAndDropCommandInformation
|
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 the current command. |
protected long |
hoverStart
The is the time the mouse first started hovering over the current item. |
protected int |
hoverThreshold
The amount of time to hover over a tree item before expanding it |
protected int |
originalOperation
This keeps track of the original operation that was in effect before we set the event.detail in here. |
protected org.eclipse.swt.widgets.Widget |
previousItem
This keeps track of the most recent item for the hoverStart . |
protected java.util.Collection |
source
This is the collection of source objects being dragged. |
protected org.eclipse.jface.viewers.Viewer |
viewer
This is the viewer for which this is a drop target listener. |
Constructor Summary | |
EditingDomainViewerDropAdapter(EditingDomain domain,
org.eclipse.jface.viewers.Viewer viewer)
This creates and instance of the given domain and viewer. |
Method Summary | |
void |
dragEnter(org.eclipse.swt.dnd.DropTargetEvent event)
This is called when the mouse first enters or starts dragging in the viewer. |
void |
dragLeave(org.eclipse.swt.dnd.DropTargetEvent event)
This is called when the mouse leaves or stops dragging in the viewer |
void |
dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent event)
This is called when the operation has changed in some way, typically because the user changes keyboard modifiers. |
void |
dragOver(org.eclipse.swt.dnd.DropTargetEvent event)
This is called repeated when the mouse over the viewer. |
void |
drop(org.eclipse.swt.dnd.DropTargetEvent event)
This is called to indate that the drop action should be invoked. |
void |
dropAccept(org.eclipse.swt.dnd.DropTargetEvent event)
This is called just as the mouse is released over the viewer to initiate a 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.util.Collection |
getDragSource(org.eclipse.swt.dnd.DropTargetEvent event)
This attempts to extract the drag source from the event early, i.e., before the drop method. |
int |
getHoverThreshold()
This gets the amount of time, in milliseconds, to hover over an item before hover(java.lang.Object) is called. |
protected static float |
getLocation(org.eclipse.swt.dnd.DropTargetEvent event)
|
protected void |
helper(org.eclipse.swt.dnd.DropTargetEvent event)
This method is called the same way for each of the DropTargetListener methods, except during leave. |
protected void |
hover(java.lang.Object target)
This is called when the cursor has hovered over the given target for longer than hoverThreshold . |
protected boolean |
scrollIfNeeded(org.eclipse.swt.dnd.DropTargetEvent event)
This returns whether a scroll was performed based on the given drag coordinates. |
void |
setHoverThreshold(int hoverThreshold)
This set the amount of time, in milliseconds, to hover over an item before hover(java.lang.Object) is called. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected org.eclipse.jface.viewers.Viewer viewer
protected EditingDomain domain
protected java.util.Collection source
protected Command command
protected java.lang.Object commandTarget
command
was created.protected int hoverThreshold
protected long hoverStart
protected org.eclipse.swt.widgets.Widget previousItem
hoverStart
.protected int originalOperation
protected EditingDomainViewerDropAdapter.DragAndDropCommandInformation dragAndDropCommandInformation
Constructor Detail |
public EditingDomainViewerDropAdapter(EditingDomain domain, org.eclipse.jface.viewers.Viewer viewer)
Method Detail |
public void dragEnter(org.eclipse.swt.dnd.DropTargetEvent event)
dragEnter
in class org.eclipse.swt.dnd.DropTargetAdapter
public void dragLeave(org.eclipse.swt.dnd.DropTargetEvent event)
dragLeave
in class org.eclipse.swt.dnd.DropTargetAdapter
public void dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent event)
dragOperationChanged
in class org.eclipse.swt.dnd.DropTargetAdapter
public void dragOver(org.eclipse.swt.dnd.DropTargetEvent event)
dragOver
in class org.eclipse.swt.dnd.DropTargetAdapter
public void dropAccept(org.eclipse.swt.dnd.DropTargetEvent event)
dropAccept
in class org.eclipse.swt.dnd.DropTargetAdapter
public void drop(org.eclipse.swt.dnd.DropTargetEvent event)
drop
in class org.eclipse.swt.dnd.DropTargetAdapter
protected void helper(org.eclipse.swt.dnd.DropTargetEvent event)
DropTargetListener
methods, except during leave.protected java.util.Collection getDragSource(org.eclipse.swt.dnd.DropTargetEvent event)
LocalTransfer
.protected java.util.Collection extractDragSource(java.lang.Object object)
public int getHoverThreshold()
hover(java.lang.Object)
is called.public void setHoverThreshold(int hoverThreshold)
hover(java.lang.Object)
is called.protected void hover(java.lang.Object target)
hoverThreshold
.protected boolean scrollIfNeeded(org.eclipse.swt.dnd.DropTargetEvent event)
protected static float getLocation(org.eclipse.swt.dnd.DropTargetEvent event)
|
Copyright 2001-2003 IBM Corporation and others. All Rights Reserved. |
||||||||
PREV CLASS SOURCE NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |