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
.editor
.view
.media
.operation
;
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
.util
.ImagesUtility
;
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
.operation
.AbstractPostTaxonOperation
;
23 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
26 * <p>CreateImageOperation class.</p>
31 public class CreateImageOperation
extends AbstractPostTaxonOperation
{
33 private ImageFile imageFile
;
35 private final DescriptionBase
<?
> description
;
38 * <p>Constructor for CreateImageOperation.</p>
40 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
41 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
42 * @param label a {@link java.lang.String} object.
43 * @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
44 * @param imageFile a {@link eu.etaxonomy.cdm.model.media.ImageFile} object.
45 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
47 public CreateImageOperation(String label
, IUndoContext undoContext
,
48 Taxon taxon
, DescriptionBase
<?
> description
, ImageFile imageFile
, IPostOperationEnabled postOperationEnabled
) {
49 super(label
, undoContext
, taxon
, postOperationEnabled
);
50 this.imageFile
= imageFile
;
51 this.description
= description
;
55 * <p>Constructor for CreateImageOperation.</p>
57 * @param label a {@link java.lang.String} object.
58 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
59 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
60 * @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
61 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
63 public CreateImageOperation(String label
, IUndoContext undoContext
,
64 Taxon taxon
, DescriptionBase
<?
> description
, IPostOperationEnabled postOperationEnabled
) {
65 super(label
, undoContext
, taxon
, postOperationEnabled
);
66 this.description
= description
;
71 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
72 throws ExecutionException
{
74 if (imageFile
== null) {
75 imageFile
= ImageFile
.NewInstance(null, null);
79 ImagesUtility
.addTaxonImage(element
, description
, imageFile
);
82 return postExecute(imageFile
);
87 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
88 throws ExecutionException
{
90 ImagesUtility
.addTaxonImage(element
, description
, imageFile
);
92 return postExecute(imageFile
);
97 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
98 throws ExecutionException
{
100 ImagesUtility
.removeTaxonImage(element
, description
, imageFile
);
102 return postExecute(null);