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.DescriptionBase;
|
20
|
import eu.etaxonomy.cdm.model.media.Media;
|
21
|
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
|
22
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
23
|
|
24
|
/**
|
25
|
* <p>RemoveImageFromDescriptionElementOperation class.</p>
|
26
|
*
|
27
|
* @author p.ciardelli
|
28
|
* @author n.hoffmann
|
29
|
* @created 05.02.2009
|
30
|
*/
|
31
|
public class RemoveImageFromDescriptionElementOperation extends AbstractPostTaxonOperation {
|
32
|
|
33
|
private DescriptionBase<?> element;
|
34
|
private Media media;
|
35
|
|
36
|
/**
|
37
|
* <p>Constructor for RemoveImageFromDescriptionElementOperation.</p>
|
38
|
*
|
39
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object
|
40
|
* @param media
|
41
|
* @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object
|
42
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object
|
43
|
* @param label a {@link java.lang.String} object
|
44
|
*/
|
45
|
public RemoveImageFromDescriptionElementOperation(String label,
|
46
|
IUndoContext undoContext, Media media,
|
47
|
DescriptionBase element, IPostOperationEnabled postOperationEnabled) {
|
48
|
super(label, undoContext, postOperationEnabled);
|
49
|
|
50
|
this.media = media;
|
51
|
this.element = element;
|
52
|
}
|
53
|
|
54
|
/** {@inheritDoc} */
|
55
|
@Override
|
56
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
57
|
throws ExecutionException {
|
58
|
|
59
|
monitor.worked(20);
|
60
|
ImagesUtility.removeMediaFromGallery(element, media);
|
61
|
monitor.worked(40);
|
62
|
|
63
|
return postExecute(element);
|
64
|
}
|
65
|
|
66
|
/** {@inheritDoc} */
|
67
|
@Override
|
68
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
69
|
throws ExecutionException {
|
70
|
return execute(monitor, info);
|
71
|
}
|
72
|
|
73
|
/** {@inheritDoc} */
|
74
|
@Override
|
75
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
76
|
throws ExecutionException {
|
77
|
ImagesUtility.addMediaToGallery(element, media);
|
78
|
return postExecute(media);
|
79
|
}
|
80
|
}
|