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.name;
|
11
|
|
12
|
import java.util.Arrays;
|
13
|
import java.util.Collection;
|
14
|
import java.util.Comparator;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.eclipse.swt.SWT;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.common.TermType;
|
20
|
import eu.etaxonomy.cdm.model.name.IBacterialName;
|
21
|
import eu.etaxonomy.cdm.model.name.ICultivarPlantName;
|
22
|
import eu.etaxonomy.cdm.model.name.IFungusName;
|
23
|
import eu.etaxonomy.cdm.model.name.INonViralName;
|
24
|
import eu.etaxonomy.cdm.model.name.IZoologicalName;
|
25
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
26
|
import eu.etaxonomy.cdm.model.name.Rank;
|
27
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
28
|
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
|
29
|
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
|
30
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
31
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
32
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
33
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
34
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
35
|
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
|
36
|
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
|
37
|
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
|
38
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
39
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
40
|
|
41
|
/**
|
42
|
* <p>NameDetailElement class.</p>
|
43
|
*
|
44
|
* @author n.hoffmann
|
45
|
* @created Feb 26, 2010
|
46
|
*/
|
47
|
public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<INonViralName> implements ISelectableElement, IEnableableFormElement{
|
48
|
|
49
|
private final Logger logger = Logger.getLogger(NameDetailElement.class);
|
50
|
|
51
|
private TermComboElement<Rank> combo_rank;
|
52
|
private TextWithLabelElement text_appendedPhrase;
|
53
|
private TextWithLabelElement text_uninomial;
|
54
|
private TextWithLabelElement text_infragenericEpithet;
|
55
|
private TextWithLabelElement text_specificEpithet;
|
56
|
private TextWithLabelElement text_infraspecificEpithet;
|
57
|
private SelectionArbitrator selectionArbitrator;
|
58
|
private CheckboxElement checkbox_anamorphic;
|
59
|
private TextWithLabelElement text_cultivarName;
|
60
|
private TextWithLabelElement text_subGenusAuthorship;
|
61
|
|
62
|
private TextWithLabelElement text_breed;
|
63
|
//private NumberWithLabelElement text_publicationYear;
|
64
|
//private NumberWithLabelElement text_originalPublicationYear;
|
65
|
private int cursorPosition;
|
66
|
|
67
|
NameDetailsConfigurator config;
|
68
|
|
69
|
private int style;
|
70
|
|
71
|
/**
|
72
|
* <p>Constructor for NameDetailElement.</p>
|
73
|
*
|
74
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
75
|
* @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
|
76
|
* @param style a int.
|
77
|
*/
|
78
|
public NameDetailElement(CdmFormFactory cdmFormFactory, ICdmFormElement formElement,
|
79
|
int style) {
|
80
|
super(cdmFormFactory, formElement);
|
81
|
// make this element selectable
|
82
|
|
83
|
|
84
|
}
|
85
|
|
86
|
/** {@inheritDoc} */
|
87
|
@Override
|
88
|
protected void createControls(ICdmFormElement formElement, INonViralName nonViralName, int style) {
|
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>(){
|
98
|
|
99
|
@Override
|
100
|
public int compare(Rank o1, Rank o2) {
|
101
|
return o2.compareTo(o1);
|
102
|
}
|
103
|
|
104
|
};
|
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
|
// }
|
146
|
if(this.getFormFactory().getSelectionProvider() != null){
|
147
|
selectionArbitrator = this.getFormFactory().createSelectionArbitrator(this);
|
148
|
}
|
149
|
}
|
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
|
// }
|
201
|
@Override
|
202
|
protected void update(INonViralName nonViralName) {
|
203
|
super.update(nonViralName);
|
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()){
|
216
|
toggleable_cache.setText(nonViralName.getNameCache());
|
217
|
}
|
218
|
if (config.isRankActivated()){
|
219
|
combo_rank.setSelection(nonViralName.getRank());
|
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()){
|
229
|
text_appendedPhrase.setText(nonViralName.getAppendedPhrase());
|
230
|
}
|
231
|
}
|
232
|
}
|
233
|
|
234
|
/**
|
235
|
* <p>clearCheckRankWarnings</p>
|
236
|
*/
|
237
|
protected void clearCheckRankWarnings() {
|
238
|
if(getEntity().hasProblem(ParserProblem.CheckRank)){
|
239
|
getEntity().removeParsingProblem(ParserProblem.CheckRank);
|
240
|
|
241
|
// FIXME this has to be reafctored completely. See tickets #1959, #1663, #1957, #1958
|
242
|
// TaxonNameEditor nameEditor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
|
243
|
// nameEditor.getSelectedContainer().getNameViewer().clearErrors();
|
244
|
}
|
245
|
}
|
246
|
|
247
|
/** {@inheritDoc} */
|
248
|
@Override
|
249
|
public void updateContent() {
|
250
|
if(getEntity() == null){
|
251
|
setEntity(TaxonNameFactory.NewNonViralInstance(null));
|
252
|
}
|
253
|
|
254
|
super.updateContent();
|
255
|
if (toggleable_cache != null){
|
256
|
toggleable_cache.setEnabled(getEntity().isProtectedNameCache());
|
257
|
|
258
|
if (isAdvancedView){
|
259
|
if(isIrrelevant()){
|
260
|
setIrrelevant(isIrrelevant());
|
261
|
}else{
|
262
|
setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache}));
|
263
|
}
|
264
|
}
|
265
|
}
|
266
|
}
|
267
|
|
268
|
|
269
|
private void updateSpecificNameParts(INonViralName nonViralName) {
|
270
|
NomenclaturalCode code = nonViralName.getNomenclaturalCode();
|
271
|
if (code != null){
|
272
|
switch(nonViralName.getNomenclaturalCode()){
|
273
|
case ICNAFP :
|
274
|
//nothing do add
|
275
|
updateBotanicalNameParts(nonViralName);
|
276
|
break;
|
277
|
case Fungi :
|
278
|
if (isAdvancedView){
|
279
|
updateFungusNameParts(nonViralName);
|
280
|
}
|
281
|
break;
|
282
|
case ICZN:
|
283
|
updateZoologicalNameParts(nonViralName);
|
284
|
break;
|
285
|
case ICVCN:
|
286
|
//TODO implement
|
287
|
logger.warn("ICVCN not yet implemented");
|
288
|
break;
|
289
|
case ICNB:
|
290
|
updateBacterialNameParts(nonViralName);
|
291
|
break;
|
292
|
case ICNCP:
|
293
|
updateCultivarNameParts(nonViralName);
|
294
|
break;
|
295
|
case NonViral:
|
296
|
//TODO implement
|
297
|
logger.warn("NonViral not yet implemented");
|
298
|
break;
|
299
|
}
|
300
|
}
|
301
|
}
|
302
|
|
303
|
private void createSpecificNameParts(ICdmFormElement formElement,
|
304
|
INonViralName nonViralName, int style) {
|
305
|
NomenclaturalCode code = nonViralName.getNomenclaturalCode();
|
306
|
if (code != null){
|
307
|
switch(nonViralName.getNomenclaturalCode()){
|
308
|
case ICNAFP :
|
309
|
//nothing do add
|
310
|
createBotanicalNameParts(formElement, nonViralName, style);
|
311
|
break;
|
312
|
case Fungi :
|
313
|
if (isAdvancedView){
|
314
|
createFungusNameParts(formElement, nonViralName, style);
|
315
|
}
|
316
|
break;
|
317
|
case ICZN:
|
318
|
createZoologicalNameParts(formElement, nonViralName, style);
|
319
|
break;
|
320
|
case ICVCN:
|
321
|
//TODO implement
|
322
|
logger.warn("ICVCN not yet implemented");
|
323
|
break;
|
324
|
case ICNB:
|
325
|
createBacterialNameParts(formElement, nonViralName, style);
|
326
|
break;
|
327
|
case ICNCP:
|
328
|
createCultivarNameParts(formElement, nonViralName, style);
|
329
|
break;
|
330
|
case NonViral:
|
331
|
//TODO implement
|
332
|
logger.warn("NonViral not yet implemented");
|
333
|
break;
|
334
|
}
|
335
|
}
|
336
|
}
|
337
|
|
338
|
|
339
|
private void createBacterialNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style) {
|
340
|
IBacterialName bacterialName = (IBacterialName) nonViralName;
|
341
|
text_subGenusAuthorship = formFactory.createTextWithLabelElement(formElement, "Subgenus Authorship", bacterialName.getSubGenusAuthorship(), style);
|
342
|
// text_nameApprobation = formFactory.createTextWithLabelElement(formElement, "Name Approbation", bacterialName.getNameApprobation(), style);
|
343
|
|
344
|
}
|
345
|
|
346
|
private void updateBacterialNameParts(INonViralName nonViralName) {
|
347
|
IBacterialName bacterialName = (IBacterialName) nonViralName;
|
348
|
text_subGenusAuthorship.setText(bacterialName.getSubGenusAuthorship());
|
349
|
}
|
350
|
|
351
|
private void createCultivarNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style) {
|
352
|
ICultivarPlantName cultivarName = (ICultivarPlantName)nonViralName;
|
353
|
text_cultivarName = formFactory.createTextWithLabelElement(formElement, "Cultivar Name", cultivarName.getCultivarName(), style);
|
354
|
}
|
355
|
|
356
|
private void updateCultivarNameParts(INonViralName nonViralName) {
|
357
|
ICultivarPlantName cultivarName = (ICultivarPlantName)nonViralName;
|
358
|
text_cultivarName.setText(cultivarName.getCultivarName());
|
359
|
}
|
360
|
|
361
|
private void createBotanicalNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){
|
362
|
//nothing to do
|
363
|
}
|
364
|
|
365
|
private void updateBotanicalNameParts(INonViralName nonViralName){
|
366
|
//nothing to do
|
367
|
}
|
368
|
|
369
|
private void createFungusNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){
|
370
|
IFungusName fungusName= (IFungusName)nonViralName;
|
371
|
checkbox_anamorphic = formFactory.createCheckbox(formElement, "Anamorphic", fungusName.isAnamorphic(), style);
|
372
|
}
|
373
|
|
374
|
private void updateFungusNameParts(INonViralName nonViralName){
|
375
|
IFungusName fungusName= (IFungusName)nonViralName;
|
376
|
checkbox_anamorphic.setSelection(fungusName.isAnamorphic());
|
377
|
}
|
378
|
|
379
|
private void createZoologicalNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){
|
380
|
IZoologicalName zoologicalName = (IZoologicalName) nonViralName;
|
381
|
|
382
|
if (isAdvancedView){
|
383
|
text_breed = formFactory.createTextWithLabelElement(formElement, "Breed", zoologicalName.getBreed(), style);
|
384
|
}
|
385
|
}
|
386
|
|
387
|
private void updateZoologicalNameParts(INonViralName nonViralName){
|
388
|
IZoologicalName zoologicalName = (IZoologicalName) nonViralName;
|
389
|
if (isAdvancedView){
|
390
|
text_breed.setText(zoologicalName.getBreed());
|
391
|
}
|
392
|
}
|
393
|
|
394
|
private void createGenusOrUninomialControls(ICdmFormElement element, INonViralName nonViralName, int style){
|
395
|
String title = "Genus";
|
396
|
Rank rank = nonViralName.getRank();
|
397
|
if(rank != null && rank.isSupraGeneric()){
|
398
|
title = "Uninomial";
|
399
|
}
|
400
|
text_uninomial = formFactory.createTextWithLabelElement(element, title, nonViralName.getGenusOrUninomial(), style);
|
401
|
}
|
402
|
|
403
|
private void updateGenusOrUninomialControls(INonViralName nonViralName){
|
404
|
text_uninomial.setVisible(true);
|
405
|
text_uninomial.setText(nonViralName.getGenusOrUninomial());
|
406
|
}
|
407
|
|
408
|
private void createInfragenerericEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){
|
409
|
if (nonViralName.getNomenclaturalCode() == null || nonViralName.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)){
|
410
|
if(nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS()) ){
|
411
|
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style);
|
412
|
return;
|
413
|
}
|
414
|
} else{
|
415
|
if((nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS())) && !nonViralName.getRank().isLower(Rank.SPECIES()) && !nonViralName.getRank().isSpeciesAggregate()){
|
416
|
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style);
|
417
|
return;
|
418
|
}
|
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
|
}
|
440
|
}
|
441
|
|
442
|
private void createSpecificEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){
|
443
|
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){
|
444
|
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", nonViralName.getSpecificEpithet(), SWT.NULL);
|
445
|
return;
|
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
|
}
|
460
|
}
|
461
|
|
462
|
private void createInfraSpecificEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){
|
463
|
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraSpecific()){
|
464
|
text_infraspecificEpithet = formFactory.createTextWithLabelElement(element, "Infraspecific Epithet", nonViralName.getInfraSpecificEpithet(), SWT.NULL);
|
465
|
}
|
466
|
}
|
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
|
|
479
|
/** {@inheritDoc} */
|
480
|
@Override
|
481
|
public void handleEvent(Object eventSource){
|
482
|
if (eventSource == toggleable_cache) {
|
483
|
getEntity().setNameCache(toggleable_cache.getText(),
|
484
|
toggleable_cache.getState());
|
485
|
//if (!isIrrelevant()) {
|
486
|
setIrrelevant(toggleable_cache.getState(),
|
487
|
Arrays.asList(new Object[] { toggleable_cache }));
|
488
|
//}
|
489
|
}
|
490
|
else if(eventSource == combo_rank){
|
491
|
getEntity().setRank(combo_rank.getSelection());
|
492
|
clearCheckRankWarnings();
|
493
|
updateContent();
|
494
|
}
|
495
|
else if(eventSource == text_appendedPhrase){
|
496
|
getEntity().setAppendedPhrase(text_appendedPhrase.getText());
|
497
|
}
|
498
|
else if(eventSource == text_infragenericEpithet){
|
499
|
getEntity().setInfraGenericEpithet(text_infragenericEpithet.getText());
|
500
|
}
|
501
|
else if(eventSource == text_infraspecificEpithet){
|
502
|
getEntity().setInfraSpecificEpithet(text_infraspecificEpithet.getText());
|
503
|
}
|
504
|
else if(eventSource == text_specificEpithet){
|
505
|
getEntity().setSpecificEpithet(text_specificEpithet.getText());
|
506
|
}
|
507
|
else if(eventSource == text_uninomial){
|
508
|
getEntity().setGenusOrUninomial(text_uninomial.getText());
|
509
|
}
|
510
|
else if(eventSource == checkbox_anamorphic){
|
511
|
((IFungusName)getEntity()).setAnamorphic(checkbox_anamorphic.getSelection());
|
512
|
}else if(eventSource == text_breed){
|
513
|
((IZoologicalName)getEntity()).setBreed(text_breed.getText());
|
514
|
}else if(eventSource == this.text_cultivarName){
|
515
|
((ICultivarPlantName)getEntity()).setCultivarName(text_cultivarName.getText());
|
516
|
}else if(eventSource == this.text_subGenusAuthorship){
|
517
|
((IBacterialName)getEntity()).setSubGenusAuthorship(text_subGenusAuthorship.getText());
|
518
|
}
|
519
|
|
520
|
}
|
521
|
|
522
|
/*
|
523
|
* (non-Javadoc)
|
524
|
* @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement#getSelectionArbitrator()
|
525
|
*/
|
526
|
/**
|
527
|
* <p>Getter for the field <code>selectionArbitrator</code>.</p>
|
528
|
*
|
529
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
|
530
|
*/
|
531
|
@Override
|
532
|
public SelectionArbitrator getSelectionArbitrator() {
|
533
|
return selectionArbitrator;
|
534
|
}
|
535
|
|
536
|
@Override
|
537
|
public void updateToggleableCacheField() {
|
538
|
if (toggleable_cache != null){
|
539
|
if(! getEntity().isProtectedNameCache()){
|
540
|
toggleable_cache.setText(getEntity().getNameCache());
|
541
|
}
|
542
|
}
|
543
|
}
|
544
|
|
545
|
@Override
|
546
|
protected void handleToggleableCacheField() {
|
547
|
boolean pushedState = toggleable_cache.getState();
|
548
|
|
549
|
getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
|
550
|
setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, text_appendedPhrase, checkbox_anamorphic }));
|
551
|
updateToggleableCacheField();
|
552
|
}
|
553
|
|
554
|
@Override
|
555
|
public void setIrrelevant(boolean irrelevant, Collection<Object> except){
|
556
|
if (toggleable_cache != null){
|
557
|
if (toggleable_cache.getState() == irrelevant){
|
558
|
super.setIrrelevant(irrelevant, except);
|
559
|
}
|
560
|
if (except == null || except.isEmpty()){
|
561
|
toggleable_cache.setIrrelevant(irrelevant);
|
562
|
}
|
563
|
}
|
564
|
|
565
|
}
|
566
|
|
567
|
|
568
|
|
569
|
|
570
|
}
|