public abstract class ViewerDropAdapter extends DropTargetAdapter
Subclasses must implement the following methods:
validateDrop - identifies valid drop targets in viewerperformDrop - carries out a drop into a viewersetFeedbackEnabled method can be called to turn on and off
visual insertion feedback (on by default).
| Modifier and Type | Field and Description |
|---|---|
static int |
LOCATION_AFTER
Constant describing the position of the cursor relative
to the target object.
|
static int |
LOCATION_BEFORE
Constant describing the position of the cursor relative
to the target object.
|
static int |
LOCATION_NONE
Constant describing the position of the cursor relative
to the target object.
|
static int |
LOCATION_ON
Constant describing the position of the cursor relative
to the target object.
|
| Modifier | Constructor and Description |
|---|---|
protected |
ViewerDropAdapter(Viewer viewer)
Creates a new drop adapter for the given viewer.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
determineLocation(DropTargetEvent event)
Returns the position of the given event's coordinates relative to its target.
|
protected Object |
determineTarget(DropTargetEvent event)
Returns the target item of the given drop event.
|
void |
dragEnter(DropTargetEvent event)
This implementation of
dragEnter permits the default
operation defined in event.detailto be performed on the current data type
defined in event.currentDataType. |
void |
dragOperationChanged(DropTargetEvent event)
This implementation of
dragOperationChanged permits the default
operation defined in event.detailto be performed on the current data type
defined in event.currentDataType. |
void |
dragOver(DropTargetEvent event)
This implementation of
dragOver permits the default
operation defined in event.detailto be performed on the current data type
defined in event.currentDataType. |
void |
drop(DropTargetEvent event)
This implementation of
drop does nothing. |
void |
dropAccept(DropTargetEvent event)
This implementation of
dropAccept permits the default
operation defined in event.detailto be performed on the current data type
defined in event.currentDataType. |
protected Rectangle |
getBounds(Item item)
Returns the bounds of the given SWT tree or table item.
|
protected int |
getCurrentLocation()
Returns a constant describing the position of the mouse relative to the
target (before, on, or after the target.
|
protected int |
getCurrentOperation()
Returns the current operation.
|
protected Object |
getCurrentTarget()
Returns the target object currently under the mouse.
|
boolean |
getFeedbackEnabled()
Returns whether visible insertion feedback should be presented to the user.
|
protected Object |
getSelectedObject()
Returns the object currently selected by the viewer.
|
protected Viewer |
getViewer()
Returns the viewer to which this drop support has been added.
|
protected void |
handleException(Throwable exception,
DropTargetEvent event)
Deprecated.
this method should not be used. Exception handling has been
removed from DropTargetAdapter methods overridden by this class.
Handles any exception that occurs during callback, including
rethrowing behavior.
[Issue: Implementation prints stack trace and eats exception to avoid crashing VA/J. Consider conditionalizing the implementation to do one thing in VAJ and something more reasonable in other operating environments. ] |
abstract boolean |
performDrop(Object data)
Performs any work associated with the drop.
|
void |
setFeedbackEnabled(boolean value)
Sets whether visible insertion feedback should be presented to the user.
|
void |
setScrollExpandEnabled(boolean value)
Sets whether auto scrolling and expanding should be provided during dragging.
|
void |
setSelectionFeedbackEnabled(boolean value)
Sets whether selection feedback should be provided during dragging.
|
abstract boolean |
validateDrop(Object target,
int operation,
TransferData transferType)
Validates dropping on the given object.
|
dragLeavepublic static final int LOCATION_BEFORE
getCurrentLocation(),
Constant Field Valuespublic static final int LOCATION_AFTER
getCurrentLocation(),
Constant Field Valuespublic static final int LOCATION_ON
getCurrentLocation(),
Constant Field Valuespublic static final int LOCATION_NONE
getCurrentLocation(),
Constant Field Valuesprotected ViewerDropAdapter(Viewer viewer)
viewer - the viewerprotected int determineLocation(DropTargetEvent event)
event - the eventLOCATION_* constants defined in this classprotected Object determineTarget(DropTargetEvent event)
event - the eventnull.public void dragEnter(DropTargetEvent event)
DropTargetAdapterdragEnter permits the default
operation defined in event.detailto be performed on the current data type
defined in event.currentDataType.
For additional information see DropTargetListener.dragEnter.dragEnter in interface DropTargetListenerdragEnter in class DropTargetAdapterevent - the information associated with the drag enter eventDropTargetEventpublic void dragOperationChanged(DropTargetEvent event)
DropTargetAdapterdragOperationChanged permits the default
operation defined in event.detailto be performed on the current data type
defined in event.currentDataType.
For additional information see DropTargetListener.dragOperationChanged.dragOperationChanged in interface DropTargetListenerdragOperationChanged in class DropTargetAdapterevent - the information associated with the drag operation changed eventDropTargetEventpublic void dragOver(DropTargetEvent event)
DropTargetAdapterdragOver permits the default
operation defined in event.detailto be performed on the current data type
defined in event.currentDataType.
For additional information see DropTargetListener.dragOver.dragOver in interface DropTargetListenerdragOver in class DropTargetAdapterevent - the information associated with the drag over eventDropTargetEventpublic void drop(DropTargetEvent event)
DropTargetAdapterdrop does nothing.
For additional information see DropTargetListener.drop.drop in interface DropTargetListenerdrop in class DropTargetAdapterevent - the information associated with the drop eventDropTargetEventpublic void dropAccept(DropTargetEvent event)
DropTargetAdapterdropAccept permits the default
operation defined in event.detailto be performed on the current data type
defined in event.currentDataType.
For additional information see DropTargetListener.dropAccept.dropAccept in interface DropTargetListenerdropAccept in class DropTargetAdapterevent - the information associated with the drop accept eventDropTargetEventprotected Rectangle getBounds(Item item)
item - the SWT Itemnull if it is not a known type of itemprotected int getCurrentLocation()
LOCATION_* constants defined in this typeprotected int getCurrentOperation()
DROP_* constant from class DNDDND.DROP_COPY,
DND.DROP_MOVE,
DND.DROP_LINK,
DND.DROP_NONEprotected Object getCurrentTarget()
public boolean getFeedbackEnabled()
Typical insertion feedback is the horizontal insertion bars that appear between adjacent items while dragging.
true if visual feedback is desired, and false if notprotected Object getSelectedObject()
null if either no object or
multiple objects are selectedprotected Viewer getViewer()
protected void handleException(Throwable exception, DropTargetEvent event)
[Issue: Implementation prints stack trace and eats exception to avoid crashing VA/J. Consider conditionalizing the implementation to do one thing in VAJ and something more reasonable in other operating environments. ]
exception - the exceptionevent - the eventpublic abstract boolean performDrop(Object data)
Subclasses must implement this method to provide drop behavior.
data - the drop datatrue if the drop was successful, and
false otherwisepublic void setFeedbackEnabled(boolean value)
Typical insertion feedback is the horizontal insertion bars that appear between adjacent items while dragging.
value - true if visual feedback is desired, and
false if notpublic void setSelectionFeedbackEnabled(boolean value)
value - true if selection feedback is desired, and
false if notpublic void setScrollExpandEnabled(boolean value)
value - true if scrolling and expanding is desired, and
false if notpublic abstract boolean validateDrop(Object target, int operation, TransferData transferType)
Subclasses must implement this method to define which drops make sense.
target - the object that the mouse is currently hovering over, or
null if the mouse is hovering over empty spaceoperation - the current drag operation (copy, move, etc.)transferType - the current transfer typetrue if the drop is valid, and false
otherwiseGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.