refactored folder structure
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / DeleteImageOperation.java
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.model.description.DescriptionBase;
20 import eu.etaxonomy.cdm.model.media.ImageFile;
21 import eu.etaxonomy.cdm.model.taxon.Taxon;
22 import eu.etaxonomy.taxeditor.model.ImagesUtil;
23
24 /**
25 * @author p.ciardelli
26 * @created 31.03.2009
27 * @version 1.0
28 */
29 public class DeleteImageOperation extends AbstractPostOperation {
30
31 private ImageFile imageFile;
32
33 private DescriptionBase<?> description;
34
35 /**
36 * @param text
37 * @param undoContext
38 * @param taxon
39 * @param url
40 */
41 public DeleteImageOperation(String label, IUndoContext undoContext,
42 Taxon taxon, DescriptionBase<?> description, ImageFile imageFile, IPostOperationEnabled postOperationEnabled) {
43 super(label, undoContext, taxon, postOperationEnabled);
44
45 this.imageFile = imageFile;
46 this.description = description;
47 }
48
49 /* (non-Javadoc)
50 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
51 */
52 @Override
53 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
54 throws ExecutionException {
55
56 ImagesUtil.removeTaxonImage(taxon, description, imageFile);
57
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 ImagesUtil.addTaxonImage(taxon, description, imageFile);
79
80 return postExecute(null);
81 }
82
83
84 }