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
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
22 import eu
.etaxonomy
.cdm
.api
.service
.exception
.HomotypicalGroupChangeException
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
28 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
29 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
30 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
31 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
32 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
33 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
36 * Change the taxonomic parent of a given taxon.
42 public class ChangeSynonymToAcceptedTaxonOperation
extends AbstractPersistentPostOperation
{
44 private Taxon newTaxon
;
45 private final Synonym synonym
;
46 private final ITaxonTreeNode parentNode
;
48 private TaxonNode newNode
;
50 //private final Set<TaxonNameBase> namesInHomotypicGroup;
53 * <p>Constructor for ChangeSynonymToAcceptedTaxonOperation.</p>
55 * @param label a {@link java.lang.String} object.
56 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
57 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
58 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
59 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
60 * @param synonymsInHomotypicalGroup an array of {@link eu.etaxonomy.cdm.model.taxon.Synonym} objects.
61 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
62 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
64 public ChangeSynonymToAcceptedTaxonOperation(String label
,
65 IUndoContext undoContext
,
67 ITaxonTreeNode parentNode
,
69 Set
<TaxonNameBase
> namesInHomotypicalGroup
,
70 IPostOperationEnabled postOperationEnabled
,
71 IConversationEnabled conversationEnabled
,
72 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
73 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
76 this.parentNode
= parentNode
;
77 this.synonym
= synonym
;
78 //this.namesInHomotypicGroup = namesInHomotypicalGroup;
84 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
85 throws ExecutionException
{
88 newNode
= (TaxonNode
) CdmStore
.getService(ITaxonService
.class).changeSynonymToAcceptedTaxon(synonym
.getUuid(),
92 } catch (HomotypicalGroupChangeException e
) {
93 MessagingUtils
.warningDialog(Messages
.ChangeSynonymToAcceptedTaxonOperation_INCONSISTENT_DATA
, getClass(), e
.getMessage());
94 return postExecute(null);
97 //newTaxon = (Taxon) CdmStore.getService(ITaxonService.class).merge(newTaxon);
98 //element.removeSynonym(synonym);
101 /*if(namesInHomotypicGroup != null){
102 Taxon taxon = newNode.getTaxon();
103 for (TaxonNameBase synonymName : namesInHomotypicGroup){
104 taxon.addHomotypicSynonymName(synonymName, null, null);
108 //newNode = CdmStore.getService(ITaxonNodeService.class).merge(newNode);
112 return postExecute(newNode
);
117 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
118 throws ExecutionException
{
119 return execute(monitor
, info
);
124 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
125 throws ExecutionException
{
127 // TODO implement - biggest problem is that any window open for new taxon must be closed first
128 MessagingUtils
.warn(this.getClass(), Messages
.ChangeSynonymToAcceptedTaxonOperation_NOT_IMPLEMENTED
);
130 return postExecute(element
);