Project

General

Profile

Download (2.42 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.operations;
12

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

    
19
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
20
import eu.etaxonomy.cdm.model.description.DescriptionBase;
21
import eu.etaxonomy.cdm.model.media.Media;
22

    
23
/**
24
 * @author p.ciardelli
25
 * @created 31.03.2009
26
 * @version 1.0
27
 */
28
public class DeleteMediaOperation extends AbstractPostOperation {
29
	
30
	private Media media;
31

    
32
	private DescriptionBase<?> description;
33

    
34
	/**
35
	 * @param text
36
	 * @param undoContext
37
	 * @param taxon
38
	 * @param url
39
	 */
40
	public DeleteMediaOperation(String label, IUndoContext undoContext,
41
			DescriptionBase<?> description, Media media, IPostOperationEnabled postOperationEnabled) {
42
		super(label, undoContext, postOperationEnabled);
43
		
44
		this.media = media;
45
		this.description = description;
46
	}
47

    
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
50
	 */
51
	@Override
52
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
53
			throws ExecutionException {
54

    
55
		monitor.worked(20);
56
    	ImagesUtility.removeMediaFromGallery(description, media);
57
		monitor.worked(40);
58

    
59
		return postExecute(null);
60
	}
61

    
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
64
	 */
65
	@Override
66
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
67
			throws ExecutionException {
68
		return execute(monitor, info);
69
	}
70

    
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73
	 */
74
	@Override
75
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
76
			throws ExecutionException {
77
		
78
		ImagesUtility.addMediaToGallery(description, media);
79
		
80
		return postExecute(null);
81
	}
82

    
83

    
84
}
(25-25/40)