Merge branch 'release/5.32.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / termtree / e4 / TermTreeDtoDropAdapter.java
index 806d70b2fca4b43dd29b172c294264d49869ee23..650465b25c22de7a0f8d50c10a28c92352bebfa2 100755 (executable)
@@ -60,6 +60,9 @@ public class TermTreeDtoDropAdapter extends ViewerDropAdapter {
 
        @Override
        public boolean performDrop(Object data) {
+               if (data == null){
+                       return false;
+               }
                Object currentTarget = getCurrentTarget();
                TermNodeDto target = null;
                if(currentTarget instanceof TermTreeDto){
@@ -68,12 +71,16 @@ public class TermTreeDtoDropAdapter extends ViewerDropAdapter {
                else if(currentTarget instanceof TermNodeDto){
                    target = (TermNodeDto) currentTarget;
                }
-
+               
                int position = 0;
                int location = getCurrentLocation();
                UUID parentUuid = target.getParentUuid();
                if(parentUuid!=null){
                    TermNodeDto parent = editor.getNodeDtoForUuid(parentUuid);
+                   if (parent == null){
+                   MessagingUtils.warningDialog("The new node needs to be saved first", this, "Newly created nodes can not be moved or used as parent without saving");
+                   return false;
+               }
                    if (location == LOCATION_BEFORE) {
                        position = Math.max(0, parent.getIndex(target));
                        target = parent;