3 * Copyright (C) 2013 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.
10 package eu
.etaxonomy
.taxeditor
.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
.model
.description
.DescriptionBase
;
19 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
20 import eu
.etaxonomy
.cdm
.model
.description
.IDescribable
;
21 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
22 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
29 public abstract class AbstractDescriptionPostOperation
<T
extends IDescribable
<D
>, D
extends DescriptionBase
<?
>> extends AbstractPostOperation
<T
> {
31 protected D description
;
33 private final boolean isImageGallery
;
38 public AbstractDescriptionPostOperation(String label
, IUndoContext undoContext
,
39 T describable
, IPostOperationEnabled postOperationEnabled
) {
40 this(label
, undoContext
, describable
, postOperationEnabled
, false);
46 public AbstractDescriptionPostOperation(String label
, IUndoContext undoContext
,
47 T describable
, IPostOperationEnabled postOperationEnabled
, boolean isImageGallery
) {
48 super(label
, undoContext
, describable
, postOperationEnabled
);
49 this.isImageGallery
= isImageGallery
;
53 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
57 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
58 throws ExecutionException
{
64 description
.setImageGallery(isImageGallery
);
65 // add the description element to hold the media elements for this image gallery
66 TextData element
= TextData
.NewInstance(Feature
.IMAGE());
67 element
.addMedia(Media
.NewInstance());
68 description
.addElement(element
);
72 return postExecute(description
);
76 * Creates the description and attaches it to the operated element.
78 protected abstract void initDescription();
82 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
84 element
.addDescription(description
);
86 return postExecute(description
);
91 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
93 element
.removeDescription(description
);
95 return postExecute(null);