Project

General

Profile

Download (3.07 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.operations;
11

    
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;
17

    
18
import eu.etaxonomy.cdm.model.taxon.Taxon;
19
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
20

    
21
/**
22
 * <p>CreateConceptRelationOperation class.</p>
23
 *
24
 * @author p.ciardelli
25
 * @author n.hoffmann
26
 * @created 26.01.2009
27
 * @version 1.0
28
 */
29
public class CreateConceptRelationOperation extends AbstractPostOperation {
30
	
31
	private Taxon concept;
32
	private TaxonRelationshipType taxonRelationshipType;
33
	
34
	/**
35
	 * <p>Constructor for CreateConceptRelationOperation.</p>
36
	 *
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.
43
	 */
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;
50
	}
51

    
52
	/* (non-Javadoc)
53
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
54
	 */
55
	/** {@inheritDoc} */
56
	@Override
57
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
58
			throws ExecutionException {
59

    
60
		monitor.worked(20);
61
		// add concept to taxon
62
		concept.addTaxonRelation(taxon, taxonRelationshipType, null, null);	
63
		monitor.worked(40);
64
		
65
		// redraw editor if exists
66
		return postExecute(concept);
67
	}
68

    
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
71
	 */
72
	/** {@inheritDoc} */
73
	@Override
74
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
75
			throws ExecutionException {
76
		return execute(monitor, info);
77
	}
78

    
79
	/* (non-Javadoc)
80
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
81
	 */
82
	/** {@inheritDoc} */
83
	@Override
84
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
85
			throws ExecutionException {
86
		
87
		taxon.removeTaxon(concept, taxonRelationshipType);
88
		
89
		// redraw editor if exists
90
		return postExecute(null);
91
	}
92
}
(14-14/40)