ref #7998 Set feature tree text field to editable=false
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / featuretree / e4 / FeatureNodeDragListener.java
index e479ae99ff01b97930fb114d9328f70ae8509625..341878736e3a7b229d82bb83233b33c42f9936c7 100644 (file)
@@ -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