minor
authorKatja Luther <k.luther@bgbm.org>
Mon, 2 Nov 2015 08:33:03 +0000 (09:33 +0100)
committerKatja Luther <k.luther@bgbm.org>
Mon, 2 Nov 2015 08:33:03 +0000 (09:33 +0100)
1  2 
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/MoveSynonymToAnotherAcceptedTaxonHandler.java

index 37cd4d1e733075100b9f83b77eacd83b9d5a3711,4ffee2de6d6fe299e67b7a844729fa35f62428d0..bb5fb10aceb55dc921bf38d1c598a8bd1517afcc
@@@ -1,5 -1,9 +1,9 @@@
  package eu.etaxonomy.taxeditor.editor.name.handler;
  
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.UUID;
  import org.apache.log4j.Logger;
  import org.eclipse.core.commands.AbstractHandler;
  import org.eclipse.core.commands.ExecutionEvent;
@@@ -9,10 -13,6 +13,6 @@@ import org.eclipse.swt.widgets.Shell
  import org.eclipse.ui.IEditorInput;
  import org.eclipse.ui.handlers.HandlerUtil;
  
- import java.util.ArrayList;
- import java.util.List;
- import java.util.UUID;
  import eu.etaxonomy.cdm.model.common.CdmBase;
  import eu.etaxonomy.cdm.model.taxon.Synonym;
  import eu.etaxonomy.cdm.model.taxon.Taxon;
@@@ -22,6 -22,7 +22,7 @@@ import eu.etaxonomy.taxeditor.editor.Mu
  import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
  import eu.etaxonomy.taxeditor.editor.name.operation.MoveSynonymToAnotherAcceptedTaxonOperation;
  import eu.etaxonomy.taxeditor.model.AbstractUtility;
+ import eu.etaxonomy.taxeditor.model.MessagingUtils;
  import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
  import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
  
@@@ -35,6 -36,10 +36,10 @@@ public class MoveSynonymToAnotherAccept
                editor =  (MultiPageTaxonEditor) HandlerUtil.getActiveEditor(event);
                Shell shell = HandlerUtil.getActiveShell(event);
                IEditorInput input = editor.getEditorInput();
+               // Get synonym from selection before possible save dialog
+               // because the selection will be null if save dialog is shown
+               StructuredSelection selection = (StructuredSelection) HandlerUtil.getCurrentSelection(event);
                if (!EditorUtil.forceUserSave(editor, shell)) {
                        return null;
                }
@@@ -44,9 -49,8 +49,8 @@@
                        return null;
                }
  
-               // Get synonym from selection
-               StructuredSelection selection = (StructuredSelection) HandlerUtil.getCurrentSelection(event);
-               if (!(selection.getFirstElement() instanceof Synonym)) {
+               if (selection==null || !(selection.getFirstElement() instanceof Synonym)) {
+                   MessagingUtils.warningDialog("No selection", this, "No synonym selected");
                        logger.error("Selection does not contain a Synonym");
                        return null;
                }
                Taxon oldParent = ((TaxonEditorInput)input).getTaxon();
                List<UUID> excludeTaxa = new ArrayList<UUID>();
                excludeTaxa.add(oldParent.getUuid());
 -              TaxonNode newParentNode = TaxonNodeSelectionDialog.select(editor.getSite().getShell(), editor.getConversationHolder(), "Select new accepted taxon", null, null, ((TaxonEditorInput)input).getTaxonNode().getClassification());
 +                              
 +              TaxonNode newParentNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), editor.getConversationHolder(), "Select new accepted taxon", excludeTaxa, null, ((TaxonEditorInput)input).getTaxonNode().getClassification());
++
                if(newParentNode!=null){
                   MoveSynonymToAnotherAcceptedTaxonOperation operation = new MoveSynonymToAnotherAcceptedTaxonOperation("Change accepted Taxon of Synonym", EditorUtil.getUndoContext(),
                            oldParent.getUuid(), synonym.getUuid(), newParentNode.getTaxon(), editor);