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
.TaxonNameBase
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
23 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
27 * <li>Create synonym name using newSynonymText</li>
28 * <li>Add name to new homotypic group</li>
29 * <li>Create a new synonym for the taxon</li>
37 public class CreateSynonymInNewGroupOperation
extends AbstractPostTaxonOperation
{
39 // TODO replace this with TaxonNameBase
40 private final TaxonNameBase newSynonymName
;
41 private SynonymRelationship newSynonymRelationship
;
44 * <p>Constructor for CreateSynonymInNewGroupOperation.</p>
46 * @param label a {@link java.lang.String} object.
47 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
48 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
49 * @param newSynonymName a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
50 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
52 public CreateSynonymInNewGroupOperation(String label
,
53 IUndoContext undoContext
, Taxon taxon
, TaxonNameBase newSynonymName
, IPostOperationEnabled postOperationEnabled
) {
54 super(label
, undoContext
, taxon
, postOperationEnabled
);
56 this.newSynonymName
= newSynonymName
;
60 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
64 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
65 throws ExecutionException
{
67 // Add name to new homotypic group
68 HomotypicalGroup
.NewInstance().addTypifiedName(newSynonymName
);
71 // Create a new synonym for the taxon
72 newSynonymRelationship
= element
.addHeterotypicSynonymName(newSynonymName
);
75 return postExecute(newSynonymRelationship
.getSynonym());
79 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
83 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
84 throws ExecutionException
{
85 return execute(monitor
, info
);
89 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
93 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
94 throws ExecutionException
{
97 element
.removeSynonymRelation(newSynonymRelationship
);
98 newSynonymRelationship
= null;
100 return postExecute(null);