63172152fec8b8be561b289b4fc5d6cbfa74e0da
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / media / operation / DeleteMediaOperation.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.editor.view.media.operation;
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 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
23 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
24
25 /**
26 * <p>DeleteMediaOperation class.</p>
27 *
28 * @author p.ciardelli
29 * @created 31.03.2009
30 * @version 1.0
31 */
32 @Deprecated // I don't think this is really used anymore
33 public class DeleteMediaOperation extends AbstractPostTaxonOperation {
34
35 private Media media;
36
37 private DescriptionBase<?> description;
38
39 /**
40 * <p>Constructor for DeleteMediaOperation.</p>
41 *
42 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
43 * @param label a {@link java.lang.String} object.
44 * @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
45 * @param media a {@link eu.etaxonomy.cdm.model.media.Media} object.
46 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
47 */
48 public DeleteMediaOperation(String label, IUndoContext undoContext,
49 DescriptionBase<?> description, Media media, IPostOperationEnabled postOperationEnabled) {
50 super(label, undoContext, postOperationEnabled);
51
52 this.media = media;
53 this.description = description;
54 }
55
56 /* (non-Javadoc)
57 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
58 */
59 /** {@inheritDoc} */
60 @Override
61 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
62 throws ExecutionException {
63
64 monitor.worked(20);
65 ImagesUtility.removeMediaFromGallery(description, media);
66 monitor.worked(40);
67
68 return postExecute(null);
69 }
70
71 /* (non-Javadoc)
72 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73 */
74 /** {@inheritDoc} */
75 @Override
76 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
77 throws ExecutionException {
78 return execute(monitor, info);
79 }
80
81 /* (non-Javadoc)
82 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
83 */
84 /** {@inheritDoc} */
85 @Override
86 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
87 throws ExecutionException {
88
89 ImagesUtility.addMediaToGallery(description, media);
90
91 return postExecute(null);
92 }
93
94
95 }