eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionElementsHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateDescriptionElementOperation.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateSpecimenDescriptionOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateTaxonDescriptionOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteDescriptionElementOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java -text
*/
@Override
public void changed(Object element) {
- firePropertyChange(IEditorPart.PROP_DIRTY);
viewer.setInput(getEditorInput());
setDirty(true);
+ firePropertyChange(IEditorPart.PROP_DIRTY);
}
}
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.handlers.HandlerUtil;
-import eu.etaxonomy.cdm.model.description.SpecimenDescription;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateSpecimenDescriptionOperation;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
editor = ((FormEditor) editor).getActiveEditor();
}
IEditorInput input = editor.getEditorInput();
+ AbstractPostOperation<?> operation;
+
// taxon description
if (input instanceof TaxonEditorInput) {
Taxon taxon = ((TaxonEditorInput) input).getTaxon();
- AbstractPostOperation operation;
try {
-
- operation = createOperationInstance(event.getCommand().getName(), taxon, postOperationEnabled);
+ operation = createTaxonOperation(event.getCommand().getName(), taxon, postOperationEnabled);
AbstractUtility.executeOperation(operation);
} catch (NotDefinedException e) {
AbstractUtility.warn(getClass(), "Command name not set.");
}
}
// specimen description
- else{
- //FIXME: no undo and redo supported. Should also use postOperation
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if(selection instanceof IStructuredSelection){
- Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
- if(selectedElement instanceof SpecimenOrObservationBase<?>){
- SpecimenDescription description = SpecimenDescription.NewInstance((SpecimenOrObservationBase<?>) selectedElement);
- postOperationEnabled.postOperation(description);
+ else if(part instanceof DescriptiveViewPart){
+ Object viewerInput = ((DescriptiveViewPart)part).getViewer().getInput();
+ if(viewerInput instanceof SpecimenOrObservationBase<?>){
+ try {
+ operation = new CreateSpecimenDescriptionOperation(event.getCommand().getName(), EditorUtil.getUndoContext(), (SpecimenOrObservationBase<?>) viewerInput, postOperationEnabled);
+ AbstractUtility.executeOperation(operation);
+ } catch (NotDefinedException e) {
+ AbstractUtility.warn(getClass(), "Command name not set.");
}
}
}
return null;
}
- /**
- * The function is used to make the specific object creation more generic
- * @param eventLabel
- * @param taxon
- * @param postOperationEnabled
- * @return
- */
- protected AbstractPostOperation createOperationInstance(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {
- // TODO use undo context specific to editor
- return new CreateTaxonDescriptionOperation(eventLabel, EditorUtil.getUndoContext(), taxon, postOperationEnabled);
- }
-
+ /** {@inheritDoc} */
+ protected CreateTaxonDescriptionOperation createTaxonOperation(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {
+ return new CreateTaxonDescriptionOperation(eventLabel, EditorUtil.getUndoContext(), taxon, postOperationEnabled);
+ }
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2013 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.operations.IUndoContext;
+
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.taxeditor.operation.AbstractDescriptionPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+
+/**
+ * @author pplitzner
+ * @date 04.12.2013
+ *
+ */
+public class CreateSpecimenDescriptionOperation extends AbstractDescriptionPostOperation<SpecimenOrObservationBase<?>, DescriptionBase> {
+
+ /**
+ * @param label
+ * @param undoContext
+ * @param describable
+ * @param postOperationEnabled
+ */
+ public CreateSpecimenDescriptionOperation(String label, IUndoContext undoContext, SpecimenOrObservationBase<?> describable, IPostOperationEnabled postOperationEnabled) {
+ super(label, undoContext, describable, postOperationEnabled);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operation.AbstractDescriptionPostOperation#initDescription()
+ */
+ @Override
+ protected void initDescription() {
+ description = SpecimenDescription.NewInstance(element);
+ }
+
+}
+// $Id$
/**
-* Copyright (C) 2007 EDIT
+* Copyright (C) 2013 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.AbstractDescriptionPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
/**
- * <p>CreateTaxonDescriptionOperation class.</p>
+ * @author pplitzner
+ * @date 04.12.2013
*
- * @author p.ciardelli
- * @author n.hoffmann
- * @created 05.02.2009
- * @version 1.0
*/
-public class CreateTaxonDescriptionOperation extends AbstractDescriptionPostOperation<Taxon, TaxonDescription>{
-
- private final 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(element);
- 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 {
-
- element.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 {
-
- element.removeDescription(description);
-
- return postExecute(null);
- }
+public class CreateTaxonDescriptionOperation extends AbstractDescriptionPostOperation<Taxon, TaxonDescription> {
+
+ /**
+ * @param label
+ * @param undoContext
+ * @param describable
+ * @param postOperationEnabled
+ * @param isImageGallery
+ */
+ public CreateTaxonDescriptionOperation(String label, IUndoContext undoContext, Taxon describable, IPostOperationEnabled postOperationEnabled) {
+ super(label, undoContext, describable, postOperationEnabled, false);
+ }
+
+ /**
+ * @param label
+ * @param undoContext
+ * @param describable
+ * @param postOperationEnabled
+ * @param isImageGallery
+ */
+ public CreateTaxonDescriptionOperation(String label, IUndoContext undoContext, Taxon describable, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) {
+ super(label, undoContext, describable, postOperationEnabled, isImageGallery);
+ }
+
+ @Override
+ protected void initDescription(){
+ description = TaxonDescription.NewInstance(element);
+ }
}
/**\r
* Copyright (C) 2011 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
import eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionHandler;\r
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;\r
import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateTaxonUseOperation;\r
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
\r
/**\r
* CreateUseHandler Class\r
- * @author a.theys \r
+ * @author a.theys\r
* @created mar 13, 2012\r
* @version 1.0\r
*/\r
public class CreateUseHandler extends CreateDescriptionHandler {\r
\r
- \r
+\r
/** {@inheritDoc} */\r
@Override\r
- protected AbstractPostOperation createOperationInstance(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {\r
+ protected CreateTaxonDescriptionOperation createTaxonOperation(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {\r
return new CreateTaxonUseOperation(eventLabel, EditorUtil.getUndoContext(), taxon, postOperationEnabled);\r
}\r
}\r
*/
package eu.etaxonomy.taxeditor.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.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.IDescribable;
-import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
+import eu.etaxonomy.cdm.model.description.TextData;
+import eu.etaxonomy.cdm.model.media.Media;
/**
* @author pplitzner
* @date 04.12.2013
*
*/
-public abstract class AbstractDescriptionPostOperation<T extends IDescribable<D>, D extends DescriptionBase<IIdentifiableEntityCacheStrategy<D>>> extends AbstractPostOperation<T> {
+public abstract class AbstractDescriptionPostOperation<T extends IDescribable<D>, D extends DescriptionBase<?>> extends AbstractPostOperation<T> {
protected D description;
+ private final boolean isImageGallery;
+
/**
*
*/
public AbstractDescriptionPostOperation(String label, IUndoContext undoContext,
T describable, IPostOperationEnabled postOperationEnabled) {
+ this(label, undoContext, describable, postOperationEnabled, false);
+ }
+
+ /**
+ *
+ */
+ public AbstractDescriptionPostOperation(String label, IUndoContext undoContext,
+ T describable, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) {
super(label, undoContext, describable, 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 {
+
+ initDescription();
+ 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);
+ }
+
+ /**
+ * Creates the description and attaches it to the operated element.
+ */
+ protected abstract void initDescription();
+
+ /** {@inheritDoc} */
+ @Override
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+
+ element.addDescription(description);
+
+ return postExecute(description);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+
+ element.removeDescription(description);
+
+ return postExecute(null);
}
}
return selectionService.getSelection();
}
- private void createViewerComposite(Composite parent) {
- viewerComposite = new SashForm(parent, SWT.HORIZONTAL);
- }
-
/**
* <p>showEmptyPage</p>
*/