public class DragSource extends Object implements DndDragStartEvent.HasDndDragStartHandlers, DndDragCancelEvent.HasDndDragCancelHandlers, DndDropEvent.HasDndDropHandlers
Enables a component to act as the source of a drag and drop operation (i.e. a user can drag data from the component).
Drag sources must set the data that will be dragged during a drag operation.
The data can be specified either by using setData(Object)
or by
setting the data via the DND event when a drag begins.
Drag sources are responsible for removing the dragged data from the source
widget after a valid drop. Use DropTarget.getOperation()
to determine
if the data was copied or moved. The target is accessible via the DNDEvent
passed to onDragDrop(DndDropEvent)
and listeners.
Modifier and Type | Field and Description |
---|---|
protected Object |
data |
protected Draggable |
draggable |
protected DragHandler |
handler |
protected StatusProxy |
statusProxy |
protected Widget |
widget |
Constructor and Description |
---|
DragSource(Widget widget)
Creates a drag source that enables the specified widget to act as the
starting point of a drag operation.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addDragCancelHandler(DndDragCancelEvent.DndDragCancelHandler handler)
Adds a
DndDragCancelEvent.DndDragCancelHandler handler for
DndDragCancelEvent events. |
HandlerRegistration |
addDragStartHandler(DndDragStartEvent.DndDragStartHandler handler)
Adds a
DndDragStartEvent.DndDragStartHandler handler for DndDragStartEvent events. |
HandlerRegistration |
addDropHandler(DndDropEvent.DndDropHandler handler)
Adds a
DndDropEvent.DndDropHandler handler for DndDropEvent events. |
void |
disable()
Disables the drag source.
|
void |
enable()
Enables the drag source.
|
Object |
getData()
Returns the data to be moved or copied.
|
Draggable |
getDraggable()
Returns the draggable instance.
|
String |
getGroup()
Returns the source's drag drop group.
|
String |
getStatusText()
Returns the status text.
|
Widget |
getWidget()
Returns the source widget.
|
boolean |
isEnabled()
Returns true if the drag source is enabled.
|
protected void |
onDragCancelled(DndDragCancelEvent event)
Called when a drag operation has been cancelled.
|
protected void |
onDragDrop(DndDropEvent event) |
protected void |
onDragFail(DndDropEvent event) |
protected void |
onDragStart(DndDragStartEvent event)
Called when a drag operation begins on the target widget.
|
void |
release()
Releases the DragSource from the widget.
|
void |
setData(Object data)
Sets the data for the drag drop operation.
|
void |
setGroup(String group)
Sets the drag drop group.
|
void |
setStatusText(String statusText)
Sets the text to be used on the status proxy object.
|
protected Widget widget
protected Draggable draggable
protected DragHandler handler
protected Object data
protected StatusProxy statusProxy
public DragSource(Widget widget)
widget
- the widget to serve as the starting point of a drag operationpublic HandlerRegistration addDragCancelHandler(DndDragCancelEvent.DndDragCancelHandler handler)
DndDragCancelEvent.HasDndDragCancelHandlers
DndDragCancelEvent.DndDragCancelHandler
handler for
DndDragCancelEvent
events.addDragCancelHandler
in interface DndDragCancelEvent.HasDndDragCancelHandlers
handler
- the handlerpublic HandlerRegistration addDragStartHandler(DndDragStartEvent.DndDragStartHandler handler)
DndDragStartEvent.HasDndDragStartHandlers
DndDragStartEvent.DndDragStartHandler
handler for DndDragStartEvent
events.addDragStartHandler
in interface DndDragStartEvent.HasDndDragStartHandlers
handler
- the handlerpublic HandlerRegistration addDropHandler(DndDropEvent.DndDropHandler handler)
DndDropEvent.HasDndDropHandlers
DndDropEvent.DndDropHandler
handler for DndDropEvent
events.addDropHandler
in interface DndDropEvent.HasDndDropHandlers
handler
- the handlerpublic void disable()
public void enable()
public Object getData()
public Draggable getDraggable()
public String getGroup()
public String getStatusText()
public Widget getWidget()
public boolean isEnabled()
public void release()
public void setData(Object data)
data
- the datapublic void setGroup(String group)
group
- the group namepublic void setStatusText(String statusText)
statusText
- the status textprotected void onDragCancelled(DndDragCancelEvent event)
event
- the dnd cancel eventprotected void onDragDrop(DndDropEvent event)
protected void onDragFail(DndDropEvent event)
protected void onDragStart(DndDragStartEvent event)
CancellableEvent.setCancelled(boolean)
.event
- the dnd eventCopyright © 2018. All rights reserved.