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
.TaxonNameBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
29 public class ChangeSynonymToConceptOperation
extends AbstractPostOperation
{
30 private Synonym synonym
;
31 private TaxonRelationshipType taxonRelationshipType
;
33 public ChangeSynonymToConceptOperation(String label
,
34 IUndoContext undoContext
, Taxon taxon
, Synonym synonym
, TaxonRelationshipType taxonRelationshipType
, IPostOperationEnabled postOperationEnabled
) {
35 super(label
, undoContext
, taxon
, postOperationEnabled
);
37 this.taxonRelationshipType
= taxonRelationshipType
;
38 this.synonym
= synonym
;
43 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
46 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
47 throws ExecutionException
{
49 // Get name from synonym
50 TaxonNameBase
<?
, ?
> synonymName
= synonym
.getName();
52 // remove synonym from taxon
53 taxon
.removeSynonym(synonym
);
55 // Create a taxon with synonym name
56 Taxon fromTaxon
= Taxon
.NewInstance(synonymName
, null);
59 fromTaxon
.addTaxonRelation(taxon
, taxonRelationshipType
, null, null);
61 // TaxonRelationshipType.
62 // logger.warn("Not yet implemented.");
64 return postExecute(fromTaxon
);
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
{
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
{