2 * Copyright (C) 2013 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.
9 package eu
.etaxonomy
.taxeditor
.operation
;
11 import org
.eclipse
.core
.commands
.ExecutionException
;
12 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
13 import org
.eclipse
.core
.runtime
.IAdaptable
;
14 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
17 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
18 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
19 import eu
.etaxonomy
.cdm
.model
.description
.IDescribable
;
20 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
21 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
28 public abstract class AbstractDescriptionPostOperation
<T
extends IDescribable
<D
>, D
extends DescriptionBase
<?
>> extends AbstractPostOperation
<T
> {
30 protected D description
;
32 private final boolean isImageGallery
;
37 public AbstractDescriptionPostOperation(String label
, IUndoContext undoContext
,
38 T describable
, IPostOperationEnabled postOperationEnabled
) {
39 this(label
, undoContext
, describable
, postOperationEnabled
, false);
45 public AbstractDescriptionPostOperation(String label
, IUndoContext undoContext
,
46 T describable
, IPostOperationEnabled postOperationEnabled
, boolean isImageGallery
) {
47 super(label
, undoContext
, describable
, postOperationEnabled
);
48 this.isImageGallery
= isImageGallery
;
52 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
56 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
57 throws ExecutionException
{
63 description
.setImageGallery(isImageGallery
);
64 // add the description element to hold the media elements for this image gallery
65 TextData element
= TextData
.NewInstance(Feature
.IMAGE());
66 element
.addMedia(Media
.NewInstance());
67 description
.addElement(element
);
71 return postExecute(description
);
75 * Creates the description and attaches it to the operated element.
77 protected abstract void initDescription();
81 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
83 element
.addDescription(description
);
85 return postExecute(description
);
90 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
92 element
.removeDescription(description
);
94 return postExecute(null);