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
;
22 * <p>CreateConceptRelationOperation class.</p>
29 public class CreateConceptRelationOperation
extends AbstractPostOperation
{
31 private Taxon concept
;
32 private TaxonRelationshipType taxonRelationshipType
;
35 * <p>Constructor for CreateConceptRelationOperation.</p>
37 * @param label a {@link java.lang.String} object.
38 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
39 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
40 * @param concept a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
41 * @param taxonRelationshipType a {@link eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType} object.
42 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
44 public CreateConceptRelationOperation(String label
,
45 IUndoContext undoContext
, Taxon taxon
, Taxon concept
, TaxonRelationshipType taxonRelationshipType
46 , IPostOperationEnabled postOperationEnabled
) {
47 super(label
, undoContext
, taxon
, postOperationEnabled
);
48 this.concept
= concept
;
49 this.taxonRelationshipType
= taxonRelationshipType
;
53 * @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
{
61 // add concept to taxon
62 concept
.addTaxonRelation(taxon
, taxonRelationshipType
, null, null);
65 // redraw editor if exists
66 return postExecute(concept
);
70 * @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)
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);