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
.store
.operations
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.core
.runtime
.IStatus
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
29 public class DeleteSynonymOperation
extends AbstractPostOperation
{
31 private Synonym synonym
;
32 private Set
<SynonymRelationshipType
> synonymTypes
;
34 public DeleteSynonymOperation(String label
, IUndoContext undoContext
,
35 Taxon taxon
, Synonym synonym
, IPostOperationEnabled postOperationEnabled
) {
36 super(label
, undoContext
, taxon
, postOperationEnabled
);
37 this.synonym
= synonym
;
41 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
44 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
45 throws ExecutionException
{
47 // Store synonymRelationshipType for later undo operations
48 synonymTypes
= synonym
.getRelationType(taxon
);
50 // Remove synonym from taxon
51 taxon
.removeSynonym(synonym
);
53 // Redraw editor if exists
54 return postExecute(null);
58 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
61 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
62 throws ExecutionException
{
63 return execute(monitor
, info
);
67 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
70 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
71 throws ExecutionException
{
73 // Add synonym to taxon
74 for (SynonymRelationshipType synonymType
: synonymTypes
){
75 taxon
.addSynonym(synonym
, synonymType
);
78 // Redraw editor if exists
79 return postExecute(synonym
);