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
.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
.taxon
.Taxon
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
20 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
28 public class CreateConceptRelationOperation
extends AbstractPostOperation
{
30 private Taxon concept
;
31 private TaxonRelationshipType taxonRelationshipType
;
33 public CreateConceptRelationOperation(String label
,
34 IUndoContext undoContext
, Taxon taxon
, Taxon concept
, TaxonRelationshipType taxonRelationshipType
35 , IPostOperationEnabled postOperationEnabled
) {
36 super(label
, undoContext
, taxon
, postOperationEnabled
);
37 this.concept
= concept
;
38 this.taxonRelationshipType
= taxonRelationshipType
;
42 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
45 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
46 throws ExecutionException
{
48 // Start the main progress monitor.
49 IProgressMonitor newMonitor
= StoreUtil
.startMainMonitor(monitor
,"Creating Concept Relationship", 2);
57 // add concept to taxon
58 concept
.addTaxonRelation(taxon
, taxonRelationshipType
, null, null);
59 StoreUtil
.isCanceled(newMonitor
, 1);
63 // Stop the progress monitor.
67 // redraw editor if exists
68 return postExecute(concept
);
72 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
75 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
76 throws ExecutionException
{
77 return execute(monitor
, info
);
81 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
84 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
85 throws ExecutionException
{
87 taxon
.removeTaxon(concept
, taxonRelationshipType
);
89 // redraw editor if exists
90 return postExecute(null);