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
;
12 import org
.eclipse
.core
.commands
.ExecutionException
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
14 import org
.eclipse
.core
.runtime
.IAdaptable
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.ui
.IWorkbenchPage
;
19 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
22 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
23 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonBaseDeletionConfigurator
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
27 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
28 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
29 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 * <p>DeleteSynonymOperation class.</p>
37 public class DeleteSynonymOperation
extends DeleteTaxonBaseOperation
{
39 private final Synonym synonym
;
40 private SynonymType synonymType
;
44 * <p>Constructor for DeleteSynonymOperation.</p>
46 * @param label a {@link java.lang.String} object.
47 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
48 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
49 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
50 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
52 public DeleteSynonymOperation(String label
, IUndoContext undoContext
, TaxonBaseDeletionConfigurator configurator
,IWorkbenchPage activePage
,
53 Taxon taxon
, Synonym synonym
, IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
,ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
54 super(label
, undoContext
, configurator
, activePage
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
55 this.synonym
= synonym
;
60 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
61 throws ExecutionException
{
63 // Store SynonymType for later undo operations
64 synonymType
= synonym
.getType();
67 // Remove synonym from taxon
68 ICdmApplicationConfiguration controller
;
70 controller
= CdmStore
.getCurrentApplicationConfiguration();
72 ITaxonService service
= controller
.getTaxonService();
73 if (synonym
.getId() == 0){
74 element
.removeSynonym(synonym
);
77 //TODO: this should be moved to the handler, the operations should not contain ui code
78 setResult(service
.deleteSynonym(synonym
.getUuid(), null));
81 // taxon.removeSynonym(synonym);
82 // CdmStore.getTaxonService().deleteSynonymRelationships(synonym);
83 // CdmStore.getTaxonService().delete(synonym);
87 // Redraw editor if exists
89 return postExecute(element
);
94 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
95 throws ExecutionException
{
96 return execute(monitor
, info
);
101 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
102 throws ExecutionException
{
104 // Add synonym to taxon
105 element
.addSynonym(synonym
, synonymType
);
107 // Redraw editor if exists
108 return postExecute(synonym
);
115 public DeleteResult
getResult() {
120 * @param result the result to set
122 public void setResult(DeleteResult result
) {
123 this.result
= result
;