3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
;
13 import org
.eclipse
.ui
.forms
.widgets
.Section
;
15 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
16 import eu
.etaxonomy
.cdm
.api
.facade
.MethodNotSupportedByDerivedUnitTypeException
;
17 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
18 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
19 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
;
20 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
.EntityDetailType
;
21 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
.SelectionType
;
22 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
.TermComboType
;
23 import eu
.etaxonomy
.taxeditor
.ui
.forms
.ICdmFormElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.forms
.TextWithLabelElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.selection
.NameSelectionElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.term
.PreservationMethodComboElement
;
31 * DerivedUnitBaseDetailElement class.
35 * @created Jun 24, 2010
38 public class DerivedUnitBaseDetailElement
extends
39 AbstractCdmDetailElement
<DerivedUnitFacade
> {
41 private TextWithLabelElement text_derivedUnitDefinitions
;
43 private TextWithLabelElement text_accessionNumber
;
45 private TextWithLabelElement text_catalogNumber
;
47 private NameSelectionElement selection_storedUnder
;
49 private TextWithLabelElement text_exsicatum
;
51 private PreservationMethodComboElement combo_preservationMethod
;
53 private DeterminationEventDetailSection section_determinations
;
55 private SpecimenCollectionDetailSection section_duplicates
;
57 private SourceCollectionDetailSection section_source
;
59 private TextWithLabelElement text_collectorsNumber
;
63 * Constructor for DerivedUnitBaseDetailElement.
67 * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
70 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
73 public DerivedUnitBaseDetailElement(CdmFormFactory formFactory
,
74 ICdmFormElement formElement
) {
75 super(formFactory
, formElement
);
80 protected void createControls(ICdmFormElement formElement
,
81 DerivedUnitFacade entity
, int style
) {
83 // text_derivedUnitDefinitions =
84 // formFactory.createTextWithLabelElement(formElement,
85 // "Specimen Definition",
86 // facade.getDerivedUnitDefinition(CdmStore.getDefaultLanguage()),
88 text_accessionNumber
= formFactory
.createTextWithLabelElement(
89 formElement
, "Accession Number", entity
.getAccessionNumber(),
91 text_catalogNumber
= formFactory
92 .createTextWithLabelElement(formElement
, "Catalog Number",
93 entity
.getCatalogNumber(), style
);
96 combo_preservationMethod
= (PreservationMethodComboElement
) formFactory
97 .createTermComboElement(TermComboType
.PRESERVATION_METHOD
,
98 formElement
, "Preservation Method",
99 entity
.getPreservationMethod(), style
);
100 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
102 StoreUtil
.info(e
.getMessage());
104 selection_storedUnder
= (NameSelectionElement
) formFactory
105 .createSelectionElement(SelectionType
.NAME
,
106 getConversationHolder(), formElement
, "Stored Under",
107 entity
.getStoredUnder(), NameSelectionElement
.DEFAULT
,
111 text_exsicatum
= formFactory
.createTextWithLabelElement(
112 formElement
, "Exsiccatum", entity
.getExsiccatum(), style
);
113 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
115 StoreUtil
.info(e
.getMessage());
119 section_determinations
= (DeterminationEventDetailSection
) formFactory
120 .createEntityDetailSection(
121 EntityDetailType
.DETERMINATION_EVENT
,
122 getConversationHolder(), formElement
, Section
.TWISTIE
);
123 section_determinations
.setLayoutData(CdmFormFactory
.FILL_HORIZONTALLY(
125 section_determinations
.setEntity(entity
);
127 section_duplicates
= (SpecimenCollectionDetailSection
) formFactory
128 .createEntityDetailSection(
129 EntityDetailType
.SPECIMEN_COLLECTION
,
130 getConversationHolder(), formElement
, Section
.TWISTIE
);
132 .setLayoutData(CdmFormFactory
.FILL_HORIZONTALLY(2, 1));
133 section_duplicates
.setEntity(entity
);
135 section_source
= (SourceCollectionDetailSection
) formFactory
136 .createEntityDetailSection(
137 EntityDetailType
.IDENTIFIABLE_SOURCE_COLLECTION
,
138 getConversationHolder(), formElement
, Section
.TWISTIE
);
139 section_source
.setLayoutData(CdmFormFactory
.FILL_HORIZONTALLY(2, 1));
140 section_source
.setEntity(entity
);
145 public void handleEvent(Object eventSource
) {
146 if (eventSource
== text_derivedUnitDefinitions
) {
147 getEntity().addDerivedUnitDefinition(
148 text_derivedUnitDefinitions
.getText(),
149 CdmStore
.getDefaultLanguage());
150 } else if (eventSource
== text_accessionNumber
) {
151 getEntity().setAccessionNumber(text_accessionNumber
.getText());
152 } else if (eventSource
== text_catalogNumber
) {
153 getEntity().setCatalogNumber(text_catalogNumber
.getText());
154 } else if (eventSource
== combo_preservationMethod
) {
156 getEntity().setPreservationMethod(
157 combo_preservationMethod
.getSelection());
158 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
161 "MethodNotSupportedByDerivedUnitTypeException",
163 "MethodNotSupportedByDerivedUnitTypeException when trying to set preservation method for derive unit",
166 } else if (eventSource
== selection_storedUnder
) {
167 getEntity().setStoredUnder(selection_storedUnder
.getEntity());
168 } else if (eventSource
== text_exsicatum
) {
170 getEntity().setExsiccatum(text_exsicatum
.getText());
171 } catch (Exception e
) {
172 StoreUtil
.error(this.getClass(), e
);