minor
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / navigator / TreeNodeDropAdapter.java
index e0f8a056682c00baa38a17452a86ab1df8f46d55..d01a59371a82eb428fdbd9c3dedc57a221639abd 100644 (file)
@@ -66,6 +66,10 @@ public class TreeNodeDropAdapter extends ViewerDropAdapter implements IPostOpera
 
        private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
 
+       public enum MovingType{
+           CHILD, PREVIOUS, BEHIND
+       }
+
 
 
        /* (non-Javadoc)
@@ -206,14 +210,14 @@ public class TreeNodeDropAdapter extends ViewerDropAdapter implements IPostOpera
                        }
 
                        AbstractPostOperation operation = new MoveTaxonOperation
-                                       ("Move Taxon", workspaceUndoContext, uuids, targetITaxonTreeNode, this, taxonNavigator, true);
+                                       ("Move Taxon", workspaceUndoContext, uuids, targetITaxonTreeNode, this, taxonNavigator, MovingType.CHILD);
                        NavigationUtil.executeOperation(operation);
 
                        logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
                        return true;
                }else{
-                       String[] buttonLables = {"Parent", "Predecessor", "Cancel"};
-                       MessageDialog dialog = new MessageDialog(null, "Target node", null, "Do you want to use the target node as parent or do you want to move the taxon below the target.", MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
+                       String[] buttonLables = {"Child", "Behind","Cancel"};
+                       MessageDialog dialog = new MessageDialog(null, "Target node", null, "Do you want to move the Taxonnode as child or behind the target node.", MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
                        dialog.open();
                        int returnCode = dialog.getReturnCode();
                        if (returnCode == 0){
@@ -224,7 +228,7 @@ public class TreeNodeDropAdapter extends ViewerDropAdapter implements IPostOpera
                                }
 
                                AbstractPostOperation operation = new MoveTaxonOperation
-                                               ("Move Taxon", workspaceUndoContext, uuids, targetITaxonTreeNode, this, taxonNavigator, true);
+                                               ("Move Taxon", workspaceUndoContext, uuids, targetITaxonTreeNode, this, taxonNavigator, MovingType.CHILD);
                                NavigationUtil.executeOperation(operation);
 
                                logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
@@ -238,12 +242,28 @@ public class TreeNodeDropAdapter extends ViewerDropAdapter implements IPostOpera
                                TaxonNode targetNode = (TaxonNode) targetITaxonTreeNode;
 
                                AbstractPostOperation operation = new MoveTaxonOperation
-                                               ("Move Taxon", workspaceUndoContext, uuids, targetNode.getParent(), this, taxonNavigator, false);
+                                               ("Move Taxon", workspaceUndoContext, uuids, targetNode, this, taxonNavigator, MovingType.PREVIOUS);
                                NavigationUtil.executeOperation(operation);
 
                                logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
                                return true;
-                       } else{
+                       }
+//                     } else if (returnCode == 2){
+//                IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext();
+//                if (workspaceUndoContext == null) {
+//                    logger.error("Workspace undo context is null. DND operation cancelled");
+//                    return false;
+//                }
+//                TaxonNode targetNode = (TaxonNode) targetITaxonTreeNode;
+//
+//                AbstractPostOperation operation = new MoveTaxonOperation
+//                        ("Move Taxon", workspaceUndoContext, uuids, targetNode, this, taxonNavigator, MovingType.BEHIND);
+//                NavigationUtil.executeOperation(operation);
+//
+//                logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
+//                return true;
+//            }
+                               else{
                                return false;
                        }