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;
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;
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;
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;
}
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(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);