1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.editor.view.media.operation;
|
11
|
|
12
|
import org.eclipse.core.commands.ExecutionException;
|
13
|
import org.eclipse.core.commands.operations.IUndoContext;
|
14
|
import org.eclipse.core.runtime.IAdaptable;
|
15
|
import org.eclipse.core.runtime.IProgressMonitor;
|
16
|
import org.eclipse.core.runtime.IStatus;
|
17
|
|
18
|
import eu.etaxonomy.cdm.api.service.IMediaService;
|
19
|
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
|
20
|
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
|
21
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
22
|
import eu.etaxonomy.cdm.model.media.Media;
|
23
|
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
|
24
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
|
27
|
/**
|
28
|
* <p>DeleteMediaOperation class.</p>
|
29
|
*
|
30
|
* @author p.ciardelli
|
31
|
* @created 31.03.2009
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class DeleteMediaOperation extends AbstractPostTaxonOperation {
|
35
|
|
36
|
private final Media media;
|
37
|
|
38
|
private final DescriptionBase<?> description;
|
39
|
|
40
|
private final MediaDeletionConfigurator config;
|
41
|
|
42
|
/**
|
43
|
* <p>Constructor for DeleteMediaOperation.</p>
|
44
|
*
|
45
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
46
|
* @param label a {@link java.lang.String} object.
|
47
|
* @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
|
48
|
* @param media a {@link eu.etaxonomy.cdm.model.media.Media} object.
|
49
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
50
|
*/
|
51
|
public DeleteMediaOperation(String label, IUndoContext undoContext,
|
52
|
DescriptionBase<?> description, Media media, MediaDeletionConfigurator config, IPostOperationEnabled postOperationEnabled) {
|
53
|
super(label, undoContext, postOperationEnabled);
|
54
|
this.config = config;
|
55
|
this.media = media;
|
56
|
this.description = description;
|
57
|
}
|
58
|
|
59
|
/* (non-Javadoc)
|
60
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
61
|
*/
|
62
|
/** {@inheritDoc} */
|
63
|
@Override
|
64
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
65
|
throws ExecutionException {
|
66
|
|
67
|
// ImagesUtility.removeMediaFromGallery(description, media);
|
68
|
|
69
|
monitor.worked(20);
|
70
|
CdmStore.getService(IMediaService.class).delete(media.getUuid(), config);
|
71
|
monitor.worked(40);
|
72
|
|
73
|
return postExecute(null);
|
74
|
}
|
75
|
|
76
|
/* (non-Javadoc)
|
77
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
78
|
*/
|
79
|
/** {@inheritDoc} */
|
80
|
@Override
|
81
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
82
|
throws ExecutionException {
|
83
|
return execute(monitor, info);
|
84
|
}
|
85
|
|
86
|
/* (non-Javadoc)
|
87
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
88
|
*/
|
89
|
/** {@inheritDoc} */
|
90
|
@Override
|
91
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
92
|
throws ExecutionException {
|
93
|
|
94
|
ImagesUtility.addMediaToGallery(description, media);
|
95
|
|
96
|
return postExecute(null);
|
97
|
}
|
98
|
|
99
|
|
100
|
}
|