com.vaadin.terminal.gwt.client.ui.dd.
Class VDragAndDropManager
java.lang.Object
com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager
- extends Object
public class VDragAndDropManager
Helper class to manage the state of drag and drop event on Vaadin client side. Can be used to implement most of the drag and drop operation automatically via cross-browser event preview method or just as a helper when implementing own low level drag and drop operation (like with HTML5 api).
Singleton. Only one drag and drop operation can be active anyways. Use
get()
to get instance.
TODO cancel drag and drop if more than one touches !?
Nested Class Summary | |
---|---|
static class |
VDragAndDropManager.DragEventType
|
Field Summary | |
---|---|
static String |
ACTIVE_DRAG_SOURCE_STYLENAME
|
Constructor Summary | |
---|---|
protected |
VDragAndDropManager()
|
Method Summary | |
---|---|
void |
endDrag()
Drag is ended (drop happened) on current drop handler. |
void |
executeWhenReady(com.google.gwt.user.client.Command command)
Method to execute commands when all existing dd related tasks are completed (some may require server visit). |
static VDragAndDropManager |
get()
|
VDropHandler |
getCurrentDropHandler()
|
void |
handleServerResponse(ValueMap valueMap)
|
void |
interruptDrag()
The drag and drop operation is ended, but drop did not happen. |
void |
setCurrentDropHandler(VDropHandler currentDropHandler)
If drag and drop operation is not handled by VDragAndDropManager s
internal handler, this can be used to update current VDropHandler
. |
VDragEvent |
startDrag(VTransferable transferable,
com.google.gwt.dom.client.NativeEvent startEvent,
boolean handleDragEvents)
This method is used to start Vaadin client side drag and drop operation. |
void |
visitServer(VDragEventServerCallback acceptCallback)
Visits server during drag and drop procedure. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
ACTIVE_DRAG_SOURCE_STYLENAME
public static final String ACTIVE_DRAG_SOURCE_STYLENAME
See Also:
Constructor Detail |
---|
VDragAndDropManager
protected VDragAndDropManager()
Method Detail |
---|
getCurrentDropHandler
public VDropHandler getCurrentDropHandler()
setCurrentDropHandler
public void setCurrentDropHandler(VDropHandler currentDropHandler)
- Parameters:
currentDropHandler
-
If drag and drop operation is not handled by VDragAndDropManager
s
internal handler, this can be used to update current VDropHandler
.
get
public static VDragAndDropManager get()
startDrag
public VDragEvent startDrag(VTransferable transferable,
com.google.gwt.dom.client.NativeEvent startEvent,
boolean handleDragEvents)
- Parameters:
transferable
-nativeEvent
-handleDragEvents
- if true,VDragAndDropManager
handles the drag and drop operation GWT event preview.- Returns:
This method is used to start Vaadin client side drag and drop operation. Operation may be started by virtually any Widget.
Cancels possible existing drag. TODO figure out if this is always a bug if one is active. Maybe a good and cheap lifesaver thought.
If possible, method automatically detects current VDropHandler
and fires VDropHandler.dragEnter(VDragEvent)
event on it.
May also be used to control the drag and drop operation. If this option
is used, VDropHandler
is searched on mouse events and appropriate
methods on it called automatically.
endDrag
public void endDrag()
Drag is ended (drop happened) on current drop handler. Calls drop method on current drop handler and does appropriate cleanup.
interruptDrag
public void interruptDrag()
The drag and drop operation is ended, but drop did not happen. If operation is currently on a drop handler, its dragLeave method is called and appropriate cleanup happens.
visitServer
public void visitServer(VDragEventServerCallback acceptCallback)
- Parameters:
acceptCallback
-
Visits server during drag and drop procedure. Transferable and event type is given to server side counterpart of DropHandler. If another server visit is started before the current is received, the current is just dropped. TODO consider if callback should have interrupted() method for cleanup.
handleServerResponse
public void handleServerResponse(ValueMap valueMap)
executeWhenReady
public void executeWhenReady(com.google.gwt.user.client.Command command)
- Parameters:
command
-
Method to execute commands when all existing dd related tasks are completed (some may require server visit).
Using this method may be handy if criterion that uses lazy initialization are used. Check
TODO Optimization: consider if we actually only need to keep the last command in queue here.