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
.common
.IdentifiableSource
;
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
;
28 public abstract class AbstractDescriptionPostOperation
<T
extends IDescribable
, D
extends DescriptionBase
>
29 extends AbstractPostOperation
<T
> {
31 protected D description
;
32 protected IdentifiableSource source
;
34 private final boolean isImageGallery
;
36 public AbstractDescriptionPostOperation(String label
, IUndoContext undoContext
,
37 T describable
, IdentifiableSource source
, IPostOperationEnabled postOperationEnabled
) {
38 this(label
, undoContext
, describable
, source
, postOperationEnabled
, false);
41 public AbstractDescriptionPostOperation(String label
, IUndoContext undoContext
,
42 T describable
, IdentifiableSource source
, IPostOperationEnabled postOperationEnabled
, boolean isImageGallery
) {
43 super(label
, undoContext
, describable
, postOperationEnabled
);
44 this.isImageGallery
= isImageGallery
;
49 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
50 throws ExecutionException
{
54 description
.addSource(source
);
59 description
.setImageGallery(isImageGallery
);
60 // add the description element to hold the media elements for this image gallery
61 TextData element
= TextData
.NewInstance(Feature
.IMAGE());
62 element
.addMedia(Media
.NewInstance());
63 description
.addElement(element
);
67 return postExecute(description
);
71 * Creates the description and attaches it to the operated element.
73 protected abstract void initDescription();
76 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
78 element
.addDescription(description
);
80 return postExecute(description
);
84 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
86 element
.removeDescription(description
);
88 return postExecute(null);