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.ui.section.occurrence;
|
12
|
|
13
|
import org.eclipse.ui.forms.widgets.Section;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
16
|
import eu.etaxonomy.cdm.api.facade.MethodNotSupportedByDerivedUnitTypeException;
|
17
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
18
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
19
|
import eu.etaxonomy.cdm.model.occurrence.PreservationMethod;
|
20
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
22
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
23
|
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
26
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
|
27
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
28
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
29
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
30
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
31
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
32
|
|
33
|
/**
|
34
|
* <p>
|
35
|
* DerivedUnitBaseDetailElement class.
|
36
|
* </p>
|
37
|
*
|
38
|
* @author n.hoffmann
|
39
|
* @created Jun 24, 2010
|
40
|
* @version 1.0
|
41
|
*/
|
42
|
public class DerivedUnitBaseDetailElement extends
|
43
|
AbstractCdmDetailElement<DerivedUnitFacade> {
|
44
|
|
45
|
private TextWithLabelElement text_derivedUnitDefinitions;
|
46
|
|
47
|
private TextWithLabelElement text_barcode;
|
48
|
|
49
|
private TextWithLabelElement text_catalogNumber;
|
50
|
|
51
|
private EntitySelectionElement<TaxonNameBase> selection_storedUnder;
|
52
|
|
53
|
private TextWithLabelElement text_exsicatum;
|
54
|
|
55
|
|
56
|
private TermComboElement<PreservationMethod> combo_preservationMethod;
|
57
|
|
58
|
private SpecimenCollectionDetailSection section_duplicates;
|
59
|
|
60
|
private SourceCollectionDetailSection section_source;
|
61
|
|
62
|
/**
|
63
|
* <p>
|
64
|
* Constructor for DerivedUnitBaseDetailElement.
|
65
|
* </p>
|
66
|
*
|
67
|
* @param formFactory
|
68
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
69
|
* object.
|
70
|
* @param formElement
|
71
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
72
|
* object.
|
73
|
*/
|
74
|
public DerivedUnitBaseDetailElement(CdmFormFactory formFactory,
|
75
|
ICdmFormElement formElement) {
|
76
|
super(formFactory, formElement);
|
77
|
}
|
78
|
|
79
|
/** {@inheritDoc} */
|
80
|
@Override
|
81
|
protected void createControls(ICdmFormElement formElement,
|
82
|
DerivedUnitFacade entity, int style) {
|
83
|
// Disable for now
|
84
|
// text_derivedUnitDefinitions =
|
85
|
// formFactory.createTextWithLabelElement(formElement,
|
86
|
// "Specimen Definition",
|
87
|
// facade.getDerivedUnitDefinition(CdmStore.getDefaultLanguage()),
|
88
|
// style);
|
89
|
text_barcode = formFactory.createTextWithLabelElement(formElement,
|
90
|
"Barcode", entity.getBarcode(), style);
|
91
|
text_catalogNumber = formFactory
|
92
|
.createTextWithLabelElement(formElement, "Catalog Number",
|
93
|
entity.getCatalogNumber(), style);
|
94
|
|
95
|
|
96
|
try {
|
97
|
combo_preservationMethod = formFactory.createTermComboElement(PreservationMethod.class,
|
98
|
formElement, "Preservation Method",
|
99
|
entity.getPreservationMethod(), style);
|
100
|
} catch (MethodNotSupportedByDerivedUnitTypeException e) {
|
101
|
// we ignore this
|
102
|
StoreUtil.info(e.getMessage());
|
103
|
}
|
104
|
selection_storedUnder = formFactory
|
105
|
.createSelectionElement(TaxonNameBase.class,
|
106
|
getConversationHolder(), formElement, "Stored Under",
|
107
|
entity.getStoredUnder(), EntitySelectionElement.ALL,
|
108
|
style);
|
109
|
|
110
|
try {
|
111
|
text_exsicatum = formFactory.createTextWithLabelElement(
|
112
|
formElement, "Exsiccatum", entity.getExsiccatum(), style);
|
113
|
} catch (MethodNotSupportedByDerivedUnitTypeException e) {
|
114
|
// we ignore this
|
115
|
StoreUtil.info(e.getMessage());
|
116
|
}
|
117
|
|
118
|
// section_duplicates = (SpecimenCollectionDetailSection) formFactory
|
119
|
// .createEntityDetailSection(
|
120
|
// EntityDetailType.SPECIMEN_COLLECTION,
|
121
|
// getConversationHolder(), formElement, Section.TWISTIE);
|
122
|
// section_duplicates
|
123
|
// .setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
124
|
// section_duplicates.setEntity(entity);
|
125
|
|
126
|
section_source = (SourceCollectionDetailSection) formFactory
|
127
|
.createEntityDetailSection(
|
128
|
EntityDetailType.IDENTIFIABLE_SOURCE_COLLECTION,
|
129
|
getConversationHolder(), formElement, Section.TWISTIE);
|
130
|
section_source.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
131
|
section_source.setEntity(entity);
|
132
|
}
|
133
|
|
134
|
/** {@inheritDoc} */
|
135
|
@Override
|
136
|
public void handleEvent(Object eventSource) {
|
137
|
if (eventSource == text_derivedUnitDefinitions) {
|
138
|
getEntity().addDerivedUnitDefinition(
|
139
|
text_derivedUnitDefinitions.getText(),
|
140
|
CdmStore.getDefaultLanguage());
|
141
|
} else if (eventSource == text_barcode) {
|
142
|
getEntity().setBarcode(text_barcode.getText());
|
143
|
} else if (eventSource == text_catalogNumber) {
|
144
|
getEntity().setCatalogNumber(text_catalogNumber.getText());
|
145
|
} else if (eventSource == combo_preservationMethod) {
|
146
|
try {
|
147
|
getEntity().setPreservationMethod(
|
148
|
combo_preservationMethod.getSelection());
|
149
|
} catch (MethodNotSupportedByDerivedUnitTypeException e) {
|
150
|
StoreUtil
|
151
|
.errorDialog(
|
152
|
"MethodNotSupportedByDerivedUnitTypeException",
|
153
|
this,
|
154
|
"MethodNotSupportedByDerivedUnitTypeException when trying to set preservation method for derive unit",
|
155
|
e);
|
156
|
}
|
157
|
} else if (eventSource == selection_storedUnder) {
|
158
|
getEntity().setStoredUnder(selection_storedUnder.getEntity());
|
159
|
} else if (eventSource == text_exsicatum) {
|
160
|
try {
|
161
|
getEntity().setExsiccatum(text_exsicatum.getText());
|
162
|
} catch (Exception e) {
|
163
|
StoreUtil.error(this.getClass(), e);
|
164
|
}
|
165
|
}
|
166
|
}
|
167
|
}
|