Revision 515cd3ec
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java | ||
---|---|---|
66 | 66 |
|
67 | 67 |
NameDetailsConfigurator config; |
68 | 68 |
|
69 |
private int style; |
|
70 |
|
|
69 | 71 |
/** |
70 | 72 |
* <p>Constructor for NameDetailElement.</p> |
71 | 73 |
* |
... | ... | |
84 | 86 |
/** {@inheritDoc} */ |
85 | 87 |
@Override |
86 | 88 |
protected void createControls(ICdmFormElement formElement, INonViralName nonViralName, int style) { |
87 |
Comparator<Rank> comparator = null; |
|
88 |
config = PreferencesUtil.setPreferredNameDetailsConfiguration(false); |
|
89 |
if ( PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.ALLOW_OVERRIDE_NAME_DETAILS) || config == null){ |
|
90 |
config = PreferencesUtil.setPreferredNameDetailsConfiguration(true); |
|
91 |
} |
|
92 |
if(PreferencesUtil.getSortRanksHierarchichally()){ |
|
93 |
comparator = new Comparator<Rank>(){ |
|
94 |
|
|
95 |
@Override |
|
96 |
public int compare(Rank o1, Rank o2) { |
|
97 |
return o2.compareTo(o1); |
|
98 |
} |
|
99 |
|
|
100 |
}; |
|
101 |
} |
|
102 |
if (isAdvancedView){ |
|
103 |
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
104 |
|
|
105 |
combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
106 |
createGenusOrUninomialControls(this, nonViralName, style); |
|
107 |
createInfragenerericEpithetControls(this, nonViralName, style); |
|
108 |
createSpecificEpithetControls(this, nonViralName, style); |
|
109 |
createInfraSpecificEpithetControls(this, nonViralName, style); |
|
110 |
createSpecificNameParts(this, nonViralName, style); |
|
111 |
text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
112 |
}else{ |
|
113 |
if (config.isNameCacheActivated()){ |
|
114 |
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
115 |
} |
|
89 |
this.style = style; |
|
90 |
super.update(nonViralName); |
|
91 |
Comparator<Rank> comparator = null; |
|
92 |
config = PreferencesUtil.setPreferredNameDetailsConfiguration(false); |
|
93 |
if ( PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.ALLOW_OVERRIDE_NAME_DETAILS) || config == null){ |
|
94 |
config = PreferencesUtil.setPreferredNameDetailsConfiguration(true); |
|
95 |
} |
|
96 |
if(PreferencesUtil.getSortRanksHierarchichally()){ |
|
97 |
comparator = new Comparator<Rank>(){ |
|
116 | 98 |
|
117 |
if (config.isRankActivated()){ |
|
118 |
combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
119 |
} |
|
99 |
@Override |
|
100 |
public int compare(Rank o1, Rank o2) { |
|
101 |
return o2.compareTo(o1); |
|
102 |
} |
|
120 | 103 |
|
121 |
if (config.isAtomisedEpithetsActivated()){ |
|
122 |
createGenusOrUninomialControls(this, nonViralName, style); |
|
123 |
createInfragenerericEpithetControls(this, nonViralName, style); |
|
124 |
createSpecificEpithetControls(this, nonViralName, style); |
|
125 |
createInfraSpecificEpithetControls(this, nonViralName, style); |
|
126 |
createSpecificNameParts(this, nonViralName, style); |
|
127 |
} |
|
128 |
if (config.isAppendedPhraseActivated()){ |
|
129 |
text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
130 |
} |
|
104 |
}; |
|
131 | 105 |
} |
106 |
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", null, nonViralName.isProtectedNameCache(), style); |
|
107 |
|
|
108 |
combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", null, style, comparator); |
|
109 |
createGenusOrUninomialControls(this, nonViralName, style); |
|
110 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(this, "Infrageneric Epithet", null, style); |
|
111 |
text_specificEpithet = formFactory.createTextWithLabelElement(this, "Specific Epithet", null, SWT.NULL); |
|
112 |
text_infraspecificEpithet = formFactory.createTextWithLabelElement(this, "Infraspecific Epithet", nonViralName.getInfraSpecificEpithet(), SWT.NULL); |
|
113 |
// createSpecificNameParts(this, nonViralName, style); |
|
114 |
|
|
115 |
text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", null, style); |
|
116 |
|
|
117 |
update(nonViralName); |
|
118 |
// if (isAdvancedView){ |
|
119 |
// toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
120 |
// |
|
121 |
// combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
122 |
// createGenusOrUninomialControls(this, nonViralName, style); |
|
123 |
// createInfragenerericEpithetControls(this, nonViralName, style); |
|
124 |
// createSpecificEpithetControls(this, nonViralName, style); |
|
125 |
// createInfraSpecificEpithetControls(this, nonViralName, style); |
|
126 |
// createSpecificNameParts(this, nonViralName, style); |
|
127 |
// text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
128 |
// }else{ |
|
129 |
// if (config.isNameCacheActivated()){ |
|
130 |
// toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
131 |
// } |
|
132 |
// if (config.isRankActivated()){ |
|
133 |
// combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
134 |
// } |
|
135 |
// if (config.isAtomisedEpithetsActivated()){ |
|
136 |
// createGenusOrUninomialControls(this, nonViralName, style); |
|
137 |
// createInfragenerericEpithetControls(this, nonViralName, style); |
|
138 |
// createSpecificEpithetControls(this, nonViralName, style); |
|
139 |
// createInfraSpecificEpithetControls(this, nonViralName, style); |
|
140 |
// createSpecificNameParts(this, nonViralName, style); |
|
141 |
// } |
|
142 |
// if (config.isAppendedPhraseActivated()){ |
|
143 |
// text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
144 |
// } |
|
145 |
// } |
|
132 | 146 |
if(this.getFormFactory().getSelectionProvider() != null){ |
133 |
selectionArbitrator = this.getFormFactory().createSelectionArbitrator(this); |
|
134 |
} |
|
135 |
|
|
147 |
selectionArbitrator = this.getFormFactory().createSelectionArbitrator(this); |
|
148 |
} |
|
136 | 149 |
} |
137 | 150 |
|
151 |
// @Override |
|
152 |
// protected void update(INonViralName nonViralName) { |
|
153 |
// super.update(nonViralName); |
|
154 |
// Comparator<Rank> comparator = null; |
|
155 |
// config = PreferencesUtil.setPreferredNameDetailsConfiguration(false); |
|
156 |
// if ( PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.ALLOW_OVERRIDE_NAME_DETAILS) || config == null){ |
|
157 |
// config = PreferencesUtil.setPreferredNameDetailsConfiguration(true); |
|
158 |
// } |
|
159 |
// if(PreferencesUtil.getSortRanksHierarchichally()){ |
|
160 |
// comparator = new Comparator<Rank>(){ |
|
161 |
// |
|
162 |
// @Override |
|
163 |
// public int compare(Rank o1, Rank o2) { |
|
164 |
// return o2.compareTo(o1); |
|
165 |
// } |
|
166 |
// |
|
167 |
// }; |
|
168 |
// } |
|
169 |
// if (isAdvancedView){ |
|
170 |
// toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
171 |
// |
|
172 |
// combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
173 |
// createGenusOrUninomialControls(this, nonViralName, style); |
|
174 |
// createInfragenerericEpithetControls(this, nonViralName, style); |
|
175 |
// createSpecificEpithetControls(this, nonViralName, style); |
|
176 |
// createInfraSpecificEpithetControls(this, nonViralName, style); |
|
177 |
// createSpecificNameParts(this, nonViralName, style); |
|
178 |
// text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
179 |
// }else{ |
|
180 |
// if (config.isNameCacheActivated()){ |
|
181 |
// toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
182 |
// } |
|
183 |
// if (config.isRankActivated()){ |
|
184 |
// combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
185 |
// } |
|
186 |
// if (config.isAtomisedEpithetsActivated()){ |
|
187 |
// createGenusOrUninomialControls(this, nonViralName, style); |
|
188 |
// createInfragenerericEpithetControls(this, nonViralName, style); |
|
189 |
// createSpecificEpithetControls(this, nonViralName, style); |
|
190 |
// createInfraSpecificEpithetControls(this, nonViralName, style); |
|
191 |
// createSpecificNameParts(this, nonViralName, style); |
|
192 |
// } |
|
193 |
// if (config.isAppendedPhraseActivated()){ |
|
194 |
// text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
195 |
// } |
|
196 |
// } |
|
197 |
// if(this.getFormFactory().getSelectionProvider() != null){ |
|
198 |
// selectionArbitrator = this.getFormFactory().createSelectionArbitrator(this); |
|
199 |
// } |
|
200 |
// } |
|
138 | 201 |
@Override |
139 | 202 |
protected void update(INonViralName nonViralName) { |
140 | 203 |
super.update(nonViralName); |
141 |
if (isAdvancedView){ |
|
204 |
if (isAdvancedView){ |
|
205 |
toggleable_cache.setText(nonViralName.getNameCache()); |
|
206 |
|
|
207 |
combo_rank.setSelection(nonViralName.getRank()); |
|
208 |
updateGenusOrUninomialControls(nonViralName); |
|
209 |
updateInfragenerericEpithetControls(nonViralName); |
|
210 |
updateSpecificEpithetControls(nonViralName); |
|
211 |
updateInfraSpecificEpithetControls(nonViralName); |
|
212 |
// updateSpecificNameParts(nonViralName); |
|
213 |
text_appendedPhrase.setText(nonViralName.getAppendedPhrase()); |
|
214 |
}else{ |
|
215 |
if (config.isNameCacheActivated()){ |
|
142 | 216 |
toggleable_cache.setText(nonViralName.getNameCache()); |
143 |
|
|
217 |
} |
|
218 |
if (config.isRankActivated()){ |
|
144 | 219 |
combo_rank.setSelection(nonViralName.getRank()); |
145 |
|
|
146 |
|
|
147 |
text_uninomial.setText(nonViralName.getGenusOrUninomial()); |
|
148 |
text_infragenericEpithet.setText(nonViralName.getInfraGenericEpithet()); |
|
149 |
text_specificEpithet.setText(nonViralName.getSpecificEpithet()); |
|
150 |
text_infraspecificEpithet.setText(nonViralName.getInfraSpecificEpithet()); |
|
151 |
updateSpecificNameParts(nonViralName); |
|
152 |
|
|
220 |
} |
|
221 |
if (config.isAtomisedEpithetsActivated()){ |
|
222 |
updateGenusOrUninomialControls(nonViralName); |
|
223 |
updateInfragenerericEpithetControls(nonViralName); |
|
224 |
updateSpecificEpithetControls(nonViralName); |
|
225 |
updateInfraSpecificEpithetControls(nonViralName); |
|
226 |
// updateSpecificNameParts(nonViralName); |
|
227 |
} |
|
228 |
if (config.isAppendedPhraseActivated()){ |
|
153 | 229 |
text_appendedPhrase.setText(nonViralName.getAppendedPhrase()); |
154 |
}else{ |
|
155 |
if (config.isNameCacheActivated()){ |
|
156 |
toggleable_cache.setText(nonViralName.getNameCache()); |
|
157 |
} |
|
158 |
|
|
159 |
if (config.isRankActivated()){ |
|
160 |
combo_rank.setSelection(nonViralName.getRank()); |
|
161 |
} |
|
162 |
|
|
163 |
if (config.isAtomisedEpithetsActivated()){ |
|
164 |
text_uninomial.setText(nonViralName.getGenusOrUninomial()); |
|
165 |
text_infragenericEpithet.setText(nonViralName.getInfraGenericEpithet()); |
|
166 |
text_specificEpithet.setText(nonViralName.getSpecificEpithet()); |
|
167 |
text_infraspecificEpithet.setText(nonViralName.getInfraSpecificEpithet()); |
|
168 |
updateSpecificNameParts(nonViralName); |
|
169 |
} |
|
170 |
if (config.isAppendedPhraseActivated()){ |
|
171 |
text_appendedPhrase.setText(nonViralName.getAppendedPhrase()); |
|
172 |
} |
|
173 | 230 |
} |
231 |
} |
|
174 | 232 |
} |
175 | 233 |
|
176 | 234 |
/** |
... | ... | |
342 | 400 |
text_uninomial = formFactory.createTextWithLabelElement(element, title, nonViralName.getGenusOrUninomial(), style); |
343 | 401 |
} |
344 | 402 |
|
403 |
private void updateGenusOrUninomialControls(INonViralName nonViralName){ |
|
404 |
text_uninomial.setVisible(true); |
|
405 |
text_uninomial.setText(nonViralName.getGenusOrUninomial()); |
|
406 |
} |
|
407 |
|
|
345 | 408 |
private void createInfragenerericEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
346 | 409 |
if (nonViralName.getNomenclaturalCode() == null || nonViralName.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)){ |
347 | 410 |
if(nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS()) ){ |
348 | 411 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style); |
412 |
return; |
|
349 | 413 |
} |
350 | 414 |
} else{ |
351 | 415 |
if((nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS())) && !nonViralName.getRank().isLower(Rank.SPECIES()) && !nonViralName.getRank().isSpeciesAggregate()){ |
352 | 416 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style); |
417 |
return; |
|
353 | 418 |
} |
354 | 419 |
} |
420 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", null, style); |
|
421 |
text_infragenericEpithet.setVisible(false); |
|
422 |
} |
|
423 |
|
|
424 |
private void updateInfragenerericEpithetControls(INonViralName nonViralName){ |
|
425 |
if (nonViralName.getNomenclaturalCode() == null || nonViralName.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)){ |
|
426 |
if(nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS()) ){ |
|
427 |
text_infragenericEpithet.setVisible(true); |
|
428 |
text_infragenericEpithet.setText(nonViralName.getInfraGenericEpithet()); |
|
429 |
return; |
|
430 |
} |
|
431 |
} |
|
432 |
else if((nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS())) && !nonViralName.getRank().isLower(Rank.SPECIES()) && !nonViralName.getRank().isSpeciesAggregate()){ |
|
433 |
text_infragenericEpithet.setVisible(true); |
|
434 |
text_infragenericEpithet.setText(nonViralName.getInfraGenericEpithet()); |
|
435 |
return; |
|
436 |
} |
|
437 |
if(text_infragenericEpithet!=null){ |
|
438 |
text_infragenericEpithet.setVisible(false); |
|
439 |
} |
|
355 | 440 |
} |
356 | 441 |
|
357 | 442 |
private void createSpecificEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
358 | 443 |
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){ |
359 |
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", nonViralName.getSpecificEpithet(), SWT.NULL); |
|
444 |
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", nonViralName.getSpecificEpithet(), SWT.NULL); |
|
445 |
return; |
|
360 | 446 |
} |
447 |
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", null, SWT.NULL); |
|
448 |
text_specificEpithet.setVisible(false); |
|
449 |
} |
|
450 |
|
|
451 |
private void updateSpecificEpithetControls(INonViralName nonViralName){ |
|
452 |
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){ |
|
453 |
text_specificEpithet.setText(nonViralName.getSpecificEpithet()); |
|
454 |
text_specificEpithet.setVisible(true); |
|
455 |
return; |
|
456 |
} |
|
457 |
if(text_specificEpithet!=null){ |
|
458 |
text_specificEpithet.setVisible(false); |
|
459 |
} |
|
361 | 460 |
} |
362 | 461 |
|
363 | 462 |
private void createInfraSpecificEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
... | ... | |
366 | 465 |
} |
367 | 466 |
} |
368 | 467 |
|
468 |
private void updateInfraSpecificEpithetControls(INonViralName nonViralName){ |
|
469 |
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraSpecific()){ |
|
470 |
text_infraspecificEpithet.setVisible(true); |
|
471 |
text_infraspecificEpithet.setText(nonViralName.getInfraSpecificEpithet()); |
|
472 |
return; |
|
473 |
} |
|
474 |
if(text_infraspecificEpithet!=null){ |
|
475 |
text_infraspecificEpithet.setVisible(false); |
|
476 |
} |
|
477 |
} |
|
478 |
|
|
369 | 479 |
/** {@inheritDoc} */ |
370 | 480 |
@Override |
371 | 481 |
public void handleEvent(Object eventSource){ |
Also available in: Unified diff
ref #6554 Cache NameDetailElement (experimental)