2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.operations
;
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
;
18 import eu
.etaxonomy
.cdm
.api
.utility
.ImagesUtility
;
19 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
20 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
30 public class RemoveImageFromDescriptionElementOperation
extends AbstractPostOperation
{
32 private DescriptionElementBase element
;
33 private ImageFile image
;
40 * @param postOperationEnabled
42 public RemoveImageFromDescriptionElementOperation(String label
,
43 IUndoContext undoContext
, Taxon taxon
, ImageFile image
,
44 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
) {
45 super(label
, undoContext
, taxon
, postOperationEnabled
);
48 this.element
= element
;
52 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
55 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
56 throws ExecutionException
{
58 // Start the main progress monitor.
59 IProgressMonitor newMonitor
= StoreUtil
.startMainMonitor(monitor
,"Removing Image from Description Element", 2);
67 ImagesUtility
.removeImage(element
, image
);
68 StoreUtil
.isCanceled(newMonitor
, 1);
72 // Stop the progress monitor.
76 return postExecute(element
);
80 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
83 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
84 throws ExecutionException
{
85 return execute(monitor
, info
);
89 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
92 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
93 throws ExecutionException
{
94 image
= ImagesUtility
.addImagePart(element
);
95 return postExecute(image
);