p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / operations / images / RemoveImageOperation.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.images;
12
13 import java.net.URL;
14
15 import org.apache.log4j.Logger;
16 import org.eclipse.core.commands.ExecutionException;
17 import org.eclipse.core.commands.operations.IUndoContext;
18 import org.eclipse.core.runtime.IAdaptable;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.core.runtime.IStatus;
21
22 import eu.etaxonomy.cdm.model.taxon.Taxon;
23 import eu.etaxonomy.taxeditor.editor.images.ImagesController;
24 import eu.etaxonomy.taxeditor.operations.AbstractEditorOperation;
25
26 /**
27 * @author p.ciardelli
28 * @created 31.03.2009
29 * @version 1.0
30 */
31 public class RemoveImageOperation extends AbstractEditorOperation {
32 private static final Logger logger = Logger
33 .getLogger(RemoveImageOperation.class);
34
35 private URL url;
36
37 /**
38 * @param text
39 * @param undoContext
40 * @param taxon
41 * @param url
42 */
43 public RemoveImageOperation(String label, IUndoContext undoContext,
44 Taxon taxon, URL url) {
45 super(label, undoContext, taxon);
46
47 this.url = url;
48 }
49
50 /* (non-Javadoc)
51 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
52 */
53 @Override
54 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
55 throws ExecutionException {
56
57 ImagesController.removeTaxonImageUrl(taxon, url);
58
59 return redrawOpenEditor();
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 ImagesController.addTaxonImageUrl(taxon, url);
79
80 return redrawOpenEditor();
81 }
82
83
84 }