Project

General

Profile

« Previous | Next » 

Revision 63732a7c

Added by Katja Luther almost 5 years ago

ref #8045: further implementation for default/explicit value selection preference pages

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SpecimenOrObservationPreferences.java
37 37
    private static final String LOCAL_SETTINGS_NOT_ALLOWED = Messages.SpecimenOrObservationPreferences_0;
38 38
    private static final String DESCRIPTION = Messages.SpecimenOrObservationPreferences_1;
39 39

  
40
    protected boolean isShowSpecimenRelatedIssues;
40
    protected Boolean isShowSpecimenRelatedIssues;
41 41
    protected boolean allowOverrideShowSpecimenRelatedIssues;
42 42
    protected boolean overrideShowSpecimenRelatedIssues;
43
    protected boolean isShowCollectingAreaInGeneralSection;
43
    protected Boolean isShowCollectingAreaInGeneralSection;
44 44
    protected boolean allowOverrideShowCollectingAreaInGeneralSection;
45 45
    protected boolean overrideShowCollectionAreaInGeneralSection;
46
    protected boolean isDeterminationOnlyForFieldUnits;
46
    protected Boolean isDeterminationOnlyForFieldUnits;
47 47
    protected boolean allowOverrideDeterminationOnlyForFieldUnits;
48 48
    protected boolean overrideDeterminationOnlyForFieldUnits;
49
    protected boolean isShowTaxonAssociation;
49
    protected Boolean isShowTaxonAssociation;
50 50
    protected boolean allowOverrideShowTaxonAssociation;
51 51
    protected boolean overrideShowTaxonAssociation;
52
    protected boolean isShowLifeForm;
52
    protected Boolean isShowLifeForm;
53 53
    protected boolean allowOverrideShowLifeForm;
54 54
    protected boolean overrideShowLifeForm;
55 55
    Composite composite;
......
92 92
        boolean isEditingAllowed = true;
93 93
        if(!isAdminPreference){
94 94
            CdmPreferenceCache cache = CdmPreferenceCache.instance();
95
            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
96
            CdmPreference showSpecimenPref = cache.findBestMatching(key);
95

  
97 96
            if (showSpecimenPref != null){
98 97
                if (!showSpecimenPref.isAllowOverride() ){
99
                    Label label = new Label(parent, SWT.NONE);
100
                    label.setText(LOCAL_SETTINGS_NOT_ALLOWED);
98

  
101 99
                    isEditingAllowed = false;
102 100

  
103 101
                }
104 102
            }
105 103
        }
106

  
107
        Label label = new Label(parent, SWT.NONE);
108
        label.setText(DESCRIPTION);
104
        if (isEditingAllowed){
105
            Label label = new Label(parent, SWT.NONE);
106
            label.setText(DESCRIPTION);
107
        }else{
108
            Label label = new Label(parent, SWT.NONE);
109
            label.setText(LOCAL_SETTINGS_NOT_ALLOWED);
110
            this.noDefaultAndApplyButton();
111
            return parent;
112
        }
109 113
        Composite titleComp = createComposite(parent);
110 114
        GridData gridData = createTextGridData();
111 115

  
......
115 119
        showSpecimenButton = createBooleanCombo(titleComp, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowSpecimen, Messages.DatabasePreferncesPage_Show_Specimen, isAdminPreference);
116 120

  
117 121
        showSpecimenButton.addSelectionListener(this);
118
        if (isShowSpecimenRelatedIssues){
119
            showSpecimenButton.select(0);
120
        }else{
121
            showSpecimenButton.select(1);
122
        int index = 0;
123
        for (String itemLabel : showSpecimenButton.getItems()) {
124
            if (isShowSpecimenRelatedIssues == null && itemLabel.equals(Messages.Preference_Use_Default)) {
125
                showSpecimenButton.select(index);
126
                break;
127
            }
128
            if (isShowSpecimenRelatedIssues != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowSpecimenRelatedIssues){
129
                showSpecimenButton.select(index);
130
                break;
131
            }
132
            if (isShowSpecimenRelatedIssues != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowSpecimenRelatedIssues){
133
                showSpecimenButton.select(index);
134
                break;
135
            }
136
            index++;
122 137
        }
123

  
138
        showSpecimenButton.setEnabled(isEditingAllowed);
124 139

  
125 140
        if (isAdminPreference){
126 141
            allowOverrideIsShowSpecimenRelatedIssuesButton = createAllowOverrideButton(titleComp);
......
144 159
        showCollectingAreaInGeneralSectionButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowCollectingAreasInGeneralSection, Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section, isAdminPreference);
145 160

  
146 161
        showCollectingAreaInGeneralSectionButton.addSelectionListener(this);
147
        if (isShowCollectingAreaInGeneralSection){
148
            showCollectingAreaInGeneralSectionButton.select(0);
149
        }else{
150
            showCollectingAreaInGeneralSectionButton.select(1);
162
        index = 0;
163
        for (String itemLabel : showCollectingAreaInGeneralSectionButton.getItems()) {
164
            if (isShowCollectingAreaInGeneralSection == null && itemLabel.equals(Messages.Preference_Use_Default)) {
165
                showCollectingAreaInGeneralSectionButton.select(index);
166
                break;
167
            }
168
            if (isShowCollectingAreaInGeneralSection != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowCollectingAreaInGeneralSection){
169
                showCollectingAreaInGeneralSectionButton.select(index);
170
                break;
171
            }
172
            if (isShowCollectingAreaInGeneralSection != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowCollectingAreaInGeneralSection){
173
                showCollectingAreaInGeneralSectionButton.select(index);
174
                break;
175
            }
176
            index++;
151 177
        }
152 178
        if (isAdminPreference){
153 179
            allowOverrideShowCollectingAreaButton = createAllowOverrideButton(composite);
......
160 186
                }
161 187
            });
162 188
        }
163

  
189
        if (showCollectingAreaInGeneralSection != null && !showCollectingAreaInGeneralSection.isAllowOverride() ){
190
               isEditingAllowed = false;
191
        }
192
        showCollectingAreaInGeneralSectionButton.setEnabled(isEditingAllowed);
164 193
        determinationOnlyForFieldUnitsButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.DeterminationOnlyForFieldUnits, Messages.DatabasePreferncesPage_Determination_only_for_field_unnits, isAdminPreference);
165 194

  
166 195

  
167 196
        determinationOnlyForFieldUnitsButton.addSelectionListener(this);
168
        if (isDeterminationOnlyForFieldUnits){
169
            determinationOnlyForFieldUnitsButton.select(0);
170
        }else{
171
            determinationOnlyForFieldUnitsButton.select(1);
197
        index = 0;
198
        for (String itemLabel : determinationOnlyForFieldUnitsButton.getItems()) {
199
            if (isDeterminationOnlyForFieldUnits == null && itemLabel.equals(Messages.Preference_Use_Default)) {
200
                determinationOnlyForFieldUnitsButton.select(index);
201
                break;
202
            }
203
            if (isDeterminationOnlyForFieldUnits != null && itemLabel.equals(Messages.GeneralPreference_yes) && isDeterminationOnlyForFieldUnits){
204
                determinationOnlyForFieldUnitsButton.select(index);
205
                break;
206
            }
207
            if (isDeterminationOnlyForFieldUnits != null && itemLabel.equals(Messages.GeneralPreference_no) && !isDeterminationOnlyForFieldUnits){
208
                determinationOnlyForFieldUnitsButton.select(index);
209
                break;
210
            }
211
            index++;
172 212
        }
173

  
213
        if (showDeterminationOnlyForFieldUnits != null && !showDeterminationOnlyForFieldUnits.isAllowOverride() ){
214
            isEditingAllowed = false;
215
        }
216
        determinationOnlyForFieldUnitsButton.setEnabled(isEditingAllowed);
174 217
        if (isAdminPreference){
175 218
            allowOverridesDeterminationOnlyForFieldUnitsButton = createAllowOverrideButton(composite);
176 219
            allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideDeterminationOnlyForFieldUnits);
......
187 230

  
188 231

  
189 232
        showTaxonAssociationButton.addSelectionListener(this);
190
        if (isShowTaxonAssociation){
191
            showTaxonAssociationButton.select(0);
192
        }else{
193
            showTaxonAssociationButton.select(1);
233
        index = 0;
234
        for (String itemLabel : showTaxonAssociationButton.getItems()) {
235
            if (isShowTaxonAssociation == null && itemLabel.equals(Messages.Preference_Use_Default)) {
236
                showTaxonAssociationButton.select(index);
237
                break;
238
            }
239
            if (isShowTaxonAssociation != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowTaxonAssociation){
240
                showTaxonAssociationButton.select(index);
241
                break;
242
            }
243
            if (isShowTaxonAssociation != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowTaxonAssociation){
244
                showTaxonAssociationButton.select(index);
245
                break;
246
            }
247
            index++;
248
        }
249
        if (showTaxonAssociation != null && !showTaxonAssociation.isAllowOverride() ){
250
            isEditingAllowed = false;
194 251
        }
252
        showTaxonAssociationButton.setEnabled(isEditingAllowed);
195 253
        if (isAdminPreference){
196 254
            allowOverrideIsShowTaxonAssociationButton = createAllowOverrideButton(composite);
197 255
            allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowTaxonAssociation);
......
207 265
        showLifeFormButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowLifeForm, Messages.DatabasePreferncesPage_Life_Form, isAdminPreference);
208 266
        showLifeFormButton.addSelectionListener(this);
209 267

  
210
        if (isShowLifeForm){
211
            showLifeFormButton.select(0);
212
        }else{
213
            showLifeFormButton.select(1);
268
        index = 0;
269
        for (String itemLabel: showLifeFormButton.getItems()) {
270
            if (isShowLifeForm == null && itemLabel.equals(Messages.Preference_Use_Default)) {
271
                showLifeFormButton.select(index);
272
                break;
273
            }
274
            if (isShowLifeForm != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowLifeForm){
275
                showLifeFormButton.select(index);
276
                break;
277
            }
278
            if (isShowLifeForm != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowLifeForm){
279
                showLifeFormButton.select(index);
280
                break;
281
            }
282
            index++;
214 283
        }
215

  
284
        if (showLifeForm != null && !showLifeForm.isAllowOverride() ){
285
            isEditingAllowed = false;
286
        }
287
        showLifeFormButton.setEnabled(isEditingAllowed);
216 288
        if (isAdminPreference){
217 289
            allowOverrideShowLifeFormButton = createAllowOverrideButton(composite);
218 290
            allowOverrideShowLifeFormButton.setSelection(allowOverrideShowLifeForm);
......
240 312
    protected void getValues() {
241 313
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
242 314

  
243
        isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey());
315

  
316
        overrideShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(
317
                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true);
318

  
244 319
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
245
        showSpecimenPref = cache.findBestMatching(key);
246
        if (showSpecimenPref == null){
320
        showSpecimenPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSpecimen);
321

  
322

  
323
        if (showSpecimenPref != null) {
324
            if (showSpecimenPref.isAllowOverride() ) {
325
                if (overrideShowSpecimenRelatedIssues){
326
                    isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), true);
327
                }
328
            } else {
329
                isShowSpecimenRelatedIssues = Boolean.valueOf(showSpecimenPref.getValue());
330
            }
331

  
332
        } else {
333
            if(!overrideShowSpecimenRelatedIssues){
334
                isShowSpecimenRelatedIssues = null;
335
            }else{
336
                isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), true);
337
            }
247 338
            showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, PreferencePredicate.ShowSpecimen.getDefaultValue() != null ?  PreferencePredicate.ShowSpecimen.getDefaultValue().toString(): null);
248 339
        }
249
        allowOverrideShowSpecimenRelatedIssues = showSpecimenPref != null ? showSpecimenPref.isAllowOverride():true;
250 340

  
251 341

  
252 342

  
253
        isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
343

  
254 344
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
255
        showCollectingAreaInGeneralSection = cache.findBestMatching(key);
256
        if (showCollectingAreaInGeneralSection == null){
345
        showCollectingAreaInGeneralSection = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
346
        overrideShowCollectionAreaInGeneralSection = PreferencesUtil.getBooleanValue(
347
                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true);
348
        allowOverrideShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSection != null ? showCollectingAreaInGeneralSection.isAllowOverride():true;
349
        if (showCollectingAreaInGeneralSection != null) {
350
            if (showCollectingAreaInGeneralSection.isAllowOverride() ) {
351
                if (overrideShowCollectionAreaInGeneralSection){
352
                    isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
353
                }
354

  
355
            } else {
356
                isShowCollectingAreaInGeneralSection = Boolean.valueOf(showCollectingAreaInGeneralSection.getValue());
357

  
358
            }
359

  
360
        } else {
361
            if(!overrideShowCollectionAreaInGeneralSection){
362
                isShowCollectingAreaInGeneralSection = null;
363
            }else{
364
                isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
365
            }
257 366
            showCollectingAreaInGeneralSection = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue() != null ?  PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue().toString(): null);
258 367
        }
259
        allowOverrideShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSection != null ? showCollectingAreaInGeneralSection.isAllowOverride():true;
260 368

  
261 369

  
262
        isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
263 370
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
264
        showDeterminationOnlyForFieldUnits = cache.findBestMatching(key);
265
        if (showDeterminationOnlyForFieldUnits == null){
371
        showDeterminationOnlyForFieldUnits = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
372
        overrideDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(
373
                PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true);
374
        if (showDeterminationOnlyForFieldUnits != null) {
375
            if (showDeterminationOnlyForFieldUnits.isAllowOverride() ) {
376
                if (overrideDeterminationOnlyForFieldUnits){
377
                    isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
378
                }
379

  
380
            } else {
381
                isDeterminationOnlyForFieldUnits = Boolean.valueOf(showDeterminationOnlyForFieldUnits.getValue());
382

  
383
            }
384

  
385
        } else {
386
            if(!overrideDeterminationOnlyForFieldUnits){
387
                isDeterminationOnlyForFieldUnits = null;
388
            }else{
389
                isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), true);
390
            }
266 391
            showDeterminationOnlyForFieldUnits = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue() != null ?  PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue().toString(): null);
267 392
        }
393

  
268 394
        allowOverrideDeterminationOnlyForFieldUnits = showDeterminationOnlyForFieldUnits != null ? showDeterminationOnlyForFieldUnits.isAllowOverride():true;
269 395

  
270
        isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
396

  
271 397
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
272
        showTaxonAssociation = cache.findBestMatching(key);
273
        if (showTaxonAssociation == null){
398
        showTaxonAssociation = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
399
        overrideShowTaxonAssociation =  PreferencesUtil.getBooleanValue(
400
                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true);
401
        if (showTaxonAssociation != null) {
402
            if (showTaxonAssociation.isAllowOverride() ) {
403
                if (overrideShowTaxonAssociation){
404
                    isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
405
                }
406

  
407
            } else {
408
                isShowTaxonAssociation = Boolean.valueOf(showTaxonAssociation.getValue());
409

  
410
            }
411

  
412
        } else {
413
            if(!overrideShowTaxonAssociation){
414
                isShowTaxonAssociation = null;
415
            }else{
416
                isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey(), true);
417
            }
274 418
            showTaxonAssociation = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, PreferencePredicate.ShowTaxonAssociations.getDefaultValue() != null ?  PreferencePredicate.ShowTaxonAssociations.getDefaultValue().toString(): null);
275 419
        }
420

  
276 421
        allowOverrideShowTaxonAssociation = showTaxonAssociation != null ? showTaxonAssociation.isAllowOverride():true;
277 422

  
278
        isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
423

  
279 424
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
280
        showLifeForm = cache.findBestMatching(key);
281
        if (showLifeForm == null){
425
        showLifeForm = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
426
        overrideShowLifeForm =  PreferencesUtil.getBooleanValue(
427
                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true);
428
        if (showLifeForm != null) {
429
            if (showLifeForm.isAllowOverride() ) {
430
                if (overrideShowLifeForm){
431
                    isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
432
                }
433

  
434
            } else {
435
                isShowLifeForm = Boolean.valueOf(showLifeForm.getValue());
436

  
437
            }
438

  
439
        } else {
440
            if(!overrideShowLifeForm){
441
                isShowLifeForm = null;
442
            }else{
443
                isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey(), true);
444
            }
282 445
            showLifeForm = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, PreferencePredicate.ShowLifeForm.getDefaultValue() != null ?  PreferencePredicate.ShowLifeForm.getDefaultValue().toString(): null);
283 446
        }
447

  
284 448
        allowOverrideShowLifeForm = showLifeForm != null ? showLifeForm.isAllowOverride():true;
285 449

  
286 450

  
......
288 452

  
289 453
    @Override
290 454
    public boolean performOk() {
291
        if (allowOverrideShowSpecimenRelatedIssues){
292
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), isShowSpecimenRelatedIssues);
293
            boolean test = isShowSpecimenRelatedIssues != Boolean.parseBoolean(showSpecimenPref.getValue());
294
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowSpecimen.getKey()), isShowSpecimenRelatedIssues != Boolean.parseBoolean(showSpecimenPref.getValue()));
455

  
456
        boolean override = false;
457
        if (isShowSpecimenRelatedIssues != null ) {
458
            override = true;
459
            PreferencesUtil.setStringValue(PreferencePredicate.ShowSpecimen.getKey(), isShowSpecimenRelatedIssues.toString());
295 460
        }
296
        if (allowOverrideShowCollectingAreaInGeneralSection){
297
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), isShowCollectingAreaInGeneralSection);
298
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), isShowCollectingAreaInGeneralSection != Boolean.parseBoolean(showCollectingAreaInGeneralSection.getValue()));
461
        PreferencesUtil.setBooleanValue(
462
                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()),
463
                override);
464

  
465
        override = false;
466
        if (isShowCollectingAreaInGeneralSection != null ) {
467
            override = true;
468
            PreferencesUtil.setStringValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), isShowCollectingAreaInGeneralSection.toString());
299 469
        }
300
        if (allowOverrideDeterminationOnlyForFieldUnits){
301
            PreferencesUtil.setBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), isDeterminationOnlyForFieldUnits);
302
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), isDeterminationOnlyForFieldUnits != Boolean.parseBoolean(showDeterminationOnlyForFieldUnits.getValue()));
470
        PreferencesUtil.setBooleanValue(
471
                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()),
472
                override);
473

  
474
        override = false;
475
        if (isDeterminationOnlyForFieldUnits != null ) {
476
            override = true;
477
            PreferencesUtil.setStringValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), isDeterminationOnlyForFieldUnits.toString());
303 478
        }
304
        if (allowOverrideShowTaxonAssociation){
305
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey(), isShowTaxonAssociation);
306
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowTaxonAssociations.getKey()), isShowTaxonAssociation != Boolean.parseBoolean(showTaxonAssociation.getValue()));
479
        PreferencesUtil.setBooleanValue(
480
                PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()),
481
                override);
482

  
483
        override = false;
484
        if (isShowTaxonAssociation != null ) {
485
            override = true;
486
            PreferencesUtil.setStringValue(PreferencePredicate.ShowTaxonAssociations.getKey(), isShowTaxonAssociation.toString());
307 487
        }
308
        if (allowOverrideShowLifeForm){
309
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowLifeForm.getKey(), isShowLifeForm);
310
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowLifeForm.getKey()), isShowLifeForm != Boolean.parseBoolean(showLifeForm.getValue()));
488
        PreferencesUtil.setBooleanValue(
489
                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()),
490
                override);
491

  
492
        override = false;
493
        if (isShowLifeForm != null ) {
494
            override = true;
495
            PreferencesUtil.setStringValue(PreferencePredicate.ShowLifeForm.getKey(), isShowLifeForm.toString());
311 496
        }
497
        PreferencesUtil.setBooleanValue(
498
                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()),
499
                override);
500

  
312 501
        return true;
313 502
    }
314 503

  
......
381 570
    @Override
382 571
    public void widgetSelected(SelectionEvent e) {
383 572
       setApply(true);
384
       if (e.getSource().equals(showSpecimenButton)){
573
       if (e.getSource().equals(this.showSpecimenButton)) {
385 574
           String text = showSpecimenButton.getText();
386
           text = text.replace(Messages.Preference_Use_Default, "");
575
           if(text.equals(Messages.Preference_Use_Default)){
576
               isShowSpecimenRelatedIssues = null;
577
               if (isAdminPreference){
578
                   allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(true);
579
               }
580
               return;
581
           }
387 582
           if (text.equals(Messages.GeneralPreference_yes)){
388 583
               isShowSpecimenRelatedIssues = true;
389 584
           }else{
390 585
               isShowSpecimenRelatedIssues = false;
391 586
           }
392 587
       }
393
       if (e.getSource().equals(showCollectingAreaInGeneralSectionButton)){
588

  
589
       if (e.getSource().equals(this.showCollectingAreaInGeneralSectionButton)) {
394 590
           String text = showCollectingAreaInGeneralSectionButton.getText();
395
           text = text.replace(" (Use default)", "");
591
           if(text.equals(Messages.Preference_Use_Default)){
592
               isShowCollectingAreaInGeneralSection = null;
593
               if (isAdminPreference){
594
                   //showCollectingAreaInGeneralSection.setAllowOverride(true);
595
                   allowOverrideShowCollectingAreaButton.setSelection(true);
596
               }
597
               return;
598
           }
396 599
           if (text.equals(Messages.GeneralPreference_yes)){
397 600
               isShowCollectingAreaInGeneralSection = true;
398 601
           }else{
......
400 603
           }
401 604
       }
402 605

  
403
       if (e.getSource().equals(determinationOnlyForFieldUnitsButton)){
606
       if (e.getSource().equals(this.determinationOnlyForFieldUnitsButton)) {
404 607
           String text = determinationOnlyForFieldUnitsButton.getText();
405
           text = text.replace(" (Use default)", "");
608
           if(text.equals(Messages.Preference_Use_Default)){
609
               isDeterminationOnlyForFieldUnits = null;
610
               if (isAdminPreference){
611
                   //showDeterminationOnlyForFieldUnits.setAllowOverride(true);
612
                   allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(true);
613
               }
614
               return;
615
           }
406 616
           if (text.equals(Messages.GeneralPreference_yes)){
407 617
               isDeterminationOnlyForFieldUnits = true;
408 618
           }else{
409 619
               isDeterminationOnlyForFieldUnits = false;
410 620
           }
411 621
       }
412
       if (e.getSource().equals(showTaxonAssociationButton)){
622

  
623
       if (e.getSource().equals(this.showTaxonAssociationButton)) {
413 624
           String text = showTaxonAssociationButton.getText();
414
           text = text.replace(" (Use default)", "");
625
           if(text.equals(Messages.Preference_Use_Default)){
626
               isShowTaxonAssociation = null;
627
               if (isAdminPreference){
628
                   //showTaxonAssociation.setAllowOverride(true);
629
                   allowOverrideIsShowTaxonAssociationButton.setSelection(true);
630
               }
631
               return;
632
           }
415 633
           if (text.equals(Messages.GeneralPreference_yes)){
416 634
               isShowTaxonAssociation = true;
417 635
           }else{
418 636
               isShowTaxonAssociation = false;
419 637
           }
420 638
       }
421
       if (e.getSource().equals(showLifeFormButton)){
639

  
640
       if (e.getSource().equals(this.showLifeFormButton)) {
422 641
           String text = showLifeFormButton.getText();
423
           text = text.replace(" (Use default)", "");
642
           if(text.equals(Messages.Preference_Use_Default)){
643
               isShowLifeForm = null;
644
               if (isAdminPreference){
645
                   //showLifeForm.setAllowOverride(true);
646
                   allowOverrideShowLifeFormButton.setSelection(true);
647
               }
648
               return;
649
           }
424 650
           if (text.equals(Messages.GeneralPreference_yes)){
425 651
               isShowLifeForm = true;
426 652
           }else{
427 653
               isShowLifeForm = false;
428 654
           }
429 655
       }
656

  
430 657
    }
431 658

  
432 659
    /**

Also available in: Unified diff