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
.derivedUnit
;
13 import org
.eclipse
.ui
.forms
.widgets
.ExpandableComposite
;
15 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
16 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
17 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
18 import eu
.etaxonomy
.cdm
.model
.occurrence
.PreservationMethod
;
19 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
21 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.SpecimenCollectionDetailSection
;
28 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
32 * DerivedUnitBaseDetailElement class.
36 * @created Jun 24, 2010
39 public class PreservedSpecimenDetailElement
extends
40 AbstractCdmDetailElement
<DerivedUnit
> {
42 private TextWithLabelElement text_derivedUnitDefinitions
;
44 private TextWithLabelElement text_barcode
;
46 private TextWithLabelElement text_catalogNumber
;
48 private EntitySelectionElement
<TaxonNameBase
> selection_storedUnder
;
50 private TextWithLabelElement text_exsicatum
;
52 private TermComboElement
<DefinedTerm
> combo_preservationMethod
;
54 private SpecimenCollectionDetailSection section_duplicates
;
56 private PreservedSpecimenSourceCollectionDetailSection section_source
;
60 * Constructor for DerivedUnitBaseDetailElement.
64 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
67 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
70 public PreservedSpecimenDetailElement(CdmFormFactory formFactory
,
71 ICdmFormElement formElement
) {
72 super(formFactory
, formElement
);
77 protected void createControls(ICdmFormElement formElement
, DerivedUnit entity
, int style
) {
79 // text_derivedUnitDefinitions =
80 // formFactory.createTextWithLabelElement(formElement,
81 // "Specimen Definition",
82 // facade.getDerivedUnitDefinition(CdmStore.getDefaultLanguage()),
84 text_barcode
= formFactory
.createTextWithLabelElement(formElement
, "Barcode", entity
.getBarcode(), style
);
85 text_catalogNumber
= formFactory
.createTextWithLabelElement(formElement
, "Catalog Number", entity
.getCatalogNumber(), style
);
88 PreservationMethod preservationMethod
= entity
.getPreservation();
89 combo_preservationMethod
= formFactory
.createTermComboElement(DefinedTerm
.class, formElement
, "Preservation Method", preservationMethod
==null?
null:preservationMethod
.getDefinedMaterialOrMethod(), style
);
90 selection_storedUnder
= formFactory
.createSelectionElement(TaxonNameBase
.class, getConversationHolder(), formElement
, "Stored Under", entity
.getStoredUnder(), EntitySelectionElement
.ALL
, style
);
92 text_exsicatum
= formFactory
.createTextWithLabelElement(formElement
, "Exsiccatum", entity
.getExsiccatum(), style
);
94 section_source
= formFactory
.createPreservedSpecimenSourceCollectionDetailSection(getConversationHolder(), formElement
, ExpandableComposite
.TWISTIE
);
95 section_source
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
96 section_source
.setEntity(entity
);
101 public void handleEvent(Object eventSource
) {
102 if (eventSource
== text_derivedUnitDefinitions
) {
103 getEntity().putDefinition(CdmStore
.getDefaultLanguage(), text_derivedUnitDefinitions
.getText());
104 } else if (eventSource
== text_barcode
) {
105 getEntity().setBarcode(text_barcode
.getText());
106 } else if (eventSource
== text_catalogNumber
) {
107 getEntity().setCatalogNumber(text_catalogNumber
.getText());
108 } else if (eventSource
== combo_preservationMethod
) {
109 PreservationMethod preservationMethod
= getEntity().getPreservation();
110 if(preservationMethod
!=null){
111 preservationMethod
.setDefinedMaterialOrMethod(combo_preservationMethod
.getSelection());
113 } else if (eventSource
== selection_storedUnder
) {
114 getEntity().setStoredUnder(selection_storedUnder
.getEntity());
115 } else if (eventSource
== text_exsicatum
) {
117 getEntity().setExsiccatum(text_exsicatum
.getText());
118 } catch (Exception e
) {
119 AbstractUtility
.error(this.getClass(), e
);