Package org.eclipse.gef.dnd
Class AbstractTransferDropTargetListener
java.lang.Object
org.eclipse.gef.dnd.AbstractTransferDropTargetListener
- All Implemented Interfaces:
- EventListener,- TransferDropTargetListener,- TransferDropTargetListener,- DropTargetListener
- Direct Known Subclasses:
- TemplateTransferDropTargetListener
public abstract class AbstractTransferDropTargetListener
extends Object
implements TransferDropTargetListener, TransferDropTargetListener
An abstract implementation of TransferDropTargetListener for use with
 
EditPartViewers. The Viewer's Control should be the Drop
 target. In order to communicate with EditParts in a consistent way,
 DropTargetEvents are processed into Requests.
 Dropping is inherently a targeting interaction. This class handles calculating the target EditPart. It also handles common targeting behavior, such as interacting with the target EditPart or its ancestors to achieve things like auto-scroll/auto-expose.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a new AbstractTransferDropTargetListener and sets the EditPartViewer.AbstractTransferDropTargetListener(EditPartViewer viewer, Transfer xfer) Constructs a new AbstractTransferDropTargetListener and sets the EditPartViewer and Transfer.
- 
Method SummaryModifier and TypeMethodDescriptionprotected RequestCreates and returns theRequestthat will be sent to the targeted EditPart.voiddragEnter(DropTargetEvent event) Stores the information about the current DropTargetEvent.voiddragLeave(DropTargetEvent event) Stores the information about the current DropTargetEvent and then callsunload().voidStores the information about the current DropTargetEvent and then callshandleDragOperationChanged().voiddragOver(DropTargetEvent event) Stores the information about the current DropTargetEvent and then callshandleDragOver().voiddrop(DropTargetEvent event) Stores the information about the current DropTargetEvent and then callshandleDrop(), followed byunload().voiddropAccept(DropTargetEvent event) Stores the currentDropTargetEventand does nothing.protected voidCallseraseTargetFeedback(Request)on the current target, using the target Request.protected CommandReturns the current command from the target EditPart.Returns the currentDropTargetEvent.protected PointReturns the current mouse location, as aPoint.protected Collection<EditPart> Returns a Collection ofEditPartsthat are to be excluded when searching for the target EditPart.protected EditPartReturns the current targetEditPart.protected RequestReturns the targetRequest.protected EditPartViewerReturns theEditPartViewerthat is the target of the drop.protected voidCalled when the user changes the Drag operation.protected voidCalled whenever the User drags over the target.protected voidUpdates the target Request and target EditPart, and performs the drop.protected voidCalled when a new target EditPart has been entered.protected voidCalled as the current target EditPart is being exited.protected voidCalled when the mouse hovers during drag and drop.protected voidCalled when the mouse resumes motion after having hovered.booleanisEnabled(DropTargetEvent event) Returnstrueif this TransferDropTargetListener is enabled for the specifiedDropTargetEvent.protected booleanReturnstrueifisEnabled(DropTargetEvent)is determined by asking the potential target for a Command.protected voidsetAutoexposeHelper(AutoexposeHelper helper) Sets the current autoexpose helper.voidsetCurrentEvent(DropTargetEvent currentEvent) Sets the current DropTargetEvent.protected voidsetEnablementDeterminedByCommand(boolean value) Determines if the target editpart should be asked for a Command duringisEnabled(DropTargetEvent).protected voidSets the targetEditPart.protected voidsetTransfer(Transfer xfer) Sets the Tranfer type that this listener can handle.protected voidsetViewer(EditPartViewer viewer) Sets the EditPartViewer.protected voidAsks the targetEditPartto show target feedback if it is notnull.protected voidunload()Erases target feedback and sets the request tonull.protected voidUpdates the activeAutoexposeHelper.protected voidUpdates the target EditPart.protected abstract voidSubclasses must implement this to update the target Request.
- 
Constructor Details- 
AbstractTransferDropTargetListenerConstructs a new AbstractTransferDropTargetListener and sets the EditPartViewer. If you use this constructor, you must set the Transfer yourself usingsetTransfer(Transfer).- Parameters:
- viewer- the EditPartViewer
 
- 
AbstractTransferDropTargetListenerConstructs a new AbstractTransferDropTargetListener and sets the EditPartViewer and Transfer. The Viewer's Control should be the Drop target.- Parameters:
- viewer- the EditPartViewer
- xfer- the Transfer
 
 
- 
- 
Method Details- 
createTargetRequestCreates and returns theRequestthat will be sent to the targeted EditPart. Subclasses can override to create specialized requests.- Returns:
- the Requestto be used with the target EditPart
 
- 
dragEnterStores the information about the current DropTargetEvent. This method may not be called on the listener, because the listener may not be made active until after the mouse has entered the drop target.- Specified by:
- dragEnterin interface- DropTargetListener
- See Also:
 
- 
dragLeaveStores the information about the current DropTargetEvent and then callsunload(). Subclasses should overrideunload()to perform actions for this event. For some reason, SWT also callsdragLeave()when the actual drop is performed, even though the mouse has not left the drop target.- Specified by:
- dragLeavein interface- DropTargetListener
- See Also:
 
- 
dragOperationChangedStores the information about the current DropTargetEvent and then callshandleDragOperationChanged(). Subclasses should overridehandleDragOperationChanged()to perform actions for this event.- Specified by:
- dragOperationChangedin interface- DropTargetListener
- See Also:
 
- 
dragOverStores the information about the current DropTargetEvent and then callshandleDragOver(). Subclasses should overridehandleDragOver()to perform actions for this event.- Specified by:
- dragOverin interface- DropTargetListener
- See Also:
 
- 
dropStores the information about the current DropTargetEvent and then callshandleDrop(), followed byunload(). Subclasses should override these methods to perform actions for this event.- Specified by:
- dropin interface- DropTargetListener
- See Also:
 
- 
dropAcceptStores the currentDropTargetEventand does nothing. By default, the drop is accepted.- Specified by:
- dropAcceptin interface- DropTargetListener
- See Also:
 
- 
eraseTargetFeedbackprotected void eraseTargetFeedback()CallseraseTargetFeedback(Request)on the current target, using the target Request. Does nothing if there is no target, or if the target has not been requested to show target feedback.
- 
getCommandReturns the current command from the target EditPart.- Returns:
- The current command from the target EditPart
 
- 
getCurrentEventReturns the currentDropTargetEvent.- Returns:
- the current event
 
- 
getDropLocationReturns the current mouse location, as aPoint. The location is relative to the control's client area.- Returns:
- the drop location
 
- 
getExclusionSetReturns a Collection ofEditPartsthat are to be excluded when searching for the target EditPart.- Returns:
- A Collection of EditParts to be excluded
 
- 
getTargetEditPartReturns the current targetEditPart.- Returns:
- the target EditPart
 
- 
getTargetRequestReturns the targetRequest. If the target Request isnull,createTargetRequest()is called and the newly created Request is returned.- Returns:
- the target Request
 
- 
getTransfer- Specified by:
- getTransferin interface- TransferDropTargetListener
- See Also:
 
- 
getViewerReturns theEditPartViewerthat is the target of the drop.- Returns:
- the EditPartViewer
 
- 
handleDragOperationChangedprotected void handleDragOperationChanged()Called when the user changes the Drag operation. By default, target feedback is erased. The target Request and target EditPart are updated, and target feedback is re-displayed on the new target.
- 
handleDragOverprotected void handleDragOver()Called whenever the User drags over the target. By default, the target Request and target EditPart are updated, feedback is shown, and auto-expose occurs.
- 
handleDropprotected void handleDrop()Updates the target Request and target EditPart, and performs the drop. By default, the drop is performed by asking the target EditPart for a Command using the target Request. This Command is then executed on the CommandStack.If there is no target EditPart or no executable Command, the event's detailfield is set toDND.DROP_NONE.
- 
handleEnteredEditPartprotected void handleEnteredEditPart()Called when a new target EditPart has been entered. By default, the new target is asked to show feedback.
- 
handleExitingEditPartprotected void handleExitingEditPart()Called as the current target EditPart is being exited. By default, the target is asked to erase feedback.
- 
handleHoverprotected void handleHover()Called when the mouse hovers during drag and drop.
- 
handleHoverStopprotected void handleHoverStop()Called when the mouse resumes motion after having hovered.
- 
isEnabledReturnstrueif this TransferDropTargetListener is enabled for the specifiedDropTargetEvent. By default, this is calculated by comparing the event'sdataTypeswith theTransfer'ssupported types (Transfer.isSupportedType(TransferData)). If a dataType is supported, an attempt is made to find a targetEditPartat the current drop location. If a targetEditPartis found,trueis returned, and the DropTargetEvent'sDropTargetEvent.currentDataTypeis set to the dataType that matched.- Specified by:
- isEnabledin interface- TransferDropTargetListener
- Parameters:
- event- the DropTargetEvent
- Returns:
- trueif this TransferDropTargetListener is enabled for the given DropTargetEvent
 
- 
isEnablementDeterminedByCommandprotected boolean isEnablementDeterminedByCommand()ReturnstrueifisEnabled(DropTargetEvent)is determined by asking the potential target for a Command.- Returns:
- trueif the target will be queried for a- Command
- Since:
- 3.1
 
- 
setAutoexposeHelperSets the current autoexpose helper.- Parameters:
- helper- the autoexpose helper
 
- 
setEnablementDeterminedByCommandprotected void setEnablementDeterminedByCommand(boolean value) Determines if the target editpart should be asked for a Command duringisEnabled(DropTargetEvent). For most DND operations, the data is not available, thus asking for a command would not make sense. The default value isfalse.- Parameters:
- value-- trueif a
- Since:
- 3.1
 
- 
setCurrentEventSets the current DropTargetEvent.- Parameters:
- currentEvent- the DropTargetEvent
 
- 
setTargetEditPartSets the targetEditPart. If the target is changing,handleExitingEditPart()is called before the target changes, andhandleEnteredEditPart()is called afterwards.- Parameters:
- ep- the new target EditPart
 
- 
setTransferSets the Tranfer type that this listener can handle.- Parameters:
- xfer- the Transfer
 
- 
setViewerSets the EditPartViewer.- Parameters:
- viewer- the EditPartViewer
 
- 
showTargetFeedbackprotected void showTargetFeedback()Asks the targetEditPartto show target feedback if it is notnull.- See Also:
 
- 
unloadprotected void unload()Erases target feedback and sets the request tonull.
- 
updateAutoexposeHelperprotected void updateAutoexposeHelper()Updates the activeAutoexposeHelper. Does nothing if there is still an active helper. Otherwise, obtains a new helper (possiblenull) at the current mouse location and callssetAutoexposeHelper(AutoexposeHelper).
- 
updateTargetEditPartprotected void updateTargetEditPart()Updates the target EditPart.
- 
updateTargetRequestprotected abstract void updateTargetRequest()Subclasses must implement this to update the target Request.
 
-