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