// $Id$
/**
-* 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.
-*/
+ * 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.ui.section.occurrence;
-import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.api.facade.MethodNotSupportedByDerivedUnitTypeException;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.occurrence.PreservationMethod;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType;
+import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
+import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
-import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement;
-import eu.etaxonomy.taxeditor.ui.term.PreservationMethodComboElement;
+import eu.etaxonomy.taxeditor.ui.section.campanula.compatibility.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
/**
- * <p>DerivedUnitBaseDetailElement class.</p>
+ * <p>
+ * DerivedUnitBaseDetailElement class.
+ * </p>
*
* @author n.hoffmann
* @created Jun 24, 2010
* @version 1.0
*/
-public class DerivedUnitBaseDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade>{
-
+public class DerivedUnitBaseDetailElement extends
+ AbstractCdmDetailElement<DerivedUnitFacade> {
+
private TextWithLabelElement text_derivedUnitDefinitions;
- private TextWithLabelElement text_accessionNumber;
+ private TextWithLabelElement text_barcode;
private TextWithLabelElement text_catalogNumber;
- private NameSelectionElement selection_storedUnder;
+ private EntitySelectionElement<TaxonNameBase> selection_storedUnder;
private TextWithLabelElement text_exsicatum;
- private PreservationMethodComboElement combo_preservationMethod;
-
- private DeterminationEventDetailSection section_determinations;
-
+ private TermComboElement<PreservationMethod> combo_preservationMethod;
+
private SpecimenCollectionDetailSection section_duplicates;
-
- private SourceCollectionDetailSection section_source;
- private TextWithLabelElement text_collectorsNumber;
+ private SourceCollectionDetailSection section_source;
-
/**
- * <p>Constructor for DerivedUnitBaseDetailElement.</p>
+ * <p>
+ * Constructor for DerivedUnitBaseDetailElement.
+ * </p>
*
- * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+ * object.
+ * @param formElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
*/
public DerivedUnitBaseDetailElement(CdmFormFactory formFactory,
ICdmFormElement formElement) {
super(formFactory, formElement);
}
-
+
/** {@inheritDoc} */
@Override
- protected void createControls(ICdmFormElement formElement,
- DerivedUnitFacade entity, int style) {
- // Disable for now
-// text_derivedUnitDefinitions = formFactory.createTextWithLabelElement(formElement, "Specimen Definition", facade.getDerivedUnitDefinition(CdmStore.getDefaultLanguage()), style);
- text_accessionNumber = formFactory.createTextWithLabelElement(formElement, "Accession Number", entity.getAccessionNumber(), style);
- text_catalogNumber = formFactory.createTextWithLabelElement(formElement, "Catalog Number", entity.getCatalogNumber(), style);
- text_collectorsNumber = formFactory.createTextWithLabelElement(formElement, "Collectors Number", entity.getCollectorsNumber(), style);
-
- try {
- combo_preservationMethod = (PreservationMethodComboElement) formFactory.createTermComboElement(TermComboType.PRESERVATION_METHOD, formElement, "Preservation Method", entity.getPreservationMethod(), style);
- } catch (MethodNotSupportedByDerivedUnitTypeException e) {
- // we ignore this
- StoreUtil.info(e.getMessage());
- }
- selection_storedUnder = (NameSelectionElement) formFactory.createSelectionElement(SelectionType.NAME, getConversationHolder(), formElement, "Stored Under", entity.getStoredUnder(), style);
-
- try {
- text_exsicatum = formFactory.createTextWithLabelElement(formElement, "Exsiccatum", entity.getExsiccatum(), style);
- } catch (MethodNotSupportedByDerivedUnitTypeException e) {
- // we ignore this
- StoreUtil.info(e.getMessage());
- }
- // source
-
- section_determinations = (DeterminationEventDetailSection) formFactory.createEntityDetailSection(EntityDetailType.DETERMINATION_EVENT, getConversationHolder(), formElement, Section.TWISTIE);
- section_determinations.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
- section_determinations.setEntity(entity);
-
- section_duplicates = (SpecimenCollectionDetailSection) formFactory.createEntityDetailSection(EntityDetailType.SPECIMEN_COLLECTION, getConversationHolder(), formElement, Section.TWISTIE);
- section_duplicates.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
- section_duplicates.setEntity(entity);
-
- section_source = (SourceCollectionDetailSection) formFactory.createEntityDetailSection(EntityDetailType.IDENTIFIABLE_SOURCE_COLLECTION, getConversationHolder(), formElement, Section.TWISTIE);
- section_source.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
- section_source.setEntity(entity);
- }
+ protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
+ // Disable for now
+ // text_derivedUnitDefinitions =
+ // formFactory.createTextWithLabelElement(formElement,
+ // "Specimen Definition",
+ // facade.getDerivedUnitDefinition(CdmStore.getDefaultLanguage()),
+ // style);
+ text_barcode = formFactory.createTextWithLabelElement(formElement, "Barcode", entity.getBarcode(), style);
+ text_catalogNumber = formFactory.createTextWithLabelElement(formElement, "Catalog Number", entity.getCatalogNumber(), style);
+
+ try {
+ combo_preservationMethod = formFactory.createTermComboElement(PreservationMethod.class, formElement, "Preservation Method", entity.getPreservationMethod(), style);
+ } catch (MethodNotSupportedByDerivedUnitTypeException e) {
+ // we ignore this
+ AbstractUtility.info(e.getMessage());
+ }
+ selection_storedUnder = formFactory.createSelectionElement(TaxonNameBase.class, getConversationHolder(), formElement, "Stored Under", entity.getStoredUnder(), EntitySelectionElement.ALL, style);
+
+ try {
+ text_exsicatum = formFactory.createTextWithLabelElement(formElement, "Exsiccatum", entity.getExsiccatum(), style);
+ } catch (MethodNotSupportedByDerivedUnitTypeException e) {
+ // we ignore this
+ AbstractUtility.info(e.getMessage());
+ }
+
+ section_duplicates = formFactory.createSpecimenCollectionDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
+ section_duplicates.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ section_duplicates.setEntity(entity);
+
+ section_source = formFactory.createSourceCollectionDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
+ section_source.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ section_source.setEntity(entity);
+ }
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
- if(eventSource == text_derivedUnitDefinitions){
- getEntity().addDerivedUnitDefinition(text_derivedUnitDefinitions.getText(), CdmStore.getDefaultLanguage());
- }
- else if(eventSource == text_accessionNumber){
- getEntity().setAccessionNumber(text_accessionNumber.getText());
- }
- else if(eventSource == text_catalogNumber){
+ if (eventSource == text_derivedUnitDefinitions) {
+ getEntity().addDerivedUnitDefinition(
+ text_derivedUnitDefinitions.getText(),
+ CdmStore.getDefaultLanguage());
+ } else if (eventSource == text_barcode) {
+ getEntity().setBarcode(text_barcode.getText());
+ } else if (eventSource == text_catalogNumber) {
getEntity().setCatalogNumber(text_catalogNumber.getText());
- }
- else if(eventSource == text_collectorsNumber){
- getEntity().setCollectorsNumber(text_collectorsNumber.getText());
- }
- else if(eventSource == combo_preservationMethod){
+ } else if (eventSource == combo_preservationMethod) {
try {
- getEntity().setPreservationMethod(combo_preservationMethod.getSelection());
+ getEntity().setPreservationMethod(
+ combo_preservationMethod.getSelection());
} catch (MethodNotSupportedByDerivedUnitTypeException e) {
- StoreUtil.errorDialog("MethodNotSupportedByDerivedUnitTypeException", this, "MethodNotSupportedByDerivedUnitTypeException when trying to set preservation method for derive unit", e);
+ AbstractUtility
+ .errorDialog(
+ "MethodNotSupportedByDerivedUnitTypeException",
+ this,
+ "MethodNotSupportedByDerivedUnitTypeException when trying to set preservation method for derive unit",
+ e);
}
- }
- else if(eventSource == selection_storedUnder){
+ } else if (eventSource == selection_storedUnder) {
getEntity().setStoredUnder(selection_storedUnder.getEntity());
- }
- else if(eventSource == text_exsicatum){
+ } else if (eventSource == text_exsicatum) {
try {
getEntity().setExsiccatum(text_exsicatum.getText());
} catch (Exception e) {
- StoreUtil.error(this.getClass(), e);
+ AbstractUtility.error(this.getClass(), e);
}
}
}