fix #8943: fix handling of term preferences in combo boxes and code cleaning
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / SearchDialogPreferences.java
1 /**
2 * Copyright (C) 2018 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 package eu.etaxonomy.taxeditor.preference;
10
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.events.SelectionAdapter;
13 import org.eclipse.swt.events.SelectionEvent;
14 import org.eclipse.swt.events.SelectionListener;
15 import org.eclipse.swt.layout.GridData;
16 import org.eclipse.swt.widgets.Button;
17 import org.eclipse.swt.widgets.Combo;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Label;
21
22 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
23 import eu.etaxonomy.cdm.model.metadata.NamedAreaSearchField;
24 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
25 import eu.etaxonomy.taxeditor.l10n.Messages;
26 import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
27
28 /**
29 * @author k.luther
30 * @since 16.10.2018
31 *
32 */
33 public class SearchDialogPreferences extends CdmPreferencePage implements SelectionListener {
34
35 protected CdmPreference showIdInSelectionDialogPref;
36 protected CdmPreference searchForIdentifierAsDefaultPref;
37 protected CdmPreference searchForIdentifierAndTitleCachePref;
38 protected CdmPreference sortTaxaByRankAndNamePref;
39 protected CdmPreference filterCommonNameReferencesPref;
40 protected CdmPreference searchNamedAreasByAbbrevPref;
41
42
43 protected Boolean showIdInSelectionDialog;
44 protected Boolean searchForIdentifierAsDefault;
45 protected Boolean searchForIdentifierAndTitleCache;
46 protected Boolean sortTaxaByRankAndName;
47 protected Boolean filterCommonNameReferences;
48 protected NamedAreaSearchField searchNamedAreasByAbbrev;
49
50 private boolean overrideShowIdInSelectionDialog = true;
51 private boolean overrideSearchForIdentifierAsDefault = true;
52 private boolean overrideSearchForIdentifierAndTitleCache = true;
53 private boolean overrideSortTaxaByRankAndName = true;
54 private boolean overrideFilterCommonNameReferences = true;
55 private boolean overrideSearchNamedAreasByAbbrev = true;
56
57 protected Combo showIdInSelectionDialogButton;
58 protected Button allowOverrideIsShowIdInSelectionDialogButton;
59 protected Combo searchForIdentifierAsDefaultButton;
60 protected Button allowOverrideSearchForIdentifierAsDefaultButton;
61 protected Combo searchForIdentifierAndTitleCacheButton;
62 protected Button allowOverridesSearchForIdentifierAndTitleCacheButton;
63 protected Combo sortTaxaByRankAndNameButton;
64 protected Button allowOverrideIsSortTaxaByRankAndNameButton;
65 protected Combo filterCommonNameReferenceButton;
66 protected Button allowOverrideFilterCommonNameReferencesButton;
67 protected Combo searchNamedAreasByAbbrevButton;
68 protected Button allowOverridesearchNamedAreasByAbbrevButton;
69
70
71
72 @Override
73 public void getValues(){
74
75 showIdInSelectionDialogPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInSelectionDialog);
76 searchForIdentifierAsDefaultPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SearchForIdentifierAsDefault);
77 searchForIdentifierAndTitleCachePref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SearchForIdentifierAndTitleCache);
78 sortTaxaByRankAndNamePref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SortTaxaByRankAndName);
79 filterCommonNameReferencesPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.CommonNameReferencesWithMarker);
80 searchNamedAreasByAbbrevPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NamedAreaSearchForAbbrev);
81
82 overrideShowIdInSelectionDialog = PreferencesUtil.getOverrideForPreference(PreferencePredicate.ShowIdInSelectionDialog.getKey());
83 overrideSearchForIdentifierAsDefault = PreferencesUtil.getOverrideForPreference(PreferencePredicate.SearchForIdentifierAsDefault.getKey());
84 overrideSearchForIdentifierAndTitleCache = PreferencesUtil.getOverrideForPreference(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey());
85 overrideSortTaxaByRankAndName = PreferencesUtil.getOverrideForPreference(PreferencePredicate.SortTaxaByRankAndName.getKey());
86 overrideFilterCommonNameReferences = PreferencesUtil.getOverrideForPreference(PreferencePredicate.CommonNameReferencesWithMarker.getKey());
87 overrideSearchNamedAreasByAbbrev = PreferencesUtil.getOverrideForPreference(PreferencePredicate.NamedAreaSearchForAbbrev.getKey());
88
89 if(overrideShowIdInSelectionDialog){
90 showIdInSelectionDialog = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSelectionDialog.getKey(), true);
91 }
92 if(overrideSearchForIdentifierAsDefault){
93 searchForIdentifierAsDefault = PreferencesUtil.getBooleanValue(PreferencePredicate.SearchForIdentifierAsDefault.getKey(), true);
94 }
95 if(overrideSearchForIdentifierAndTitleCache){
96 searchForIdentifierAndTitleCache = PreferencesUtil.getBooleanValue(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey(), true);
97 }
98 if(overrideSortTaxaByRankAndName){
99 sortTaxaByRankAndName = PreferencesUtil.getBooleanValue(PreferencePredicate.SortTaxaByRankAndName.getKey(), true);
100 }
101 if(overrideFilterCommonNameReferences){
102 filterCommonNameReferences = PreferencesUtil.getBooleanValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey(), true);
103 }
104 if(overrideSearchNamedAreasByAbbrev){
105 String stringValue = PreferencesUtil.getStringValue(PreferencePredicate.NamedAreaSearchForAbbrev.getKey(), true);
106 searchNamedAreasByAbbrev = stringValue != null? NamedAreaSearchField.byKey(stringValue):null;
107 }
108
109
110
111 }
112
113
114
115 @Override
116 public void widgetSelected(SelectionEvent e) {
117 setApply(true);
118 if (e.getSource().equals(this.showIdInSelectionDialogButton)) {
119 String text = showIdInSelectionDialogButton.getText();
120 if(text.startsWith(Messages.Preference_Use_Default)){
121 showIdInSelectionDialog = null;
122 return;
123 }
124
125 if (text.equals(Messages.GeneralPreference_yes)){
126 showIdInSelectionDialog = true;
127 }else{
128 showIdInSelectionDialog = false;
129 }
130 }
131
132 if (e.getSource().equals(this.searchForIdentifierAsDefaultButton)) {
133 String text = searchForIdentifierAsDefaultButton.getText();
134 if(text.startsWith(Messages.Preference_Use_Default)){
135 searchForIdentifierAsDefault = null;
136 return;
137 }
138
139 if (text.equals(Messages.GeneralPreference_yes)){
140 searchForIdentifierAsDefault = true;
141 }else{
142 searchForIdentifierAsDefault = false;
143 }
144 }
145
146 if (e.getSource().equals(this.searchForIdentifierAndTitleCacheButton)) {
147 String text = searchForIdentifierAndTitleCacheButton.getText();
148 if(text.startsWith(Messages.Preference_Use_Default)){
149 searchForIdentifierAndTitleCache = null;
150 return;
151 }
152
153 if (text.equals(Messages.GeneralPreference_yes)){
154 searchForIdentifierAndTitleCache = true;
155 }else{
156 searchForIdentifierAndTitleCache = false;
157 }
158 }
159
160 if (e.getSource().equals(this.sortTaxaByRankAndNameButton)) {
161 String text = sortTaxaByRankAndNameButton.getText();
162 if(text.startsWith(Messages.Preference_Use_Default)){
163 sortTaxaByRankAndName = null;
164 return;
165 }
166
167 if (text.equals(Messages.GeneralPreference_yes)){
168 sortTaxaByRankAndName = true;
169 }else{
170 sortTaxaByRankAndName = false;
171 }
172 }
173
174 if (e.getSource().equals(this.filterCommonNameReferenceButton)) {
175 String text = filterCommonNameReferenceButton.getText();
176 if(text.startsWith(Messages.Preference_Use_Default)){
177 filterCommonNameReferences = null;
178 return;
179 }
180
181 if (text.equals(Messages.GeneralPreference_yes)){
182 filterCommonNameReferences = true;
183 }else{
184 filterCommonNameReferences = false;
185 }
186 }
187
188 if (e.getSource().equals(this.searchNamedAreasByAbbrevButton)) {
189 String text = searchNamedAreasByAbbrevButton.getText();
190 if(text.startsWith(Messages.Preference_Use_Default)){
191 searchNamedAreasByAbbrev = null;
192 return;
193 }
194 searchNamedAreasByAbbrev = (NamedAreaSearchField) searchNamedAreasByAbbrevButton.getData(text);
195
196 }
197
198
199
200 }
201
202 @Override
203 public void widgetDefaultSelected(SelectionEvent e) {
204 // TODO Auto-generated method stub
205
206 }
207
208 @Override
209 protected Control createContents(Composite parent) {
210 getValues();
211
212 Composite titleComp = createComposite(parent);
213 GridData gridData = createTextGridData();
214
215 Label separator= new Label(titleComp, SWT.HORIZONTAL | SWT.SEPARATOR);
216 separator.setLayoutData(gridData);
217 separator.setVisible(false);
218 showIdInSelectionDialogButton = createBooleanCombo(titleComp, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowIdInSelectionDialog, Messages.DatabasePreferncesPage_Show_Id_In_SelectionDialog, isAdminPreference);
219
220 showIdInSelectionDialogButton.addSelectionListener(this);
221
222 if (!isAdminPreference && showIdInSelectionDialogPref != null){
223 showIdInSelectionDialogButton.setEnabled(showIdInSelectionDialogPref.isAllowOverride());
224 }
225
226 if (isAdminPreference){
227 allowOverrideIsShowIdInSelectionDialogButton = createAllowOverrideButton(titleComp);
228 allowOverrideIsShowIdInSelectionDialogButton.setSelection(showIdInSelectionDialogPref != null? showIdInSelectionDialogPref.isAllowOverride(): true);
229 allowOverrideIsShowIdInSelectionDialogButton.addSelectionListener(new SelectionAdapter(){
230 @Override
231 public void widgetSelected(SelectionEvent e) {
232 setApply(true);
233 if (showIdInSelectionDialogPref == null){
234 showIdInSelectionDialogPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSelectionDialog, null);
235 }
236 showIdInSelectionDialogPref.setAllowOverride(allowOverrideIsShowIdInSelectionDialogButton.getSelection());
237 }
238 });
239 }
240
241 Composite composite = createComposite(parent);
242 //composite.setEnabled(isShowSpecimenRelatedIssues);
243 gridData = createTextGridData();
244
245 separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
246 separator.setLayoutData(gridData);
247
248 searchForIdentifierAsDefaultButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SearchForIdentifierAsDefault, Messages.DatabasePreferncesPage_Search_for_identifier_as_default, isAdminPreference);
249
250 searchForIdentifierAsDefaultButton.addSelectionListener(this);
251
252 if (isAdminPreference){
253 allowOverrideSearchForIdentifierAsDefaultButton = createAllowOverrideButton(composite);
254 allowOverrideSearchForIdentifierAsDefaultButton.setSelection(searchForIdentifierAsDefaultPref != null?searchForIdentifierAsDefaultPref.isAllowOverride(): true);
255 allowOverrideSearchForIdentifierAsDefaultButton.addSelectionListener(new SelectionAdapter(){
256 @Override
257 public void widgetSelected(SelectionEvent e) {
258 setApply(true);
259 if (searchForIdentifierAsDefaultPref == null && !allowOverrideSearchForIdentifierAsDefaultButton.getSelection()){
260 searchForIdentifierAsDefaultPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAsDefault, null);
261 }
262 searchForIdentifierAsDefaultPref.setAllowOverride(allowOverrideSearchForIdentifierAsDefaultButton.getSelection());
263 }
264 });
265 }
266 if(!isAdminPreference && searchForIdentifierAsDefaultPref != null){
267 searchForIdentifierAsDefaultButton.setEnabled(searchForIdentifierAsDefaultPref.isAllowOverride());
268 }
269
270 searchForIdentifierAndTitleCacheButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SearchForIdentifierAndTitleCache, Messages.DatabasePreferncesPage_search_for_identifier_and_titleCache, isAdminPreference);
271 searchForIdentifierAndTitleCacheButton.addSelectionListener(this);
272
273 if(!isAdminPreference && searchForIdentifierAndTitleCachePref != null){
274 searchForIdentifierAndTitleCacheButton.setEnabled(searchForIdentifierAndTitleCachePref.isAllowOverride());
275 }
276
277 if (isAdminPreference){
278 allowOverridesSearchForIdentifierAndTitleCacheButton = createAllowOverrideButton(composite);
279 allowOverridesSearchForIdentifierAndTitleCacheButton.setSelection(searchForIdentifierAndTitleCachePref != null?searchForIdentifierAndTitleCachePref.isAllowOverride():true);
280 allowOverridesSearchForIdentifierAndTitleCacheButton.addSelectionListener(new SelectionAdapter(){
281 @Override
282 public void widgetSelected(SelectionEvent e) {
283 setApply(true);
284 if (searchForIdentifierAndTitleCachePref == null && !allowOverridesSearchForIdentifierAndTitleCacheButton.getSelection()){
285 searchForIdentifierAndTitleCachePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAndTitleCache, null);
286 }
287 searchForIdentifierAndTitleCachePref.setAllowOverride(allowOverridesSearchForIdentifierAndTitleCacheButton.getSelection());
288 }
289 });
290 }
291
292 sortTaxaByRankAndNameButton =createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SortTaxaByRankAndName, Messages.DatabasePreferncesPage_Sort_Taxa_By_Name_And_Rank, isAdminPreference);
293
294
295 sortTaxaByRankAndNameButton.addSelectionListener(this);
296
297 if ( !isAdminPreference && sortTaxaByRankAndNamePref != null){
298 sortTaxaByRankAndNameButton.setEnabled(sortTaxaByRankAndNamePref.isAllowOverride());
299 }
300
301 if (isAdminPreference){
302 allowOverrideIsSortTaxaByRankAndNameButton = createAllowOverrideButton(composite);
303 allowOverrideIsSortTaxaByRankAndNameButton.setSelection(sortTaxaByRankAndNamePref != null? sortTaxaByRankAndNamePref.isAllowOverride(): true);
304 allowOverrideIsSortTaxaByRankAndNameButton.addSelectionListener(new SelectionAdapter(){
305 @Override
306 public void widgetSelected(SelectionEvent e) {
307 setApply(true);
308 if (sortTaxaByRankAndNamePref == null && !allowOverrideIsSortTaxaByRankAndNameButton.getSelection()){
309 sortTaxaByRankAndNamePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SortTaxaByRankAndName, null);
310 }
311 sortTaxaByRankAndNamePref.setAllowOverride(allowOverrideIsSortTaxaByRankAndNameButton.getSelection());
312 }
313 });
314 }
315
316 filterCommonNameReferenceButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.CommonNameReferencesWithMarker, Messages.DatabasePreferncesPage_CommonNameFilter, isAdminPreference);
317 filterCommonNameReferenceButton.addSelectionListener(this);
318
319
320 if (!isAdminPreference && filterCommonNameReferencesPref != null){
321 filterCommonNameReferenceButton.setEnabled(filterCommonNameReferencesPref.isAllowOverride());
322 }
323
324 if (isAdminPreference){
325 allowOverrideFilterCommonNameReferencesButton = createAllowOverrideButton(composite);
326 allowOverrideFilterCommonNameReferencesButton.setSelection(filterCommonNameReferencesPref != null? filterCommonNameReferencesPref.isAllowOverride():true);
327 allowOverrideFilterCommonNameReferencesButton.addSelectionListener(new SelectionAdapter(){
328 @Override
329 public void widgetSelected(SelectionEvent e) {
330 setApply(true);
331 if (filterCommonNameReferencesPref == null && !allowOverrideFilterCommonNameReferencesButton.getSelection()){
332 filterCommonNameReferencesPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameReferencesWithMarker, null);
333 }
334 filterCommonNameReferencesPref.setAllowOverride(allowOverrideFilterCommonNameReferencesButton.getSelection());
335 }
336 });
337 }
338
339 searchNamedAreasByAbbrevButton = createCombo(composite, NamedAreaSearchField.values(), PreferencePredicate.NamedAreaSearchForAbbrev, Messages.DatabasePreferncesPage_NamedAreaSearchField, isAdminPreference);
340 searchNamedAreasByAbbrevButton.addSelectionListener(this);
341
342
343 if (!isAdminPreference && searchNamedAreasByAbbrevPref != null){
344 searchNamedAreasByAbbrevButton.setEnabled(searchNamedAreasByAbbrevPref.isAllowOverride());
345 }
346
347 if (isAdminPreference){
348 allowOverridesearchNamedAreasByAbbrevButton = createAllowOverrideButton(composite);
349 allowOverridesearchNamedAreasByAbbrevButton.setSelection(searchNamedAreasByAbbrevPref != null? searchNamedAreasByAbbrevPref.isAllowOverride():true);
350 allowOverridesearchNamedAreasByAbbrevButton.addSelectionListener(new SelectionAdapter(){
351 @Override
352 public void widgetSelected(SelectionEvent e) {
353 setApply(true);
354 if (searchNamedAreasByAbbrevPref == null && !allowOverridesearchNamedAreasByAbbrevButton.getSelection()){
355 searchNamedAreasByAbbrevPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.NamedAreaSearchForAbbrev, null);
356 }
357 searchNamedAreasByAbbrevPref.setAllowOverride(allowOverridesearchNamedAreasByAbbrevButton.getSelection());
358 }
359 });
360 }
361
362 setSelections();
363
364 return composite;
365 }
366
367 @Override
368 protected void performDefaults() {
369 showIdInSelectionDialogButton.select(0);
370 showIdInSelectionDialog = null;
371 if (isAdminPreference){
372 allowOverrideIsShowIdInSelectionDialogButton.setSelection(true);
373 showIdInSelectionDialogPref.setAllowOverride(true);
374 }
375 searchForIdentifierAsDefaultButton.select(0);
376 searchForIdentifierAsDefault = null;
377 if (isAdminPreference){
378 allowOverrideSearchForIdentifierAsDefaultButton.setSelection(true);
379 searchForIdentifierAsDefaultPref.setAllowOverride(true);
380 }
381 searchForIdentifierAndTitleCacheButton.select(0);
382 searchForIdentifierAndTitleCache = null;
383 if (isAdminPreference){
384 allowOverridesSearchForIdentifierAndTitleCacheButton.setSelection(true);
385 searchForIdentifierAndTitleCachePref.setAllowOverride(true);
386 }
387 sortTaxaByRankAndNameButton.select(0);
388 sortTaxaByRankAndName = null;
389 if (isAdminPreference){
390 allowOverrideIsSortTaxaByRankAndNameButton.setSelection(true);
391 sortTaxaByRankAndNamePref.setAllowOverride(true);
392 }
393 filterCommonNameReferenceButton.select(0);
394 filterCommonNameReferences = null;
395 if (isAdminPreference){
396 allowOverrideFilterCommonNameReferencesButton.setSelection(true);
397 filterCommonNameReferencesPref.setAllowOverride(true);
398 }
399 searchNamedAreasByAbbrevButton.select(0);
400 searchNamedAreasByAbbrev = null;
401 if (isAdminPreference){
402 allowOverridesearchNamedAreasByAbbrevButton.setSelection(true);
403 searchNamedAreasByAbbrevPref.setAllowOverride(true);
404 }
405 setApply(true);
406 }
407
408 @Override
409 public boolean performOk(){
410 if (!isApply()){
411 return true;
412 }
413 boolean override = false;
414 if (showIdInSelectionDialog != null ) {
415 override = true;
416 PreferencesUtil.setStringValue(PreferencePredicate.ShowIdInSelectionDialog.getKey(), showIdInSelectionDialog.toString());
417 }
418 PreferencesUtil.setBooleanValue(
419 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSelectionDialog.getKey()),
420 override);
421
422 override = false;
423
424 if(searchForIdentifierAsDefault != null){
425 override = true;
426 PreferencesUtil.setStringValue(PreferencePredicate.SearchForIdentifierAsDefault.getKey(), searchForIdentifierAsDefault.toString());
427 }
428 PreferencesUtil.setBooleanValue(
429 PreferencesUtil.prefOverrideKey(PreferencePredicate.SearchForIdentifierAsDefault.getKey()),
430 override);
431 override = false;
432
433 if(searchForIdentifierAndTitleCache != null){
434 override = true;
435 PreferencesUtil.setStringValue(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey(), searchForIdentifierAndTitleCache.toString());
436 }
437 PreferencesUtil.setBooleanValue(
438 PreferencesUtil.prefOverrideKey(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey()),
439 override);
440 override = false;
441
442 if(sortTaxaByRankAndName != null){
443 override = true;
444 PreferencesUtil.setStringValue(PreferencePredicate.SortTaxaByRankAndName.getKey(), sortTaxaByRankAndName.toString());
445 }
446 PreferencesUtil.setBooleanValue(
447 PreferencesUtil.prefOverrideKey(PreferencePredicate.SortTaxaByRankAndName.getKey()),
448 override);
449 override = false;
450
451
452 if(filterCommonNameReferences != null){
453 override = true;
454 PreferencesUtil.setStringValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey(), filterCommonNameReferences.toString());
455 }
456 PreferencesUtil.setBooleanValue(
457 PreferencesUtil.prefOverrideKey(PreferencePredicate.CommonNameReferencesWithMarker.getKey()),
458 override);
459 override = false;
460
461 if(searchNamedAreasByAbbrev != null){
462 override = true;
463 PreferencesUtil.setStringValue(PreferencePredicate.NamedAreaSearchForAbbrev.getKey(), searchNamedAreasByAbbrev.getKey());
464 }
465 PreferencesUtil.setBooleanValue(
466 PreferencesUtil.prefOverrideKey(PreferencePredicate.NamedAreaSearchForAbbrev.getKey()),
467 override);
468
469
470
471 return true;
472 }
473
474 protected void setSelections(){
475
476 int index = 0;
477 for (String itemLabel : showIdInSelectionDialogButton.getItems()) {
478 if (itemLabel.startsWith(Messages.Preference_Use_Default) && (showIdInSelectionDialog == null || (!overrideShowIdInSelectionDialog && !isAdminPreference))) {
479 showIdInSelectionDialogButton.select(index);
480 break;
481 }
482 if (itemLabel.equals(Messages.GeneralPreference_yes) && showIdInSelectionDialog){
483 showIdInSelectionDialogButton.select(index);
484 break;
485 }
486 if (itemLabel.equals(Messages.GeneralPreference_no) && !showIdInSelectionDialog){
487 showIdInSelectionDialogButton.select(index);
488 break;
489 }
490 index++;
491 }
492
493 index = 0;
494 for (String itemLabel : searchForIdentifierAsDefaultButton.getItems()) {
495 if ((searchForIdentifierAsDefault == null || (!overrideSearchForIdentifierAsDefault && !isAdminPreference)) && itemLabel.startsWith(Messages.Preference_Use_Default)) {
496 searchForIdentifierAsDefaultButton.select(index);
497 break;
498 }
499 if (searchForIdentifierAsDefault != null && itemLabel.equals(Messages.GeneralPreference_yes) && searchForIdentifierAsDefault){
500 searchForIdentifierAsDefaultButton.select(index);
501 break;
502 }
503 if (searchForIdentifierAsDefault != null && itemLabel.equals(Messages.GeneralPreference_no) && !searchForIdentifierAsDefault){
504 searchForIdentifierAsDefaultButton.select(index);
505 break;
506 }
507 index++;
508 }
509
510 index = 0;
511 for (String itemLabel : searchForIdentifierAndTitleCacheButton.getItems()) {
512 if ((searchForIdentifierAndTitleCache == null || (!overrideSearchForIdentifierAndTitleCache && !isAdminPreference))&& itemLabel.startsWith(Messages.Preference_Use_Default)) {
513 searchForIdentifierAndTitleCacheButton.select(index);
514 break;
515 }
516 if (searchForIdentifierAndTitleCache != null && itemLabel.equals(Messages.GeneralPreference_yes) && searchForIdentifierAndTitleCache){
517 searchForIdentifierAndTitleCacheButton.select(index);
518 break;
519 }
520 if (searchForIdentifierAndTitleCache != null && itemLabel.equals(Messages.GeneralPreference_no) && !searchForIdentifierAndTitleCache){
521 searchForIdentifierAndTitleCacheButton.select(index);
522 break;
523 }
524 index++;
525 }
526
527 index = 0;
528 for (String itemLabel : sortTaxaByRankAndNameButton.getItems()) {
529 if ((sortTaxaByRankAndName == null || (!overrideSortTaxaByRankAndName && !isAdminPreference))&& itemLabel.startsWith(Messages.Preference_Use_Default)) {
530 sortTaxaByRankAndNameButton.select(index);
531 break;
532 }
533 if (sortTaxaByRankAndName != null && itemLabel.equals(Messages.GeneralPreference_yes) && sortTaxaByRankAndName){
534 sortTaxaByRankAndNameButton.select(index);
535 break;
536 }
537 if (sortTaxaByRankAndName != null && itemLabel.equals(Messages.GeneralPreference_no) && !sortTaxaByRankAndName){
538 sortTaxaByRankAndNameButton.select(index);
539 break;
540 }
541 index++;
542 }
543
544 index = 0;
545 for (String itemLabel: filterCommonNameReferenceButton.getItems()) {
546 if ((filterCommonNameReferences == null || (!overrideFilterCommonNameReferences && !isAdminPreference)) && itemLabel.startsWith(Messages.Preference_Use_Default)) {
547 filterCommonNameReferenceButton.select(index);
548 break;
549 }
550 if (filterCommonNameReferences != null && itemLabel.equals(Messages.GeneralPreference_yes) && filterCommonNameReferences){
551 filterCommonNameReferenceButton.select(index);
552 break;
553 }
554 if (filterCommonNameReferences != null && itemLabel.equals(Messages.GeneralPreference_no) && !filterCommonNameReferences){
555 filterCommonNameReferenceButton.select(index);
556 break;
557 }
558 index++;
559 }
560 index = 0;
561 for (String itemLabel: searchNamedAreasByAbbrevButton.getItems()) {
562 if ((searchNamedAreasByAbbrev == null || (!overrideSearchNamedAreasByAbbrev && !isAdminPreference)) && itemLabel.startsWith(Messages.Preference_Use_Default)) {
563 searchNamedAreasByAbbrevButton.select(index);
564 break;
565 }
566
567
568 if (searchNamedAreasByAbbrev != null && itemLabel.equals(searchNamedAreasByAbbrev.getLabel())){
569 searchNamedAreasByAbbrevButton.select(index);
570 break;
571 }
572
573 index++;
574 }
575 }
576
577
578 }