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
.model
.name
.HomotypicalGroup
;
19 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
23 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
26 * <p>CreateSynonymInExistingHomotypicalGroupOperation class.</p>
31 public class CreateSynonymInExistingHomotypicalGroupOperation
extends
32 AbstractPostTaxonOperation
{
34 private final HomotypicalGroup group
;
35 private final NonViralName newSynonymName
;
37 private Synonym synonym
;
40 * <p>Constructor for CreateSynonymInExistingHomotypicalGroupOperation.</p>
42 * @param label a {@link java.lang.String} object.
43 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
44 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
45 * @param group a {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup} object.
46 * @param newSynonymName a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
47 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
49 public CreateSynonymInExistingHomotypicalGroupOperation(String label
,
50 IUndoContext undoContext
, Taxon taxon
, HomotypicalGroup group
, NonViralName newSynonymName
, IPostOperationEnabled postOperationEnabled
) {
51 super(label
, undoContext
, taxon
, postOperationEnabled
);
53 this.newSynonymName
= newSynonymName
;
58 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
59 throws ExecutionException
{
61 // Add name to given homotypic group
62 group
.addTypifiedName(newSynonymName
);
65 // Create a new synonym for the taxon
67 if(group
.equals(element
.getHomotypicGroup())){
68 synonym
= element
.addHomotypicSynonymName(newSynonymName
);
70 synonym
= element
.addHeterotypicSynonymName(newSynonymName
);
74 // Synonym affectedSynonym = null;
76 // for(Synonym synonym : group.getSynonymsInGroup(taxon.getSec())){
77 // if(synonym.getName() == synonymName){
78 // affectedSynonym = synonym;
83 return postExecute(synonym
);
88 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
89 throws ExecutionException
{
90 return execute(monitor
, info
);
95 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
96 throws ExecutionException
{
98 element
.removeSynonym(synonym
);
100 return postExecute(null);