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