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 java
.util
.HashSet
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
18 import org
.eclipse
.core
.runtime
.IAdaptable
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.eclipse
.core
.runtime
.IStatus
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
25 import eu
.etaxonomy
.taxeditor
.store
.model
.TaxonUtil
;
32 public class ChangeConceptRelationshipTypeOperation
extends AbstractPostOperation
{
35 private static final Logger logger
= Logger
36 .getLogger(ChangeConceptRelationshipTypeOperation
.class);
38 private Taxon relatedTaxon
;
40 private TaxonRelationship taxonRelationship
;
42 private TaxonRelationshipType oldRelationshipType
;
44 private TaxonRelationshipType newRelationshipType
;
46 public ChangeConceptRelationshipTypeOperation(String label
,
47 IUndoContext undoContext
, Taxon taxon
, Taxon relatedTaxon
, TaxonRelationshipType type
, IPostOperationEnabled postOperationEnabled
) {
48 super(label
, undoContext
, taxon
, postOperationEnabled
);
49 this.relatedTaxon
= relatedTaxon
;
51 this.taxonRelationship
= TaxonUtil
.getRelationshipBetweenTwoTaxa(relatedTaxon
, taxon
);
52 this.oldRelationshipType
= taxonRelationship
.getType();
53 this.newRelationshipType
= type
;
57 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
61 throws ExecutionException
{
62 // Remove relatedTaxon and old relationship
63 // FIXME since taxon relationships come in a set, which relationships are we going to delete here?
64 taxon
.removeTaxon(relatedTaxon
, oldRelationshipType
);
65 // Add new relationship
66 // TODO add microcitation for misapplied name to property sheet
67 relatedTaxon
.addTaxonRelation(taxon
, newRelationshipType
, null, null);
70 return postExecute(relatedTaxon
);
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 return execute(monitor
, info
);
83 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
86 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
87 throws ExecutionException
{
88 // see FIXME in execute()
89 logger
.warn("Not implemented yet. See developer documentation for details");