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
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
19 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.ITreeNode
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
24 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
25 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
30 * Change the taxonomic parent of a given taxon.
36 public class ChangeSynonymToAcceptedTaxonOperation
extends AbstractPersistentPostOperation
{
38 private Taxon newTaxon
;
39 private Synonym synonym
;
40 private ITreeNode parentNode
;
42 private TaxonNode newNode
;
44 private Synonym
[] synonymsInHomotypicalGroup
;
47 * <p>Constructor for ChangeSynonymToAcceptedTaxonOperation.</p>
49 * @param label a {@link java.lang.String} object.
50 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
51 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
52 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
53 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
54 * @param synonymsInHomotypicalGroup an array of {@link eu.etaxonomy.cdm.model.taxon.Synonym} objects.
55 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
56 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
58 public ChangeSynonymToAcceptedTaxonOperation(String label
, IUndoContext undoContext
,
59 Taxon taxon
, ITreeNode parentNode
, Synonym synonym
, Synonym
[] synonymsInHomotypicalGroup
, IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
) {
60 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
63 this.parentNode
= parentNode
;
64 this.synonym
= synonym
;
65 this.synonymsInHomotypicalGroup
= synonymsInHomotypicalGroup
;
69 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
74 throws ExecutionException
{
76 newTaxon
= CdmStore
.getService(ITaxonService
.class).changeSynonymToAcceptedTaxon(synonym
, taxon
);
79 // synonym.setSec(null);
81 // TODO let user choose parent
82 newNode
= parentNode
.addChildTaxon(newTaxon
, null, null, null);
84 if(synonymsInHomotypicalGroup
!= null){
85 Taxon taxon
= newNode
.getTaxon();
86 for (Synonym synonym
: synonymsInHomotypicalGroup
){
87 taxon
.addHomotypicSynonym(synonym
, null, null);
93 return postExecute(newNode
);
97 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
101 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
102 throws ExecutionException
{
103 return execute(monitor
, info
);
107 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
111 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
112 throws ExecutionException
{
114 // TODO implement - biggest problem is that any window open for new taxon must be closed first
115 StoreUtil
.warn(this.getClass(), "Not yet implemented");
117 return postExecute(taxon
);