3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.operations
;
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
;
19 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
20 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.model
.ImagesHelper
;
23 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
30 public class DeleteImageOperation
extends AbstractPostOperation
{
32 private ImageFile imageFile
;
34 private DescriptionBase
<?
> description
;
42 public DeleteImageOperation(String label
, IUndoContext undoContext
,
43 Taxon taxon
, DescriptionBase
<?
> description
, ImageFile imageFile
, IPostOperationEnabled postOperationEnabled
) {
44 super(label
, undoContext
, taxon
, postOperationEnabled
);
46 this.imageFile
= imageFile
;
47 this.description
= description
;
51 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
54 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
55 throws ExecutionException
{
57 // Start the main progress monitor.
58 IProgressMonitor newMonitor
= StoreUtil
.startMainMonitor(monitor
,"Deleting Image", 2);
66 ImagesHelper
.removeTaxonImage(taxon
, description
, imageFile
);
67 StoreUtil
.isCanceled(newMonitor
, 1);
71 // Stop the progress monitor.
75 return postExecute(null);
79 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
82 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
83 throws ExecutionException
{
84 return execute(monitor
, info
);
88 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
91 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
92 throws ExecutionException
{
94 ImagesHelper
.addTaxonImage(taxon
, description
, imageFile
);
96 return postExecute(null);