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
.INonViralName
;
20 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
21 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
24 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
25 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
28 * <p>CreateSynonymInExistingHomotypicalGroupOperation class.</p>
33 public class CreateSynonymInExistingHomotypicalGroupOperation
extends
34 AbstractPostTaxonOperation
{
36 private final HomotypicalGroup group
;
37 private final TaxonNameBase
<?
,?
> newSynonymName
;
39 private Synonym synonym
;
42 * <p>Constructor for CreateSynonymInExistingHomotypicalGroupOperation.</p>
44 * @param label a {@link java.lang.String} object.
45 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
46 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
47 * @param group a {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup} object.
48 * @param newSynonymName a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
49 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
51 public CreateSynonymInExistingHomotypicalGroupOperation(String label
,
52 IUndoContext undoContext
, Taxon taxon
, HomotypicalGroup group
,
53 TaxonNameBase
<?
,?
> newSynonymName
, IPostOperationEnabled postOperationEnabled
) {
54 super(label
, undoContext
, taxon
, postOperationEnabled
);
56 this.newSynonymName
= newSynonymName
;
61 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
62 throws ExecutionException
{
64 // Add name to given homotypic group
65 group
.addTypifiedName(newSynonymName
);
68 // Create a new synonym for the taxon
70 if(group
.equals(element
.getHomotypicGroup())){
71 synonym
= element
.addHomotypicSynonymName(newSynonymName
);
73 synonym
= element
.addHeterotypicSynonymName(newSynonymName
);
77 // Synonym affectedSynonym = null;
79 // for(Synonym synonym : group.getSynonymsInGroup(taxon.getSec())){
80 // if(synonym.getName() == synonymName){
81 // affectedSynonym = synonym;
86 return postExecute(synonym
);
91 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
92 throws ExecutionException
{
93 return execute(monitor
, info
);
98 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
99 throws ExecutionException
{
101 element
.removeSynonym(synonym
);
103 return postExecute(null);