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