+++ /dev/null
-/**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-
-package eu.etaxonomy.taxeditor.editor.view.descriptive.operation;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.IUndoContext;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.description.TextData;
-import eu.etaxonomy.cdm.model.media.Media;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-
-/**
- * <p>CreateTaxonDescriptionOperation class.</p>
- *
- * @author p.ciardelli
- * @author n.hoffmann
- * @created 05.02.2009
- * @version 1.0
- */
-public class CreateTaxonDescriptionOperation extends AbstractPostOperation {
-
- private TaxonDescription description;
- private boolean isImageGallery;
-
- /**
- * <p>Constructor for CreateTaxonDescriptionOperation.</p>
- *
- * @param label a {@link java.lang.String} object.
- * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
- * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
- * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
- */
- public CreateTaxonDescriptionOperation(String label, IUndoContext undoContext,
- Taxon taxon, IPostOperationEnabled postOperationEnabled) {
- this(label, undoContext, taxon, postOperationEnabled, false);
- }
-
- /**
- * <p>Constructor for CreateTaxonDescriptionOperation.</p>
- *
- * @param label a {@link java.lang.String} object.
- * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
- * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
- * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
- * @param isImageGallery a boolean.
- */
- public CreateTaxonDescriptionOperation(String label, IUndoContext undoContext,
- Taxon taxon, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) {
- super(label, undoContext, taxon, postOperationEnabled);
-
- this.isImageGallery = isImageGallery;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
-
- description = TaxonDescription.NewInstance(taxon);
- monitor.worked(20);
-
- if(isImageGallery){
- description.setImageGallery(isImageGallery);
- // add the description element to hold the media elements for this image gallery
- TextData element = TextData.NewInstance(Feature.IMAGE());
- element.addMedia(Media.NewInstance());
- description.addElement(element);
- }
- monitor.worked(40);
-
- return postExecute(description);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus redo(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
-
- taxon.addDescription(description);
-
- return postExecute(description);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus undo(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
-
- taxon.removeDescription(description);
-
- return postExecute(null);
- }
-}