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
.api
.application
.CdmApplicationController
;
21 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
25 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
26 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 * <p>DeleteSynonymOperation class.</p>
36 public class DeleteSynonymOperation
extends AbstractPostOperation
{
38 private Synonym synonym
;
39 private Set
<SynonymRelationshipType
> synonymTypes
;
42 * <p>Constructor for DeleteSynonymOperation.</p>
44 * @param label a {@link java.lang.String} object.
45 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
46 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
47 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
48 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
50 public DeleteSynonymOperation(String label
, IUndoContext undoContext
,
51 Taxon taxon
, Synonym synonym
, IPostOperationEnabled postOperationEnabled
) {
52 super(label
, undoContext
, taxon
, postOperationEnabled
);
53 this.synonym
= synonym
;
57 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
61 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
62 throws ExecutionException
{
64 // Store synonymRelationshipType for later undo operations
65 synonymTypes
= synonym
.getRelationType(taxon
);
68 // Remove synonym from taxon
70 CdmApplicationController controller
;
72 controller
= (CdmApplicationController
) CdmStore
.getCurrentApplicationConfiguration();
74 ITaxonService service
= controller
.getTaxonService();
75 service
.deleteSynonym(synonym
, null);
77 // taxon.removeSynonym(synonym);
78 // CdmStore.getTaxonService().deleteSynonymRelationships(synonym);
79 // CdmStore.getTaxonService().delete(synonym);
83 // Redraw editor if exists
85 return postExecute(null);
89 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
93 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
94 throws ExecutionException
{
95 return execute(monitor
, info
);
99 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
103 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
104 throws ExecutionException
{
106 // Add synonym to taxon
107 for (SynonymRelationshipType synonymType
: synonymTypes
){
108 taxon
.addSynonym(synonym
, synonymType
);
111 // Redraw editor if exists
112 return postExecute(synonym
);