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