fixing #4808
authorKatja Luther <k.luther@bgbm.org>
Mon, 16 Nov 2015 13:31:12 +0000 (14:31 +0100)
committerKatja Luther <k.luther@bgbm.org>
Mon, 16 Nov 2015 13:31:12 +0000 (14:31 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDragListener.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDropAdapter.java

index e5e58d0f675cd52dd980bf0eebeb0b383ec679b7..86c95a2c1f1aa20558b5339f08e80b7baddb95bf 100644 (file)
@@ -61,7 +61,9 @@ public class DescriptionElementDragListener extends DragSourceAdapter {
                List<DescriptionElementBase> descriptionElements = new ArrayList<DescriptionElementBase>();
                for (Object object : selection.toList()){
                        if(object instanceof DescriptionBase){
                List<DescriptionElementBase> descriptionElements = new ArrayList<DescriptionElementBase>();
                for (Object object : selection.toList()){
                        if(object instanceof DescriptionBase){
-                               descriptionElements.addAll(((DescriptionBase) object).getElements());
+                               if (!((DescriptionBase) object).getElements().isEmpty()){
+                                       descriptionElements.addAll(((DescriptionBase) object).getElements());
+                               }
                                description = HibernateProxyHelper.deproxy(object, DescriptionBase.class);
                                
                        }else if(object instanceof FeatureNodeContainer){
                                description = HibernateProxyHelper.deproxy(object, DescriptionBase.class);
                                
                        }else if(object instanceof FeatureNodeContainer){
@@ -73,7 +75,9 @@ public class DescriptionElementDragListener extends DragSourceAdapter {
                }
                if (DescriptionElementTransfer.getInstance().isSupportedType(
                                event.dataType)) {
                }
                if (DescriptionElementTransfer.getInstance().isSupportedType(
                                event.dataType)) {
-                       event.data = descriptionElements.toArray(new DescriptionElementBase[descriptionElements.size()]);
+                       if (!descriptionElements.isEmpty()){
+                               event.data = descriptionElements.toArray(new DescriptionElementBase[descriptionElements.size()]);
+                       }
                        
                }
                
                        
                }
                
index 9af171323df34d178dcdba4bac6010721bc07b05..e7d7f2907df81a1ffe7a8f96baa5cbab9fbf8fbb 100644 (file)
@@ -52,30 +52,34 @@ public class DescriptionElementDropAdapter extends ViewerDropAdapter {
                boolean isCopy = getCurrentOperation() == DND.DROP_COPY ? true : false;
                
                // cannot drop a feature node onto itself
                boolean isCopy = getCurrentOperation() == DND.DROP_COPY ? true : false;
                
                // cannot drop a feature node onto itself
-               for (Object droppedElement : droppedElements) {                 
-                       if (droppedElement == null){
-                               MessagingUtils.warningDialog("Operation not supported yet", this, "We are currently unable to drag and drop a newly created element. Please save the editor to make this work.");
-                               return false;
-                       }
-                       if(! (droppedElement instanceof DescriptionElementBase)){
-                               return false;
-                       }else{
-                               DescriptionElementBase descriptionElement = (DescriptionElementBase) droppedElement;
-                               
-                               if (descriptionElement.getInDescription().equals(target)) {
+               if (droppedElements != null){
+                       for (Object droppedElement : droppedElements) {                 
+                               if (droppedElement == null){
+                                       MessagingUtils.warningDialog("Operation not supported yet", this, "We are currently unable to drag and drop a newly created element. Please save the editor to make this work.");
                                        return false;
                                }
                                        return false;
                                }
-                               
-                               descriptionElements.add(descriptionElement);
-                       }                       
+                               if(! (droppedElement instanceof DescriptionElementBase)){
+                                       return false;
+                               }else{
+                                       DescriptionElementBase descriptionElement = (DescriptionElementBase) droppedElement;
+                                       
+                                       if (descriptionElement.getInDescription().equals(target)) {
+                                               return false;
+                                       }
+                                       
+                                       descriptionElements.add(descriptionElement);
+                               }                       
+                       }
+                       
+                       AbstractPostOperation operation = new MoveDescriptionElementsOperation("Move Descriptions", EditorUtil.getUndoContext(), target, descriptionElements, isCopy, null);
+                       
+                       EditorUtil.executeOperation(operation);
+                       return true;
                }
                }
+               MessagingUtils.warningDialog("Operation not supported yet", this, "We are unable to drag and drop empty descriptions");
+       
+               return false;
                
                
-               AbstractPostOperation operation = new MoveDescriptionElementsOperation("Move Descriptions", EditorUtil.getUndoContext(), target, descriptionElements, isCopy, null);
-               
-               EditorUtil.executeOperation(operation);
-               
-               
-               return true;
        }
 
        /* (non-Javadoc)
        }
 
        /* (non-Javadoc)