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
.operations
.name
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
17 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
18 import org
.eclipse
.core
.runtime
.IAdaptable
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.eclipse
.core
.runtime
.IStatus
;
21 import org
.eclipse
.core
.runtime
.Status
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
26 import eu
.etaxonomy
.taxeditor
.controller
.GlobalController
;
27 import eu
.etaxonomy
.taxeditor
.editor
.name
.TaxonNameEditor
;
28 import eu
.etaxonomy
.taxeditor
.operations
.AbstractEditorOperation
;
35 public class RemoveSynonymOperation
extends AbstractEditorOperation
{
36 private static final Logger logger
= Logger
37 .getLogger(RemoveSynonymOperation
.class);
39 private Synonym synonym
;
40 private Set
<SynonymRelationshipType
> synonymTypes
;
42 public RemoveSynonymOperation(String label
, IUndoContext undoContext
,
43 Taxon taxon
, Synonym synonym
) {
44 super(label
, undoContext
, taxon
);
45 this.synonym
= synonym
;
49 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
52 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
53 throws ExecutionException
{
55 // Store synonymRelationshipType for later undo operations
56 synonymTypes
= synonym
.getRelationType(taxon
);
58 // Remove synonym from taxon
59 taxon
.removeSynonym(synonym
);
61 // Redraw editor if exists
62 return redrawOpenEditor();
66 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
69 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
70 throws ExecutionException
{
71 return execute(monitor
, info
);
75 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
78 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
79 throws ExecutionException
{
81 // Add synonym to taxon
82 for (SynonymRelationshipType synonymType
: synonymTypes
){
83 taxon
.addSynonym(synonym
, synonymType
);
86 // Redraw editor if exists
87 return redrawOpenEditor();