1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.ui.section.name;
|
11
|
|
12
|
import org.eclipse.swt.events.SelectionListener;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.service.name.TypeDesignationStatusComparator;
|
15
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
16
|
import eu.etaxonomy.cdm.model.common.TermType;
|
17
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
18
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
|
19
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
20
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
21
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
27
|
|
28
|
/**
|
29
|
* @author n.hoffmann
|
30
|
* @created May 17, 2010
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class SpecimenTypeDesignationElement extends
|
34
|
AbstractTypeDesignationElement<SpecimenTypeDesignation> {
|
35
|
|
36
|
private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
|
37
|
private EntitySelectionElement<DerivedUnit> selection_typeSpecimen;
|
38
|
private TextWithLabelElement text_specimenTypeText;
|
39
|
|
40
|
public SpecimenTypeDesignationElement(CdmFormFactory formFactory,
|
41
|
AbstractFormSection section, SpecimenTypeDesignation entity,
|
42
|
SelectionListener removeListener, int style) {
|
43
|
super(formFactory, section, entity, removeListener, style);
|
44
|
}
|
45
|
|
46
|
/** {@inheritDoc} */
|
47
|
@Override
|
48
|
public void createControls(ICdmFormElement formElement, int style) {
|
49
|
selection_typeSpecimen = formFactory
|
50
|
.createSelectionElement(DerivedUnit.class,
|
51
|
formElement, "Specimen", null,
|
52
|
EntitySelectionElement.ALL, style);
|
53
|
combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
|
54
|
formElement, "Designation Status", null, style, new TypeDesignationStatusComparator<SpecimenTypeDesignationStatus>());
|
55
|
|
56
|
super.createControls(formElement, style);
|
57
|
}
|
58
|
|
59
|
/** {@inheritDoc} */
|
60
|
@Override
|
61
|
public void setEntity(SpecimenTypeDesignation entity) {
|
62
|
super.setEntity(entity);
|
63
|
if (entity.getTypeSpecimen() != null){
|
64
|
selection_typeSpecimen.setEntity(entity.getTypeSpecimen());
|
65
|
}else{
|
66
|
selection_typeSpecimen.setEntity(entity.getTypeSpecimen());
|
67
|
}
|
68
|
|
69
|
SpecimenTypeDesignationStatus typeStatus = HibernateProxyHelper
|
70
|
.deproxy(entity.getTypeStatus(), SpecimenTypeDesignationStatus.class);
|
71
|
combo_typeStatus.setSelection(typeStatus);
|
72
|
|
73
|
checkbox_notDesignated.setSelection(entity.isNotDesignated());
|
74
|
}
|
75
|
|
76
|
/** {@inheritDoc} */
|
77
|
@Override
|
78
|
public void handleEvent(Object eventSource) {
|
79
|
if (eventSource == combo_typeStatus) {
|
80
|
getEntity().setTypeStatus(combo_typeStatus.getSelection());
|
81
|
}
|
82
|
// TODO remove this once specimens are correctly implemented
|
83
|
else if (eventSource == text_specimenTypeText) {
|
84
|
// TODO this is a simple workaround to enter type specimen as text
|
85
|
// strings
|
86
|
if (getEntity().getTypeSpecimen() == null) {
|
87
|
DerivedUnit typeSpecimen = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
|
88
|
getEntity().setTypeSpecimen(typeSpecimen);
|
89
|
}
|
90
|
getEntity().getTypeSpecimen().setTitleCache(
|
91
|
text_specimenTypeText.getText());
|
92
|
} else if (eventSource == selection_typeSpecimen) {
|
93
|
getEntity().setTypeSpecimen(selection_typeSpecimen.getSelection());
|
94
|
} else if (eventSource == checkbox_notDesignated) {
|
95
|
getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
|
96
|
}
|
97
|
// else if (eventSource == selection_reference) {
|
98
|
// getEntity().setCitation(selection_reference.getSelection());
|
99
|
// } else if (eventSource == text_referenceDetail) {
|
100
|
// getEntity().setCitationMicroReference(
|
101
|
// text_referenceDetail.getText());
|
102
|
// }
|
103
|
}
|
104
|
}
|