|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.swt.dnd.DropTargetAdapter | +--org.eclipse.jface.viewers.ViewerDropAdapter
This adapter class provides generic drag-and-drop support for a viewer.
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).
Field Summary | |
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. |
Constructor Summary | |
protected |
ViewerDropAdapter(Viewer viewer)
Creates a new drop adapter for the given viewer. |
Method Summary | |
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.detail to 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.detail to 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.detail to 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.detail to 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)
Handles any exception that occurs during callback, including rethrowing behavior. |
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. |
abstract boolean |
validateDrop(Object target,
int operation,
TransferData transferType)
Validates dropping on the given object. |
Methods inherited from class org.eclipse.swt.dnd.DropTargetAdapter |
dragLeave |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LOCATION_BEFORE
#getLocation
,
Constant Field Valuespublic static final int LOCATION_AFTER
#getLocation
,
Constant Field Valuespublic static final int LOCATION_ON
#getLocation
,
Constant Field Valuespublic static final int LOCATION_NONE
#getLocation
,
Constant Field ValuesConstructor Detail |
protected ViewerDropAdapter(Viewer viewer)
viewer
- the viewerMethod Detail |
protected int determineLocation(DropTargetEvent event)
event
- the event
LOCATION_*
constants defined in this classprotected Object determineTarget(DropTargetEvent event)
event
- the event
null
.public void dragEnter(DropTargetEvent event)
DropTargetAdapter
dragEnter
permits the default
operation defined in event.detail
to be performed on the current data type
defined in event.currentDataType
.
For additional information see DropTargetListener.dragEnter
.
dragEnter
in interface DropTargetListener
dragEnter
in class DropTargetAdapter
event
- the information associated with the drag enter eventDropTargetEvent
public void dragOperationChanged(DropTargetEvent event)
DropTargetAdapter
dragOperationChanged
permits the default
operation defined in event.detail
to be performed on the current data type
defined in event.currentDataType
.
For additional information see DropTargetListener.dragOperationChanged
.
dragOperationChanged
in interface DropTargetListener
dragOperationChanged
in class DropTargetAdapter
event
- the information associated with the drag operation changed eventDropTargetEvent
public void dragOver(DropTargetEvent event)
DropTargetAdapter
dragOver
permits the default
operation defined in event.detail
to be performed on the current data type
defined in event.currentDataType
.
For additional information see DropTargetListener.dragOver
.
dragOver
in interface DropTargetListener
dragOver
in class DropTargetAdapter
event
- the information associated with the drag over eventDropTargetEvent
public void drop(DropTargetEvent event)
DropTargetAdapter
drop
does nothing.
For additional information see DropTargetListener.drop
.
drop
in interface DropTargetListener
drop
in class DropTargetAdapter
event
- the information associated with the drop eventDropTargetEvent
public void dropAccept(DropTargetEvent event)
DropTargetAdapter
dropAccept
permits the default
operation defined in event.detail
to be performed on the current data type
defined in event.currentDataType
.
For additional information see DropTargetListener.dropAccept
.
dropAccept
in interface DropTargetListener
dropAccept
in class DropTargetAdapter
event
- the information associated with the drop accept eventDropTargetEvent
protected Rectangle getBounds(Item item)
item
- the SWT Item
null
if it is not a known type of itemprotected int getCurrentLocation()
LOCATION_*
constants defined in this typeprotected int getCurrentOperation()
DROP_*
constant from class DND
DND.DROP_COPY
,
DND.DROP_MOVE
,
DND.DROP_LINK
,
DND.DROP_NONE
protected 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 data
true
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 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 type
true
if the drop is valid, and false
otherwise
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |