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
.name
;
13 import org
.eclipse
.swt
.events
.SelectionListener
;
15 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
16 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
17 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
18 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
19 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
.SelectionType
;
25 import eu
.etaxonomy
.taxeditor
.ui
.selection
.DerivedUnitBaseSelectionElement
;
29 * SpecimenTypeDesignationElement class.
33 * @created May 17, 2010
36 public class SpecimenTypeDesignationElement
extends
37 AbstractTypeDesignationElement
<SpecimenTypeDesignation
> {
39 private TermComboElement
<SpecimenTypeDesignationStatus
> combo_typeStatus
;
40 private DerivedUnitBaseSelectionElement selection_typeSpecimen
;
41 private TextWithLabelElement text_specimenTypeText
;
45 * Constructor for SpecimenTypeDesignationElement.
49 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
52 * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
55 * a {@link eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation}
57 * @param removeListener
58 * a {@link org.eclipse.swt.events.SelectionListener} object.
62 public SpecimenTypeDesignationElement(CdmFormFactory formFactory
,
63 AbstractFormSection section
, SpecimenTypeDesignation entity
,
64 SelectionListener removeListener
, int style
) {
65 super(formFactory
, section
, entity
, removeListener
, style
);
70 public void createControls(ICdmFormElement formElement
, int style
) {
71 selection_typeSpecimen
= (DerivedUnitBaseSelectionElement
) formFactory
72 .createSelectionElement(SelectionType
.DERIVED_UNIT
,
73 getConversationHolder(), formElement
, "Unit", null,
74 DerivedUnitBaseSelectionElement
.DEFAULT
, style
);
75 combo_typeStatus
= formFactory
76 .createTermComboElement(SpecimenTypeDesignationStatus
.class,
77 formElement
, "Designation Status", null, style
);
79 super.createControls(formElement
, style
);
84 public void setEntity(SpecimenTypeDesignation entity
) {
85 super.setEntity(entity
);
86 selection_typeSpecimen
.setEntity(entity
.getTypeSpecimen());
88 SpecimenTypeDesignationStatus typeStatus
= (SpecimenTypeDesignationStatus
) HibernateProxyHelper
89 .deproxy(entity
.getTypeStatus());
90 combo_typeStatus
.setSelection(typeStatus
);
91 checkbox_notDesignated
.setSelection(entity
.isNotDesignated());
96 public void handleEvent(Object eventSource
) {
97 if (eventSource
== combo_typeStatus
) {
98 getEntity().setTypeStatus(combo_typeStatus
.getSelection());
100 // TODO remove this once specimens are correctly implemented
101 else if (eventSource
== text_specimenTypeText
) {
102 // TODO this is a simple workaround to enter type specimen as text
104 if (getEntity().getTypeSpecimen() == null) {
105 Specimen typeSpecimen
= Specimen
.NewInstance();
106 getEntity().setTypeSpecimen(typeSpecimen
);
108 getEntity().getTypeSpecimen().setTitleCache(
109 text_specimenTypeText
.getText());
110 } else if (eventSource
== selection_typeSpecimen
) {
111 getEntity().setTypeSpecimen(selection_typeSpecimen
.getSelection());
112 } else if (eventSource
== checkbox_notDesignated
) {
113 getEntity().setNotDesignated(checkbox_notDesignated
.getSelection());
114 } else if (eventSource
== selection_reference
) {
115 getEntity().setCitation(selection_reference
.getSelection());
116 } else if (eventSource
== text_referenceDetail
) {
117 getEntity().setCitationMicroReference(
118 text_referenceDetail
.getText());
119 } else if (eventSource
== text_originaleNameString
) {
120 getEntity().setOriginalNameString(
121 text_originaleNameString
.getText());