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
.model
.MessagingUtils
;
29 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
30 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
31 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
34 * Change the taxonomic parent of a given taxon.
40 public class ChangeSynonymToAcceptedTaxonOperation
extends AbstractPersistentPostOperation
{
42 private Taxon newTaxon
;
43 private final Synonym synonym
;
44 private final ITaxonTreeNode parentNode
;
46 private TaxonNode newNode
;
48 private final Set
<TaxonNameBase
> namesInHomotypicGroup
;
51 * <p>Constructor for ChangeSynonymToAcceptedTaxonOperation.</p>
53 * @param label a {@link java.lang.String} object.
54 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
55 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
56 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
57 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
58 * @param synonymsInHomotypicalGroup an array of {@link eu.etaxonomy.cdm.model.taxon.Synonym} objects.
59 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
60 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
62 public ChangeSynonymToAcceptedTaxonOperation(String label
, IUndoContext undoContext
,
63 Taxon taxon
, ITaxonTreeNode parentNode
, Synonym synonym
, Set
<TaxonNameBase
> namesInHomotypicalGroup
, IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
) {
64 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
67 this.parentNode
= parentNode
;
68 this.synonym
= synonym
;
69 this.namesInHomotypicGroup
= namesInHomotypicalGroup
;
73 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
77 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
78 throws ExecutionException
{
81 newTaxon
= CdmStore
.getService(ITaxonService
.class).changeSynonymToAcceptedTaxon(synonym
, element
, true, true, null, null);
82 } catch (HomotypicalGroupChangeException e
) {
83 MessagingUtils
.warningDialog("Operation may lead to inconsistent data", getClass(), e
.getMessage());
84 return postExecute(null);
89 newNode
= parentNode
.addChildTaxon(newTaxon
, null, null);
91 /*if(namesInHomotypicGroup != null){
92 Taxon taxon = newNode.getTaxon();
93 for (TaxonNameBase synonymName : namesInHomotypicGroup){
94 taxon.addHomotypicSynonymName(synonymName, null, null);
101 return postExecute(newNode
);
105 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
109 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
110 throws ExecutionException
{
111 return execute(monitor
, info
);
115 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
119 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
120 throws ExecutionException
{
122 // TODO implement - biggest problem is that any window open for new taxon must be closed first
123 MessagingUtils
.warn(this.getClass(), "Not yet implemented");
125 return postExecute(element
);