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 void |
clearState()
Clears internal state of this drop adapter.
|
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 DropTargetEvent |
getCurrentEvent()
Returns the current
DropTargetEvent . |
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() |
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. ] |
protected void |
overrideOperation(int operation)
Overrides the current operation for a drop that happens immediately
after the current validateDrop.
|
abstract boolean |
performDrop(Object data)
Performs any work associated with the drop.
|
void |
setExpandEnabled(boolean value)
Sets whether auto expanding should be provided during dragging.
|
void |
setFeedbackEnabled(boolean value)
Sets whether visible insertion feedback should be presented to the user.
|
void |
setScrollEnabled(boolean value)
Sets whether auto scrolling should be provided during dragging.
|
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.
|
dragLeave
public 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 void clearState()
protected int determineLocation(DropTargetEvent event)
event
- the eventLOCATION_*
constants defined in this classprotected Object determineTarget(DropTargetEvent event)
event
- the eventnull
.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 Itemnull
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()
protected DropTargetEvent getCurrentEvent()
DropTargetEvent
.
This may be called only inside of the validateDrop(Object, int, TransferData)
or performDrop(Object)
methods.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()
protected Viewer getViewer()
@Deprecated 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
otherwiseprotected void overrideOperation(int operation)
validateDrop(Object, int, TransferData)
methodoperation
- the operation to be used for the drop.DND.DROP_COPY
,
DND.DROP_MOVE
,
DND.DROP_LINK
,
DND.DROP_NONE
public 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 void setExpandEnabled(boolean value)
value
- true
if expanding is desired, and
false
if notpublic void setScrollEnabled(boolean value)
value
- true
if scrolling 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
otherwise
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.