2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.handler
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.IHandler
;
15 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
17 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
19 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
20 import eu
.etaxonomy
.taxeditor
.editor
.Page
;
21 import eu
.etaxonomy
.taxeditor
.editor
.name
.TaxonNameEditor
;
22 import eu
.etaxonomy
.taxeditor
.editor
.name
.operation
.DeleteMisapplicationOperation
;
23 import eu
.etaxonomy
.taxeditor
.editor
.name
.operation
.DeleteSynonymOperation
;
24 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
27 * <p>DeleteTaxonBaseHandler class.</p>
33 public class DeleteTaxonBaseHandler
extends AbstractHandler
implements IHandler
{
36 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
39 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
40 TaxonNameEditor editor
= (TaxonNameEditor
) EditorUtil
.getActiveEditorPage(Page
.NAME
);
42 Object selectedElement
= EditorUtil
.getSelection(event
).getFirstElement();
44 doExecute(event
, editor
, selectedElement
);
51 * @param selectedElement
55 protected void doExecute(ExecutionEvent event
, TaxonNameEditor editor
, Object selectedElement
) {
56 AbstractPostOperation operation
= null;
57 String commandName
= null;
60 commandName
= event
.getCommand().getName();
61 } catch (NotDefinedException e
) {
62 EditorUtil
.error(getClass(), e
);
66 if(selectedElement
instanceof Synonym
){
67 operation
= new DeleteSynonymOperation(commandName
, editor
.getUndoContext(), editor
.getTaxon(), (Synonym
) selectedElement
, editor
);
70 else if(selectedElement
instanceof Taxon
&& ((Taxon
) selectedElement
).isMisapplication()){
71 operation
= new DeleteMisapplicationOperation(commandName
, editor
.getUndoContext(), editor
72 .getTaxon(), (Taxon
) selectedElement
, editor
);
75 throw new IllegalArgumentException("Element has to be Synonym, Misapplication or Concept");
78 EditorUtil
.executeOperation(operation
);