Project

General

Profile

Download (3.19 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.media.operation;
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.api.utility.ImagesUtility;
19
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
20
import eu.etaxonomy.cdm.model.media.ImageFile;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
23
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
24

    
25
/**
26
 * <p>RemoveImageFromDescriptionElementOperation class.</p>
27
 *
28
 * @author p.ciardelli
29
 * @author n.hoffmann
30
 * @created 05.02.2009
31
 * @version 1.0
32
 */
33
public class RemoveImageFromDescriptionElementOperation extends AbstractPostTaxonOperation {
34
	
35
	private DescriptionElementBase element;
36
	private ImageFile image;
37

    
38
	/**
39
	 * <p>Constructor for RemoveImageFromDescriptionElementOperation.</p>
40
	 *
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 element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
44
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
45
	 * @param label a {@link java.lang.String} object.
46
	 * @param image a {@link eu.etaxonomy.cdm.model.media.ImageFile} object.
47
	 */
48
	public RemoveImageFromDescriptionElementOperation(String label,
49
			IUndoContext undoContext, Taxon taxon, ImageFile image,
50
			DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {
51
		super(label, undoContext, taxon, postOperationEnabled);
52
		
53
		this.image = image;
54
		this.element = element;
55
	}
56

    
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
59
	 */
60
	/** {@inheritDoc} */
61
	@Override
62
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
63
			throws ExecutionException {
64

    
65
		monitor.worked(20);
66
		ImagesUtility.removeImage(element, image);
67
		monitor.worked(40);
68

    
69
		return postExecute(element);
70
	}
71

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

    
82
	/* (non-Javadoc)
83
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
84
	 */
85
	/** {@inheritDoc} */
86
	@Override
87
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
88
			throws ExecutionException {
89
		image = ImagesUtility.addImagePart(element);
90
		return postExecute(image);
91
	}
92
}
(5-5/5)