ref #3535: update both name editors after moving description oder description elements
authorKatja Luther <k.luther@bgbm.org>
Thu, 6 Sep 2018 08:13:44 +0000 (10:13 +0200)
committerKatja Luther <k.luther@bgbm.org>
Thu, 6 Sep 2018 08:13:44 +0000 (10:13 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionElementsHandlerE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionToOtherTaxonHandlerE4.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingMoveTaxonNodeHandlerE4.java

index 776dbd5082153af1189d76943ded95c407896ff7..1fadf38dc9c09f86dc1b0b297466e8431a1e432c 100644 (file)
@@ -66,6 +66,7 @@ import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
  */
 public class MoveDescriptionElementsHandlerE4 implements IPostOperationEnabled{
     private UUID newAcceptedTaxonNodeUuid;
+    private UUID oldAcceptedTaxonNodeUuid;
     private TaxonNameEditorE4 editor;
     private MApplication application;
     private EModelService modelService;
@@ -133,7 +134,8 @@ public class MoveDescriptionElementsHandlerE4 implements IPostOperationEnabled{
         if (actualTaxon != null){
             if (!actualTaxon.getTaxonNodes().isEmpty() && actualTaxon.getTaxonNodes().size() ==1){
                 actualNode = actualTaxon.getTaxonNodes().iterator().next();
-                excludeTaxa.add(actualNode.getUuid());
+                oldAcceptedTaxonNodeUuid = actualNode.getUuid();
+                excludeTaxa.add(oldAcceptedTaxonNodeUuid);
                 classification = actualNode.getClassification();
 
             }
@@ -181,6 +183,7 @@ public class MoveDescriptionElementsHandlerE4 implements IPostOperationEnabled{
 //                        AbstractUtility.close(possibleOpenEditor);
 //                    }
                 EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid, modelService, partService, application);
+                EditorUtil.openTaxonNodeE4(oldAcceptedTaxonNodeUuid, modelService, partService, application);
             }
 
         });
index ee9aca61132233d1d76ce494fbb5821d83008641..091b7ae17d7851279a5d0a81fbec77734fa1aac8 100644 (file)
@@ -57,6 +57,9 @@ public class MoveDescriptionToOtherTaxonHandlerE4 implements IPostOperationEnabl
     private MoveDescriptionToOtherTaxonOperation operation;
 
     private UUID newAcceptedTaxonNodeUuid;
+    private UUID oldAcceptedTaxonNodeUuid;
+    private UUID newAcceptedTaxonUuid;
+    private UUID oldAcceptedTaxonUuid;
     private TaxonNameEditorE4 editor;
     private MApplication application;
     private EModelService modelService;
@@ -100,17 +103,20 @@ public class MoveDescriptionToOtherTaxonHandlerE4 implements IPostOperationEnabl
         descriptions.add(description);
 
         // Choose the target taxon
-        Set<UUID> excludeTaxa = new HashSet<>();
 
-        excludeTaxa.add(descriptions.get(0).getTaxon().getUuid());
 
         //get current taxon node
         TaxonNode node = null;
         Classification classification = null;
         if(editor!=null){
             node = editor.getEditorInput().getTaxonNode();
+            oldAcceptedTaxonUuid = editor.getTaxon().getUuid();
+            oldAcceptedTaxonNodeUuid = node.getUuid();
             classification = node.getClassification();
         }
+
+        Set<UUID> excludeTaxa = new HashSet<>();
+        excludeTaxa.add(oldAcceptedTaxonNodeUuid);
         TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
 //                editor.getConversationHolder(),
                 Messages.MoveDescriptionToOtherTaxonHandler_CHOOSE_ACC_TAXON,
@@ -123,7 +129,7 @@ public class MoveDescriptionToOtherTaxonHandlerE4 implements IPostOperationEnabl
         }
 
         newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
-
+        newAcceptedTaxonUuid = newAcceptedTaxonNode.getTaxon().getUuid();
         for(TaxonDescription taxonDescription : descriptions){
             operation = new MoveDescriptionToOtherTaxonOperation(menuItem.getLocalizedLabel(),
                     editor.getUndoContext(),
@@ -153,7 +159,10 @@ public class MoveDescriptionToOtherTaxonHandlerE4 implements IPostOperationEnabl
 //                    if(possibleOpenEditor != null){
 //                        AbstractUtility.close(possibleOpenEditor);
 //                    }
+//                    EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, oldAcceptedTaxonNodeUuid);
+//                    EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, newAcceptedTaxonNodeUuid);
                     EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid, modelService, partService, application);
+                    EditorUtil.openTaxonNodeE4(oldAcceptedTaxonNodeUuid, modelService, partService, application);
 //                } catch (PartInitException e) {
 //                    MessagingUtils.error(this.getClass(), e);
 //                    throw new RuntimeException(e);
index b65a703a7643f4e406331fb5523042e59f6ebd3f..675cf8fecef39bba0c39fb847e1d561f6ec3bfcd 100644 (file)
@@ -66,6 +66,7 @@ public class RemotingMoveTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 {
                     TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
         }
         // check that selected object is a taxon node
+
         Object obj ;
         Iterator iter = selection.iterator();
         oldTaxonNodeUUIDs = new HashSet<>();