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
.editor
.view
.concept
.operation
;
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
.model
.TaxonRelationshipTypeInverseContainer
;
21 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
22 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
25 * <p>CreateConceptRelationOperation class.</p>
32 public class CreateConceptRelationOperation
extends AbstractPostOperation
{
34 private Taxon concept
;
35 private TaxonRelationshipTypeInverseContainer taxonRelationshipTypeInverseContainer
;
38 * <p>Constructor for CreateConceptRelationOperation.</p>
40 * @param label a {@link java.lang.String} object.
41 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
42 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
43 * @param concept a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
44 * @param taxonRelationshipType a {@link eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType} object.
45 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
47 public CreateConceptRelationOperation(String label
,
48 IUndoContext undoContext
, Taxon taxon
, Taxon concept
, TaxonRelationshipTypeInverseContainer taxonRelationshipTypeInverseContainer
49 , IPostOperationEnabled postOperationEnabled
) {
50 super(label
, undoContext
, taxon
, postOperationEnabled
);
51 this.concept
= concept
;
52 this.taxonRelationshipTypeInverseContainer
= taxonRelationshipTypeInverseContainer
;
55 public CreateConceptRelationOperation(String label
,
56 IUndoContext undoContext
, Taxon taxon
, Taxon concept
, TaxonRelationshipType taxonRelationshipType
57 , IPostOperationEnabled postOperationEnabled
) {
58 this(label
, undoContext
, taxon
, concept
, new TaxonRelationshipTypeInverseContainer(taxonRelationshipType
, false), postOperationEnabled
);
62 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
66 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
67 throws ExecutionException
{
70 // add concept to taxon
71 if(taxonRelationshipTypeInverseContainer
.isInverse()){
72 concept
.addTaxonRelation(taxon
, taxonRelationshipTypeInverseContainer
.getType(), null, null);
74 taxon
.addTaxonRelation(concept
, taxonRelationshipTypeInverseContainer
.getType(), null, null);
78 // redraw editor if exists
79 return postExecute(concept
);
83 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
87 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
88 throws ExecutionException
{
89 return execute(monitor
, info
);
93 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
97 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
98 throws ExecutionException
{
100 taxon
.removeTaxon(concept
, taxonRelationshipTypeInverseContainer
.getType());
102 // redraw editor if exists
103 return postExecute(null);