ref #8162 move FeatureTree and FeatureNode to new term package in TaxEditor
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / featuretree / e4 / FeatureNodeDragListener.java
index e479ae99ff01b97930fb114d9328f70ae8509625..6987524df7ed01912e290e50fe883547aae3c9a5 100644 (file)
@@ -13,7 +13,7 @@ import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.dnd.DragSourceAdapter;
 import org.eclipse.swt.dnd.DragSourceEvent;
 
-import eu.etaxonomy.cdm.model.description.FeatureNode;
+import eu.etaxonomy.cdm.model.term.FeatureNode;
 import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
 
 public class FeatureNodeDragListener extends DragSourceAdapter {
@@ -30,9 +30,11 @@ public class FeatureNodeDragListener extends DragSourceAdapter {
     @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(selection!=null && !selection.isEmpty()){
+            FeatureNode[] featureNodes = (FeatureNode[]) selection.toList().toArray(new FeatureNode[selection.size()]);
+            if (FeatureNodeTransfer.getInstance().isSupportedType(event.dataType)) {
+                event.data = featureNodes;
+            }
         }
     }
 
@@ -41,7 +43,9 @@ public class FeatureNodeDragListener extends DragSourceAdapter {
         */
        @Override
        public void dragStart(DragSourceEvent event) {
-               event.doit = !viewer.getSelection().isEmpty();
+        event.doit = !viewer.getSelection().isEmpty()
+                && ((IStructuredSelection) viewer.getSelection()).toList()
+                .stream().allMatch(element -> element instanceof FeatureNode);
        }
 
 }
\ No newline at end of file