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
.operation
;
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
;
23 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
24 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
27 * <p>DeleteSynonymOperation class.</p>
33 public class DeleteSynonymOperation
extends AbstractPostOperation
{
35 private Synonym synonym
;
36 private Set
<SynonymRelationshipType
> synonymTypes
;
39 * <p>Constructor for DeleteSynonymOperation.</p>
41 * @param label a {@link java.lang.String} object.
42 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
43 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
44 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
45 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
47 public DeleteSynonymOperation(String label
, IUndoContext undoContext
,
48 Taxon taxon
, Synonym synonym
, IPostOperationEnabled postOperationEnabled
) {
49 super(label
, undoContext
, taxon
, postOperationEnabled
);
50 this.synonym
= synonym
;
54 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
58 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
59 throws ExecutionException
{
61 // Store synonymRelationshipType for later undo operations
62 synonymTypes
= synonym
.getRelationType(taxon
);
65 // Remove synonym from taxon
67 taxon
.removeSynonym(synonym
);
68 // CdmStore.getTaxonService().deleteSynonymRelationships(synonym);
69 // CdmStore.getTaxonService().delete(synonym);
73 // Redraw editor if exists
74 return postExecute(null);
78 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
82 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
83 throws ExecutionException
{
84 return execute(monitor
, info
);
88 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
92 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
93 throws ExecutionException
{
95 // Add synonym to taxon
96 for (SynonymRelationshipType synonymType
: synonymTypes
){
97 taxon
.addSynonym(synonym
, synonymType
);
100 // Redraw editor if exists
101 return postExecute(synonym
);