Project

General

Profile

Download (2.09 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.editor.view.concept.operation;
11

    
12
import java.util.Set;
13

    
14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.commands.operations.IUndoContext;
16
import org.eclipse.core.runtime.IAdaptable;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IStatus;
19

    
20
import eu.etaxonomy.cdm.model.taxon.Taxon;
21
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
22
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
23
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
24

    
25
/**
26
 * Deletes given relations between two taxa.
27
 *
28
 * @author p.ciardelli
29
 * @author n.hoffmann
30
 * @created 29.01.2009
31
 */
32
public class DeleteConceptRelationOperation extends AbstractPostTaxonOperation {
33

    
34
	private final Set<TaxonRelationship> taxonRelationships;
35

    
36
	public DeleteConceptRelationOperation(String label,
37
			IUndoContext undoContext, Taxon taxon, Set<TaxonRelationship> relations,
38
			IPostOperationEnabled postOperationEnabled) {
39
		super(label, undoContext, taxon, postOperationEnabled);
40

    
41
		taxonRelationships = relations;
42
	}
43

    
44
	@Override
45
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
46
			throws ExecutionException {
47

    
48
		monitor.worked(20);
49

    
50
		// Remove relation from taxon
51
		for(TaxonRelationship relationship : taxonRelationships){
52
		    element.removeTaxonRelation(relationship);
53
			monitor.worked(10);
54
		}
55
		monitor.worked(10);
56

    
57
		return postExecute(element);
58
	}
59

    
60
	@Override
61
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
62
			throws ExecutionException {
63
		return execute(monitor, info);
64
	}
65

    
66
	@Override
67
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
68
			throws ExecutionException {
69

    
70
		for(TaxonRelationship relationship : taxonRelationships){
71
		    element.addTaxonRelation(relationship);
72
			monitor.worked(10);
73
		}
74

    
75
		return postExecute(element);
76
	}
77
}
(2-2/2)