package eu.etaxonomy.taxeditor.editor.handler.create;
-import java.util.Collections;
-
import org.apache.log4j.Logger;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.PartInitException;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
-import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeFieldUnitCacheStrategy;
-import eu.etaxonomy.cdm.api.service.IOccurrenceService;
-import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
-import eu.etaxonomy.cdm.model.occurrence.DerivationEventType;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
-import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
-import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
/**
* @author n.hoffmann
/** {@inheritDoc} */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- ConversationHolder conversation = CdmStore.createConversation();
- conversation.bind();
- FieldUnit fieldUnit = FieldUnit.NewInstance();
- DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
- DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.GATHERING_IN_SITU());
- fieldUnit.setCacheStrategy(new DerivedUnitFacadeFieldUnitCacheStrategy());
- derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
- CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
- CdmStore.getService(IOccurrenceService.class).save(derivedUnit);
- conversation.commit();
- DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singleton(fieldUnit.getUuid()));
- try {
- EditorUtil.open(input);
- } catch (PartInitException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-// NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
-// wizard.init(null, null);
-// WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
-// dialog.open();
+ //TODO: we need to discuss how specimens should be created and handled #5244
+// ConversationHolder conversation = CdmStore.createConversation();
+// conversation.bind();
+// FieldUnit fieldUnit = FieldUnit.NewInstance();
+// DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
+// DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.GATHERING_IN_SITU());
+// fieldUnit.setCacheStrategy(new DerivedUnitFacadeFieldUnitCacheStrategy());
+// derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
+// CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
+// CdmStore.getService(IOccurrenceService.class).save(derivedUnit);
+// conversation.commit();
+// DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singleton(fieldUnit.getUuid()));
+// try {
+// EditorUtil.open(input);
+// } catch (PartInitException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+ NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
+ wizard.init(null, null);
+ WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
+ dialog.open();
return null;
}
}
AbstractCdmDetailElement<DerivedUnitFacade> {
boolean showOnlyDerivedUnitData = false;
+ //TODO: flag to disable specimen type dropdown (#5244)
+ boolean showSpecimenType = true;
private ToggleableTextElement toggleableText_titleCache;
private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
super(formFactory, formElement);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
- * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
- */
@Override
protected void createControls(ICdmFormElement formElement,
DerivedUnitFacade entity, int style) {
else{
combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
combo_specorobstype.setSelection(entity.getType());
+ combo_specorobstype.setEnabled(showSpecimenType);
selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
formElement, "Country",
entity.getCountry(), EntitySelectionElement.NOTHING, style);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
- * .lang.Object)
- */
@Override
public void handleEvent(Object eventSource) {
if (eventSource == toggleableText_titleCache) {
this.showOnlyDerivedUnitData = showOnlyDerivedUnitData;
}
+ public void setShowSpecimenType(boolean showSpecimenType) {
+ this.showSpecimenType = showSpecimenType;
+ }
+
}