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
.operations
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
22 import eu
.etaxonomy
.taxeditor
.model
.TaxonHelper
;
29 public class ChangeConceptRelationshipTypeOperation
extends AbstractPostOperation
{
32 private static final Logger logger
= Logger
33 .getLogger(ChangeConceptRelationshipTypeOperation
.class);
35 private Taxon relatedTaxon
;
37 private TaxonRelationship taxonRelationship
;
39 private TaxonRelationshipType oldRelationshipType
;
41 private TaxonRelationshipType newRelationshipType
;
43 public ChangeConceptRelationshipTypeOperation(String label
,
44 IUndoContext undoContext
, Taxon taxon
, Taxon relatedTaxon
, TaxonRelationshipType type
, IPostOperationEnabled postOperationEnabled
) {
45 super(label
, undoContext
, taxon
, postOperationEnabled
);
46 this.relatedTaxon
= relatedTaxon
;
48 this.taxonRelationship
= TaxonHelper
.getRelationshipBetweenTwoTaxa(relatedTaxon
, taxon
);
49 this.oldRelationshipType
= taxonRelationship
.getType();
50 this.newRelationshipType
= type
;
54 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
57 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
58 throws ExecutionException
{
59 // Remove relatedTaxon and old relationship
60 // FIXME since taxon relationships come in a set, which relationships are we going to delete here?
61 taxon
.removeTaxon(relatedTaxon
, oldRelationshipType
);
62 // Add new relationship
63 // TODO add microcitation for misapplied name to property sheet
64 relatedTaxon
.addTaxonRelation(taxon
, newRelationshipType
, null, null);
67 return postExecute(relatedTaxon
);
71 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
74 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
75 throws ExecutionException
{
76 return execute(monitor
, info
);
80 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
83 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
84 throws ExecutionException
{
85 // see FIXME in execute()
86 logger
.warn("Not implemented yet. See developer documentation for details");