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
.utility
.ImagesUtility
;
19 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
20 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
21 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
22 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
24 * This operation creates a new {@link Media} and adds it to the currently selected {@link DescriptionBase}.
31 public class AddMediaToImageGalleryOperation
extends AbstractPostTaxonOperation
{
33 private final DescriptionBase
<?
> description
;
37 * <p>Constructor for AddMediaToImageGalleryOperation.</p>
39 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
40 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
41 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
42 * @param label a {@link java.lang.String} object.
43 * @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
45 public AddMediaToImageGalleryOperation(String label
,
46 IUndoContext undoContext
, DescriptionBase
<?
> description
, IPostOperationEnabled postOperationEnabled
) {
47 this(null, label
, undoContext
, description
, postOperationEnabled
);
48 media
= Media
.NewInstance();
51 protected AddMediaToImageGalleryOperation(Media media
, String label
,
52 IUndoContext undoContext
, DescriptionBase
<?
> description
, IPostOperationEnabled postOperationEnabled
) {
53 super(label
, undoContext
, postOperationEnabled
);
55 this.description
= description
;
60 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
64 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
65 throws ExecutionException
{
69 ImagesUtility
.addMediaToGallery(description
, media
);
73 return postExecute(media
);
77 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
81 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
82 throws ExecutionException
{
83 return execute(monitor
, info
);
87 * @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
{
93 ImagesUtility
.removeMediaFromGallery(description
, media
);
94 return postExecute(description
);