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
.editor
.view
.media
.operation
;
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
.api
.utility
.ImagesUtility
;
20 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
21 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
24 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
27 * <p>CreateImageOperation class.</p>
33 public class CreateImageOperation
extends AbstractPostTaxonOperation
{
35 private ImageFile imageFile
;
37 private final DescriptionBase
<?
> description
;
40 * <p>Constructor for CreateImageOperation.</p>
42 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
43 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
44 * @param label a {@link java.lang.String} object.
45 * @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
46 * @param imageFile a {@link eu.etaxonomy.cdm.model.media.ImageFile} object.
47 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
49 public CreateImageOperation(String label
, IUndoContext undoContext
,
50 Taxon taxon
, DescriptionBase
<?
> description
, ImageFile imageFile
, IPostOperationEnabled postOperationEnabled
) {
51 super(label
, undoContext
, taxon
, postOperationEnabled
);
52 this.imageFile
= imageFile
;
53 this.description
= description
;
57 * <p>Constructor for CreateImageOperation.</p>
59 * @param label a {@link java.lang.String} object.
60 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
61 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
62 * @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
63 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
65 public CreateImageOperation(String label
, IUndoContext undoContext
,
66 Taxon taxon
, DescriptionBase
<?
> description
, IPostOperationEnabled postOperationEnabled
) {
67 super(label
, undoContext
, taxon
, postOperationEnabled
);
68 this.description
= description
;
72 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
76 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
77 throws ExecutionException
{
79 if (imageFile
== null) {
80 imageFile
= ImageFile
.NewInstance(null, null);
84 ImagesUtility
.addTaxonImage(element
, description
, imageFile
);
87 return postExecute(imageFile
);
91 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
95 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
96 throws ExecutionException
{
98 ImagesUtility
.addTaxonImage(element
, description
, imageFile
);
100 return postExecute(imageFile
);
104 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
108 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
109 throws ExecutionException
{
111 ImagesUtility
.removeTaxonImage(element
, description
, imageFile
);
113 return postExecute(null);