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
.Synonym
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
31 public class ChangeConceptToSynonymOperation
extends
32 AbstractPostOperation
{
34 private Taxon concept
;
36 private HomotypicalGroup homotypicalGroup
;
38 public ChangeConceptToSynonymOperation(String label
,
39 IUndoContext undoContext
, Taxon taxon
, Taxon concept
, HomotypicalGroup homotypicalGroup
,
40 IPostOperationEnabled editor
) {
41 super(label
, undoContext
, taxon
, editor
);
43 this.concept
= concept
;
44 this.homotypicalGroup
= homotypicalGroup
;
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 new synonym using concept name
55 TaxonNameBase
<?
, ?
> synonymName
= concept
.getName();
56 Synonym synonym
= Synonym
.NewInstance(synonymName
, taxon
.getSec());
58 // Remove concept relation from taxon
59 taxon
.removeTaxon(concept
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
63 taxon
.addSynonym(synonym
, SynonymRelationshipType
.SYNONYM_OF());
65 if(homotypicalGroup
!= null){
66 // Add synonym to homotypical group
67 homotypicalGroup
.addTypifiedName(synonymName
);
70 return postExecute(synonym
);
74 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
77 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
78 throws ExecutionException
{
79 // TODO redo for change misapplied name ...
84 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
87 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
88 throws ExecutionException
{
89 // TODO undo for change misapplied name ...