1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.section.name;
|
12
|
|
13
|
import org.eclipse.swt.events.SelectionListener;
|
14
|
|
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.forms.AbstractFormSection;
|
20
|
import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
|
21
|
import eu.etaxonomy.taxeditor.forms.CdmFormFactory.SelectionType;
|
22
|
import eu.etaxonomy.taxeditor.forms.CdmFormFactory.TermComboType;
|
23
|
import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.forms.TextWithLabelElement;
|
25
|
import eu.etaxonomy.taxeditor.forms.selection.DerivedUnitBaseSelectionElement;
|
26
|
import eu.etaxonomy.taxeditor.forms.term.SpecimenTypeDesignationStatusComboElement;
|
27
|
|
28
|
/**
|
29
|
* <p>SpecimenTypeDesignationElement class.</p>
|
30
|
*
|
31
|
* @author n.hoffmann
|
32
|
* @created May 17, 2010
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class SpecimenTypeDesignationElement extends
|
36
|
AbstractTypeDesignationElement<SpecimenTypeDesignation> {
|
37
|
|
38
|
private SpecimenTypeDesignationStatusComboElement combo_typeStatus;
|
39
|
private DerivedUnitBaseSelectionElement selection_typeSpecimen;
|
40
|
private TextWithLabelElement text_specimenTypeText;
|
41
|
|
42
|
/**
|
43
|
* <p>Constructor for SpecimenTypeDesignationElement.</p>
|
44
|
*
|
45
|
* @param formFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
|
46
|
* @param section a {@link eu.etaxonomy.taxeditor.forms.AbstractFormSection} object.
|
47
|
* @param entity a {@link eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation} object.
|
48
|
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
|
49
|
* @param style a int.
|
50
|
*/
|
51
|
public SpecimenTypeDesignationElement(CdmFormFactory formFactory,
|
52
|
AbstractFormSection section, SpecimenTypeDesignation entity,
|
53
|
SelectionListener removeListener, int style) {
|
54
|
super(formFactory, section, entity, removeListener, style);
|
55
|
}
|
56
|
|
57
|
/** {@inheritDoc} */
|
58
|
@Override
|
59
|
public void createControls(ICdmFormElement formElement, int style) {
|
60
|
// TODO until we do not have a specimen editor we will provide a simple text interface to enter specimen
|
61
|
// information
|
62
|
|
63
|
// text_specimenTypeText = formFactory.createTextWithLabelElement(formElement, "Unit", null, style);
|
64
|
// TODO testing the specimen selection dialog
|
65
|
selection_typeSpecimen = (DerivedUnitBaseSelectionElement) formFactory.createSelectionElement(SelectionType.DERIVED_UNIT, getConversationHolder(), formElement, "Unit", null, style);
|
66
|
combo_typeStatus = (SpecimenTypeDesignationStatusComboElement) formFactory.createTermComboElement(TermComboType.SPECIMENTYPEDESIGNATIONSTATUS, formElement, "Designation Status", null, style);
|
67
|
|
68
|
super.createControls(formElement, style);
|
69
|
}
|
70
|
|
71
|
/** {@inheritDoc} */
|
72
|
@Override
|
73
|
public void setEntity(SpecimenTypeDesignation entity) {
|
74
|
super.setEntity(entity);
|
75
|
// TODO remove this once specimen are completely implemented
|
76
|
if(entity.getTypeSpecimen() != null && text_specimenTypeText != null){
|
77
|
text_specimenTypeText.setText(entity.getTypeSpecimen().getTitleCache());
|
78
|
}
|
79
|
|
80
|
SpecimenTypeDesignationStatus typeStatus = (SpecimenTypeDesignationStatus) HibernateProxyHelper.deproxy(entity.getTypeStatus());
|
81
|
combo_typeStatus.setSelection(typeStatus);
|
82
|
checkbox_notDesignated.setSelection(entity.isNotDesignated());
|
83
|
}
|
84
|
|
85
|
/** {@inheritDoc} */
|
86
|
@Override
|
87
|
public void handleEvent(Object eventSource) {
|
88
|
if(eventSource == combo_typeStatus){
|
89
|
getEntity().setTypeStatus(combo_typeStatus.getSelection());
|
90
|
}
|
91
|
// TODO remove this once specimens are correctly implemented
|
92
|
else if(eventSource == text_specimenTypeText){
|
93
|
// TODO this is a simple workaround to enter type specimen as text strings
|
94
|
if(getEntity().getTypeSpecimen() == null){
|
95
|
Specimen typeSpecimen = Specimen.NewInstance();
|
96
|
getEntity().setTypeSpecimen(typeSpecimen);
|
97
|
}
|
98
|
getEntity().getTypeSpecimen().setTitleCache(text_specimenTypeText.getText());
|
99
|
}
|
100
|
else if(eventSource == selection_typeSpecimen){
|
101
|
getEntity().setTypeSpecimen(selection_typeSpecimen.getSelection());
|
102
|
}
|
103
|
else if(eventSource == checkbox_notDesignated){
|
104
|
getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
|
105
|
}
|
106
|
else if(eventSource == selection_reference){
|
107
|
getEntity().setCitation(selection_reference.getSelection());
|
108
|
}
|
109
|
else if(eventSource == text_referenceDetail){
|
110
|
getEntity().setCitationMicroReference(text_referenceDetail.getText());
|
111
|
}
|
112
|
else if(eventSource == text_originaleNameString){
|
113
|
getEntity().setOriginalNameString(text_originaleNameString.getText());
|
114
|
}
|
115
|
}
|
116
|
}
|