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
.reference
.ReferenceBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
28 public class DeleteMisapplicationOperation
extends AbstractPostOperation
{
30 private Taxon misapplication
;
32 private ReferenceBase
<?
> citation
;
34 private String microcitation
;
36 public DeleteMisapplicationOperation(String label
, IUndoContext undoContext
,
37 Taxon taxon
, Taxon misapplication
, IPostOperationEnabled postOperationEnabled
) {
38 super(label
, undoContext
, taxon
, postOperationEnabled
);
40 this.misapplication
= misapplication
;
44 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
47 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
48 throws ExecutionException
{
50 // Find misapplication relation, save citation information
51 for (TaxonRelationship relationship
: taxon
.getTaxonRelations()) {
52 if (relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR())
53 && relationship
.getFromTaxon().equals(misapplication
)) {
54 citation
= relationship
.getCitation();
55 microcitation
= relationship
.getCitationMicroReference();
59 // Remove misapplied name relation from taxon
60 taxon
.removeTaxon(misapplication
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
62 return postExecute(null);
66 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
69 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
70 throws ExecutionException
{
71 return execute(monitor
, info
);
75 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
78 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
79 throws ExecutionException
{
81 taxon
.addMisappliedName(misapplication
, citation
, microcitation
);
83 return postExecute(misapplication
);