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
.store
.operations
;
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
.store
.parser
.CdmParserUtil
;
26 * <li>Create synonym name using newSynonymText</li>
27 * <li>Add name to new homotypic group</li>
28 * <li>Create a new synonym for the taxon</li>
35 public class CreateSynonymInNewGroupOperation
extends AbstractPostOperation
{
37 private String newSynonymText
;
38 private SynonymRelationship newSynonymRelationship
;
40 public CreateSynonymInNewGroupOperation(String label
,
41 IUndoContext undoContext
, Taxon taxon
, String newSynonymText
, IPostOperationEnabled postOperationEnabled
) {
42 super(label
, undoContext
, taxon
, postOperationEnabled
);
44 this.newSynonymText
= newSynonymText
;
48 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
51 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
52 throws ExecutionException
{
54 // Create synonym name using newSynonymText
55 TaxonNameBase
<?
, ?
> synonymName
=
56 CdmParserUtil
.parseFullReference(newSynonymText
, null, null);
58 // Add name to new homotypic group
59 HomotypicalGroup
.NewInstance().addTypifiedName(synonymName
);
61 // Create a new synonym for the taxon
62 newSynonymRelationship
= taxon
.addHeterotypicSynonymName(synonymName
);
64 return postExecute(newSynonymRelationship
.getSynonym());
68 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
71 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
72 throws ExecutionException
{
73 return execute(monitor
, info
);
77 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
80 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
81 throws ExecutionException
{
84 taxon
.removeSynonymRelation(newSynonymRelationship
);
85 newSynonymRelationship
= null;
87 return postExecute(null);