org.eclipse.cdt.internal.ui.dnd
Class CDTViewerDropAdapter

java.lang.Object
  extended by org.eclipse.cdt.internal.ui.dnd.CDTViewerDropAdapter
All Implemented Interfaces:
java.util.EventListener, org.eclipse.swt.dnd.DropTargetListener, org.eclipse.swt.internal.SWTEventListener
Direct Known Subclasses:
FileTransferDropAdapter, ResourceTransferDropAdapter, SelectionTransferDropAdapter

public class CDTViewerDropAdapter
extends java.lang.Object
implements org.eclipse.swt.dnd.DropTargetListener

A drag and drop adapter to be used together with structured viewers. The adapater delegates the dragEnter, dragOperationChanged , dragOver and dropAccept method to the validateDrop method. Furthermore it adds location feedback.


Field Summary
static int INSERTION_FEEDBACK
          Style to enable location feedback.
static int LOCATION_AFTER
          Constant describing the position of the mouse cursor relative to the target object.
static int LOCATION_BEFORE
          Constant describing the position of the mouse cursor relative to the target object.
static int LOCATION_NONE
          Constant describing the position of the mouse cursor relative to the target object.
static int LOCATION_ON
          Constant describing the position of the mouse cursor relative to the target object.
 
Constructor Summary
CDTViewerDropAdapter(org.eclipse.jface.viewers.StructuredViewer viewer, int feedback)
           
 
Method Summary
 void dragEnter(org.eclipse.swt.dnd.DropTargetEvent event)
           
 void dragLeave(org.eclipse.swt.dnd.DropTargetEvent event)
           
 void dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent event)
           
 void dragOver(org.eclipse.swt.dnd.DropTargetEvent event)
           
 void drop(org.eclipse.swt.dnd.DropTargetEvent event)
          The actual drop has occurred.
 void drop(java.lang.Object target, org.eclipse.swt.dnd.DropTargetEvent event)
          The actual drop has occurred.
 void dropAccept(org.eclipse.swt.dnd.DropTargetEvent event)
           
 void internalTestSetLocation(int location)
           
 void showInsertionFeedback(boolean showInsertionFeedback)
          Controls whether the drop adapter shows insertion feedback or not.
 void validateDrop(org.eclipse.swt.dnd.DropTargetEvent event)
          Checks if the drop is valid.
 void validateDrop(java.lang.Object target, org.eclipse.swt.dnd.DropTargetEvent event, int operation)
          Checks if the drop on the current target is valid.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCATION_NONE

public static final int LOCATION_NONE
Constant describing the position of the mouse cursor relative to the target object. This means the mouse is not positioned over or near any valid target.

See Also:
Constant Field Values

LOCATION_ON

public static final int LOCATION_ON
Constant describing the position of the mouse cursor relative to the target object. This means the mouse is positioned directly on the target.

See Also:
Constant Field Values

LOCATION_BEFORE

public static final int LOCATION_BEFORE
Constant describing the position of the mouse cursor relative to the target object. This means the mouse is positioned slightly before the target.

See Also:
Constant Field Values

LOCATION_AFTER

public static final int LOCATION_AFTER
Constant describing the position of the mouse cursor relative to the target object. This means the mouse is positioned slightly after the target.

See Also:
Constant Field Values

INSERTION_FEEDBACK

public static final int INSERTION_FEEDBACK
Style to enable location feedback.

See Also:
Constant Field Values
Constructor Detail

CDTViewerDropAdapter

public CDTViewerDropAdapter(org.eclipse.jface.viewers.StructuredViewer viewer,
                            int feedback)
Method Detail

showInsertionFeedback

public void showInsertionFeedback(boolean showInsertionFeedback)
Controls whether the drop adapter shows insertion feedback or not.

Parameters:
showInsertionFeedback - true if the drop adapter is supposed to show insertion feedback. Otherwise false

drop

public void drop(org.eclipse.swt.dnd.DropTargetEvent event)
The actual drop has occurred. Calls drop(Object target, DropTargetEvent event) .

Specified by:
drop in interface org.eclipse.swt.dnd.DropTargetListener
See Also:
DropTargetListener.drop(org.eclipse.swt.dnd.DropTargetEvent)

drop

public void drop(java.lang.Object target,
                 org.eclipse.swt.dnd.DropTargetEvent event)
The actual drop has occurred.

Parameters:
target - the drop target in form of a domain element.
event - the drop traget event

validateDrop

public void validateDrop(org.eclipse.swt.dnd.DropTargetEvent event)
Checks if the drop is valid. The method calls validateDrop (Object target, DropTargetEvent event). Implementors can alter the currentDataType field and the detail field to give feedback about drop acceptence.


validateDrop

public void validateDrop(java.lang.Object target,
                         org.eclipse.swt.dnd.DropTargetEvent event,
                         int operation)
Checks if the drop on the current target is valid. The method can alter the currentDataType field and the detail field to give feedback about drop acceptence.

Parameters:
target - the drop target in form of a domain element.
event - the drop traget event
operation - the operation requested by the user.

dragEnter

public void dragEnter(org.eclipse.swt.dnd.DropTargetEvent event)
Specified by:
dragEnter in interface org.eclipse.swt.dnd.DropTargetListener

dragLeave

public void dragLeave(org.eclipse.swt.dnd.DropTargetEvent event)
Specified by:
dragLeave in interface org.eclipse.swt.dnd.DropTargetListener

dragOperationChanged

public void dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent event)
Specified by:
dragOperationChanged in interface org.eclipse.swt.dnd.DropTargetListener

dragOver

public void dragOver(org.eclipse.swt.dnd.DropTargetEvent event)
Specified by:
dragOver in interface org.eclipse.swt.dnd.DropTargetListener

dropAccept

public void dropAccept(org.eclipse.swt.dnd.DropTargetEvent event)
Specified by:
dropAccept in interface org.eclipse.swt.dnd.DropTargetListener

internalTestSetLocation

public void internalTestSetLocation(int location)