// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
Page.NAME);
-
+ Shell shell = HandlerUtil.getActiveShell(event);
+ if (!EditorUtil.forceUserSave(editor, shell)) {
+ return null;
+ }
Object selectedElement = EditorUtil.getSelection(event).getFirstElement();
-
+
AbstractPostOperation operation = null;
try {
if(selectedElement instanceof Taxon){
- operation = new ChangeConceptRelationshipTypeOperation(event.getCommand().getName(),
+ operation = new ChangeConceptRelationshipTypeOperation(event.getCommand().getName(),
editor.getUndoContext(), editor.getTaxon(), (Taxon) selectedElement, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), editor);
}
if(selectedElement instanceof Synonym){
- operation = new ChangeSynonymToMisapplicationOperation(event.getCommand().getName(),
+ operation = new ChangeSynonymToMisapplicationOperation(event.getCommand().getName(),
editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
}
-
+
EditorUtil.executeOperation(operation);
} catch (NotDefinedException e) {
logger.warn("Command name not set");
}
-
+
return null;
}
}