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