import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSourceAdapter;
import org.eclipse.swt.dnd.DragSourceEvent;
import eu.etaxonomy.cdm.model.description.FeatureNode;
import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
-class FeatureNodeDragListener extends DragSourceAdapter {
+public class FeatureNodeDragListener extends DragSourceAdapter {
private final TreeViewer viewer;
this.viewer = viewer;
}
- /**
- * Method declared on DragSourceListener
- */
- @Override
- public void dragFinished(DragSourceEvent event) {
- if (!event.doit) {
- return;
+ /**
+ * Method declared on DragSourceListener
+ */
+ @Override
+ public void dragSetData(DragSourceEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ FeatureNode[] featureNodes = (FeatureNode[]) selection.toList().toArray(new FeatureNode[selection.size()]);
+ if (FeatureNodeTransfer.getInstance().isSupportedType(event.dataType)) {
+ event.data = featureNodes;
}
- // if the featureNode was moved, remove it from the source viewer
- if (event.detail == DND.DROP_MOVE) {
- IStructuredSelection selection = (IStructuredSelection) viewer
- .getSelection();
- viewer.remove(selection);
- viewer.refresh();
- }
- }
-
- /**
- * Method declared on DragSourceListener
- */
- @Override
- public void dragSetData(DragSourceEvent event) {
- IStructuredSelection selection = (IStructuredSelection) viewer
- .getSelection();
- FeatureNode[] featureNodes = (FeatureNode[]) selection.toList()
- .toArray(new FeatureNode[selection.size()]);
- if (FeatureNodeTransfer.getInstance().isSupportedType(
- event.dataType)) {
- event.data = featureNodes;
- }
- }
+ }
/**
* Method declared on DragSourceListener