public class DropTarget extends Object implements DndDragEnterEvent.HasDndDragEnterHandlers, DndDragLeaveEvent.HasDndDragLeaveHandlers, DndDragCancelEvent.HasDndDragCancelHandlers, DndDragMoveEvent.HasDndDragMoveHandlers, DndDropEvent.HasDndDropHandlers
Enables a component to act as the target of a drag and drop operation (i.e. a user can drop data on the component).
While the cursor is over a target, the target is responsible for determining
if the drop is valid and showing any visual indicators for the drop. The
StatusProxy
object should be used to specify if the drop is valid,
and can also be used to change the values of the proxy object displayed by
the cursor.
Modifier and Type | Field and Description |
---|---|
protected Widget |
dropWidget |
protected DND.Feedback |
feedback |
protected DND.Operation |
operation |
protected String |
overStyle |
Constructor and Description |
---|
DropTarget(Widget dropWidget)
Creates a new drop dropWidget.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addDragCancelHandler(DndDragCancelEvent.DndDragCancelHandler handler)
Adds a
DndDragCancelEvent.DndDragCancelHandler handler for
DndDragCancelEvent events. |
HandlerRegistration |
addDragEnterHandler(DndDragEnterEvent.DndDragEnterHandler handler)
Adds a
DndDragEnterEvent.DndDragEnterHandler handler for DndDragEnterEvent events. |
HandlerRegistration |
addDragLeaveHandler(DndDragLeaveEvent.DndDragLeaveHandler handler)
Adds a
DndDragLeaveEvent.DndDragLeaveHandler handler for DndDragLeaveEvent events. |
HandlerRegistration |
addDragMoveHandler(DndDragMoveEvent.DndDragMoveHandler handler)
Adds a
DndDragMoveEvent.DndDragMoveHandler handler for DndDragMoveEvent 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.
|
protected XElement |
getElementFromEvent(NativeEvent event)
Obtain potential top-most target element associated with provided event.
|
DND.Feedback |
getFeedback()
Returns the target's feedback setting.
|
String |
getGroup()
Returns the target's group name.
|
DND.Operation |
getOperation()
Returns the target's operation.
|
String |
getOverStyle()
Returns the target's over style.
|
Widget |
getWidget()
Returns the target's widget.
|
boolean |
isAllowSelfAsSource()
Returns true if internal drops are allowed.
|
boolean |
isEnabled()
Returns true if the drag source is enabled.
|
protected void |
onDragCancelled(DndDragCancelEvent event)
Called if the user cancels the drag operations while the mouse is over the
target.
|
protected void |
onDragDrop(DndDropEvent event)
Called when the user releases the mouse over the target widget.
|
protected void |
onDragEnter(DndDragEnterEvent event)
Called when the cursor first enters the bounds of the drop target.
|
protected void |
onDragFail(DndDropEvent event)
Called when a drop fails.
|
protected void |
onDragLeave(DndDragLeaveEvent event)
Called when the cursor leaves the target.
|
protected void |
onDragMove(DndDragMoveEvent event)
Called when the cursor is moved within the target widget.
|
protected void |
onDropWidgetAttach() |
protected void |
onDropWidgetDetach() |
protected List<Object> |
prepareDropData(Object data,
boolean convertTreeStoreModel) |
void |
release()
Unregisters the target as a drop target.
|
void |
setAllowSelfAsSource(boolean allowSelfAsSource)
Sets whether internal drops are allowed (defaults to false).
|
void |
setFeedback(DND.Feedback feedback)
Sets the target's feedback.
|
void |
setGroup(String group)
Sets the drag group.
|
void |
setOperation(DND.Operation operation)
Sets the operation for the drop target which specifies if data should be
moved or copied when dropped.
|
void |
setOverStyle(String overStyle)
Sets the style name to be applied when the cursor is over the target
(defaults to null).
|
protected void |
showFeedback(DndDragMoveEvent event)
Called as the mouse is moved over the target widget.
|
protected Widget dropWidget
protected DND.Feedback feedback
protected DND.Operation operation
protected String overStyle
public DropTarget(Widget dropWidget)
dropWidget
- the dropWidget widgetpublic HandlerRegistration addDragCancelHandler(DndDragCancelEvent.DndDragCancelHandler handler)
DndDragCancelEvent.HasDndDragCancelHandlers
DndDragCancelEvent.DndDragCancelHandler
handler for
DndDragCancelEvent
events.addDragCancelHandler
in interface DndDragCancelEvent.HasDndDragCancelHandlers
handler
- the handlerpublic HandlerRegistration addDragEnterHandler(DndDragEnterEvent.DndDragEnterHandler handler)
DndDragEnterEvent.HasDndDragEnterHandlers
DndDragEnterEvent.DndDragEnterHandler
handler for DndDragEnterEvent
events.addDragEnterHandler
in interface DndDragEnterEvent.HasDndDragEnterHandlers
handler
- the handlerpublic HandlerRegistration addDragLeaveHandler(DndDragLeaveEvent.DndDragLeaveHandler handler)
DndDragLeaveEvent.HasDndDragLeaveHandlers
DndDragLeaveEvent.DndDragLeaveHandler
handler for DndDragLeaveEvent
events.addDragLeaveHandler
in interface DndDragLeaveEvent.HasDndDragLeaveHandlers
handler
- the handlerpublic HandlerRegistration addDragMoveHandler(DndDragMoveEvent.DndDragMoveHandler handler)
DndDragMoveEvent.HasDndDragMoveHandlers
DndDragMoveEvent.DndDragMoveHandler
handler for DndDragMoveEvent
events.addDragMoveHandler
in interface DndDragMoveEvent.HasDndDragMoveHandlers
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 DND.Feedback getFeedback()
public String getGroup()
public DND.Operation getOperation()
public String getOverStyle()
public Widget getWidget()
public boolean isAllowSelfAsSource()
public boolean isEnabled()
public void release()
public void setAllowSelfAsSource(boolean allowSelfAsSource)
allowSelfAsSource
- true to allow internal dropspublic void setFeedback(DND.Feedback feedback)
feedback
- the feedbackpublic void setGroup(String group)
group
- the group namepublic void setOperation(DND.Operation operation)
operation
- the operationpublic void setOverStyle(String overStyle)
overStyle
- the over styleprotected XElement getElementFromEvent(NativeEvent event)
event
- protected void onDropWidgetAttach()
protected void onDropWidgetDetach()
protected void onDragCancelled(DndDragCancelEvent event)
event
- the drag cancel eventprotected void onDragDrop(DndDropEvent event)
event
- the drop eventprotected void onDragEnter(DndDragEnterEvent event)
event
- the drag enter eventprotected void onDragFail(DndDropEvent event)
event
- the drop eventprotected void onDragLeave(DndDragLeaveEvent event)
event
- the drag leave eventprotected void onDragMove(DndDragMoveEvent event)
CancellableEvent.setCancelled(boolean)
to true,
showFeedback(DndDragMoveEvent)
will be called.event
- the dd eventprotected void showFeedback(DndDragMoveEvent event)
event
- the dd eventCopyright © 2018. All rights reserved.