Project

General

Profile

Download (2.81 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.bulkeditor.operation;
12

    
13
import java.util.Set;
14

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

    
21
import eu.etaxonomy.cdm.model.common.IAnnotatableEntity;
22
import eu.etaxonomy.cdm.model.common.Marker;
23
import eu.etaxonomy.cdm.model.common.MarkerType;
24
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
25
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
26

    
27
/**
28
 * @author n.hoffmann
29
 * @created Dec 13, 2010
30
 * @version 1.0
31
 */
32
public class SetMarkerFlagOperation extends AbstractPostOperation {
33

    
34
	private Set<IAnnotatableEntity> annotatableEntities;
35
	private MarkerType markerType;
36
	private boolean value;
37

    
38
	/**
39
	 * @param label
40
	 * @param undoContext
41
	 * @param postOperationEnabled
42
	 */
43
	public SetMarkerFlagOperation(String label, IUndoContext undoContext,
44
			Set<IAnnotatableEntity> annotatableEntities, MarkerType markerType, boolean value,
45
			IPostOperationEnabled postOperationEnabled) {
46
		super(label, undoContext, postOperationEnabled);
47
		this.annotatableEntities = annotatableEntities;
48
		this.markerType = markerType;
49
		this.value = value;
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
	@Override
56
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
57
			throws ExecutionException {
58
		
59
		for(IAnnotatableEntity annotatableEntity : annotatableEntities){
60
			Marker marker = Marker.NewInstance(markerType, value);
61
			
62
			annotatableEntity.addMarker(marker);
63
		}
64
		
65
		return postExecute(null);
66
	}
67

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

    
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
79
	 */
80
	@Override
81
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
82
			throws ExecutionException {
83
		for(IAnnotatableEntity annotatableEntity : annotatableEntities){
84
			Marker marker = Marker.NewInstance(markerType, ! value);
85
			
86
			annotatableEntity.addMarker(marker);
87
		}
88
		
89
		return postExecute(null);
90
	}
91

    
92
}
    (1-1/1)