Project

General

Profile

« Previous | Next » 

Revision a51915c2

Added by Katja Luther over 5 years ago

ref #7849: handle exception if value of preference not in Enum for areaDisplay

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java
36 36

  
37 37
    protected boolean isEditorActivated;
38 38
    protected boolean allowOverrideActivated;
39
    protected boolean overrideActivated;
39 40
    boolean isUseLocal;
40 41
    protected boolean isShowRank;
41 42
    protected boolean isSortByVocabularyOrder;
42 43
    protected String displayStatus;
43 44
    protected String displayArea;
44
    protected boolean allowOverrideStatus;
45
    protected boolean ownDescriptionForDistributionEditor;
46
    protected boolean allowOverrideOwnDescriptionForDistributionEditor;
47
    protected boolean overrideOwnDescriptionForDistributionEditor;
48
    protected boolean allowOverrideAreaVoc;
49
    protected boolean overrideAreaVoc;
45 50
    protected boolean allowOverrideRank;
51
    protected boolean overrideRank;
46 52
    protected boolean allowOverrideOrderAreas;
53
    protected boolean overrideOrderAreas;
47 54
    protected boolean allowOverrideAreaDisplay;
55
    protected boolean overrideAreaDisplay;
48 56
    protected boolean allowOverrideStatusDisplay;
57
    protected boolean overrideStatusDisplay;
49 58
    Combo statusDisplaySelectionCombo;
50 59
    Combo areaDisplaySelectionCombo;
51 60

  
......
72 81
                @Override
73 82
                public void widgetSelected(SelectionEvent e) {
74 83
                    isEditorActivated = activateCheckButton.getSelection();
84
                    if(!isAdminPreference){
85
                        overrideActivated = true;
86
                    }
75 87

  
76 88
                    if(isEditorActivated){
77 89
                        child.setVisible(true);
......
120 132
            activateRankButton.addSelectionListener(new SelectionAdapter(){
121 133
                @Override
122 134
                public void widgetSelected(SelectionEvent e) {
135
                    if(!isAdminPreference){
136
                        overrideRank = true;
137
                    }
123 138
                    isShowRank = activateRankButton.getSelection();
124 139
                }
125 140
            });
......
147 162
            sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
148 163
                @Override
149 164
                public void widgetSelected(SelectionEvent e) {
165
                    if(!isAdminPreference){
166
                        overrideOrderAreas = true;
167
                    }
150 168
                    isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
151 169
                 }
152 170
            });
......
167 185
                }
168 186
            }
169 187

  
188
            final Button ownDescription = new Button(child, SWT.CHECK);
189
            ownDescription.setText(Messages.ChecklistEditorGeneralPreference_own_Description);
190
            ownDescription.setToolTipText(Messages.ChecklistEditorGeneralPreference_own_Description);
191
            ownDescription.setSelection(ownDescriptionForDistributionEditor);
192
            ownDescription.addSelectionListener(new SelectionAdapter(){
193
                @Override
194
                public void widgetSelected(SelectionEvent e) {
195
                    if(!isAdminPreference){
196
                        overrideOwnDescriptionForDistributionEditor = true;
197
                    }
198
                    ownDescriptionForDistributionEditor = ownDescription.getSelection();
199
                 }
200
            });
201

  
202
            if (isAdminPreference){
203
                Button allowOverrideDescription = createAllowOverrideButton(child);
204
                allowOverrideDescription.setSelection(allowOverrideOwnDescriptionForDistributionEditor);
205

  
206
                allowOverrideDescription.addSelectionListener(new SelectionAdapter(){
207
                    @Override
208
                    public void widgetSelected(SelectionEvent e) {
209
                        allowOverrideOwnDescriptionForDistributionEditor = allowOverrideDescription.getSelection();
210
                    }
211
                });
212
            }else{
213
                if (!allowOverrideOwnDescriptionForDistributionEditor){
214
                    ownDescription.setEnabled(false);
215
                }
216
            }
217

  
218

  
170 219
            separator= new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
171 220
            separator.setLayoutData(sepGrid);
172 221

  
173
//            final CLabel label = new CLabel(child, SWT.NULL);
174
//            label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);
175
//            label.setLayoutData(textGrid);
176
//
177
//
178
//            final CommandHandlerButton button_openSelectAreas = new CommandHandlerButton(child, SWT.PUSH,
179
//                    commandHandlerString);
180 222
//
181
//            button_openSelectAreas.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
182
//
183
//            if (isAdminPreference){
184
//                createAllowOverrideButton(child);
185
//            }
186

  
187 223

  
188 224
            final CLabel description = new CLabel(child, SWT.NULL);
189 225
            description.setText(Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas);
......
201 237
                areaDisplaySelectionCombo.add(display.getLabel());
202 238
            }
203 239
            int index = 0;
204
            if (PreferencesUtil.getStringValue(IPreferenceKeys.CHECKLIST_AREA_DISPLAY) != null){
205
                TermDisplayEnum areaDisplay = TermDisplayEnum.valueOf(displayArea);
240
            if (PreferencesUtil.getStringValue(EditorPreferencePredicate.DistributionEditorActivated.getKey()) != null){
241
                TermDisplayEnum areaDisplay;
242
                try{
243
                    areaDisplay  = TermDisplayEnum.valueOf(displayArea);
244
                }catch(IllegalArgumentException e){
245
                    areaDisplay = TermDisplayEnum.Title;
246
                }
206 247
                for (String itemLabel : areaDisplaySelectionCombo.getItems()){
207 248
                    if (itemLabel.equalsIgnoreCase(areaDisplay.getLabel())){
208 249
                        areaDisplaySelectionCombo.select(index);
......
270 311
                }
271 312
            }
272 313

  
273
            if (isAdminPreference){
274
                final CLabel labelStatus = new CLabel(child, SWT.NULL);
275
                labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS);
276
                labelStatus.setLayoutData(textGrid);
277

  
278
                final CommandHandlerButton button_openStatusWizard = new CommandHandlerButton(child, SWT.PUSH,
279
                        commandHandlerStringStatus); //$NON-NLS-1$
314
//            if (isAdminPreference){
315
//                final CLabel labelStatus = new CLabel(child, SWT.NULL);
316
//                labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS);
317
//                labelStatus.setLayoutData(textGrid);
318
//
319
//                final CommandHandlerButton button_openStatusWizard = new CommandHandlerButton(child, SWT.PUSH,
320
//                        commandHandlerStringStatus); //$NON-NLS-1$
321
//
322
//                button_openStatusWizard.setText(Messages.Distribution_status_selection);
323
//
324
//            }
280 325

  
281
                button_openStatusWizard.setText(Messages.Distribution_status_selection);
326
            final CLabel label = new CLabel(child, SWT.NULL);
327
            label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);
328
            label.setLayoutData(textGrid);
329
            final CommandHandlerButton button_openSelectAreas = new CommandHandlerButton(child, SWT.PUSH,
330
                      commandHandlerString);
331
            button_openSelectAreas.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
282 332

  
333
            if (isAdminPreference){
334
                createAllowOverrideButton(child);
335
            }else{
336
                if (!allowOverrideAreaVoc){
337
                    button_openSelectAreas.setEnabled(false);
338
                }
283 339
            }
284

  
285
           // PreferencesUtil.recursiveSetEnabled(child, CdmStore.isActive());
340
            // PreferencesUtil.recursiveSetEnabled(child, CdmStore.isActive());
286 341

  
287 342
            if(isEditorActivated){
288 343
                child.setEnabled(true);
......
309 364
    @Override
310 365
    public boolean performOk() {
311 366
        if (isAllowOverride){
312
            PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
367
            PreferencesUtil.setBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey(), isEditorActivated);
368
            PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE, overrideActivated);
313 369
            PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
370
            PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_AREAS_SORTED_BY_IDINVOC_OVERRIDE, overrideOrderAreas);
314 371
            PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
372
            PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_SHOW_RANK_OVERRIDE, overrideRank);
315 373
            PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
374
            PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_DISPLAY_STATUS_OVERRIDE, overrideStatusDisplay);
316 375
            PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);
376
            PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_DISPLAY_AREA_OVERRIDE, overrideAreaDisplay);
377
            PreferencesUtil.setOwnDescriptionForChecklistEditor(ownDescriptionForDistributionEditor);
378
            PreferencesUtil.setBooleanValue(IPreferenceKeys.OWN_DESCRIPTION_OVERRIDE, overrideOwnDescriptionForDistributionEditor);
317 379

  
318 380

  
319 381
        }
......
359 421
    public void init() {
360 422
        isAdminPreference = false;
361 423
        setPreferenceStore(PreferencesUtil.getPreferenceStore());
362
        distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
424
        distributionEditorPref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DistributionEditorActivated);
363 425

  
364 426

  
365 427
        if (distributionEditorPref != null){
366 428
            isAllowOverride = distributionEditorPref.isAllowOverride();
367
            if (isAllowOverride){
368
                isEditorActivated = PreferencesUtil.getBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
429
            boolean test = PreferencesUtil.getBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE);
430
            if (isAllowOverride && PreferencesUtil.getBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE)){
431
                isEditorActivated = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey());
369 432
            }else{
370 433
                isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
371 434
            }
372 435
        }else{
373
            isEditorActivated = PreferencesUtil.getBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
436
            isEditorActivated = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey());
374 437
            isAllowOverride = true;
375 438
        }
376
        CdmPreference prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus);
439
        CdmPreference prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
377 440

  
378
        allowOverrideStatus = prefStatus != null?prefStatus.isAllowOverride():false;
441
        allowOverrideAreaVoc = prefStatus != null?prefStatus.isAllowOverride():false;
379 442

  
380 443
        CdmPreference pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor);
381 444
        if (pref != null){
382 445
            this.allowOverrideAreaDisplay = pref.isAllowOverride();
383 446
            if (allowOverrideAreaDisplay){
384
                displayArea = PreferencesUtil.getStringValue(IPreferenceKeys.CHECKLIST_AREA_DISPLAY);
447
                displayArea = PreferencesUtil.getStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
385 448
            }else{
386 449
                displayArea = pref.getValue();
387 450
            }
388 451
        }else{
389
            displayArea = PreferencesUtil.getStringValue(IPreferenceKeys.CHECKLIST_AREA_DISPLAY);
452
            displayArea = PreferencesUtil.getStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
390 453
            this.allowOverrideAreaDisplay = true;
391 454
        }
392 455

  
......
420 483
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.ShowRankInDistributionEditor);
421 484
        if (pref != null){
422 485

  
423
            this.allowOverrideRank = pref.isAllowOverride();
486
            allowOverrideRank = pref.isAllowOverride();
424 487
            if (allowOverrideRank){
425 488
                isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
426 489
            }else{
......
431 494
            this.allowOverrideRank = true;
432 495
        }
433 496

  
497
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.OwnDescriptionForDistributionEditor);
498
        if (pref != null){
499

  
500
            allowOverrideOwnDescriptionForDistributionEditor = pref.isAllowOverride();
501
            if (allowOverrideOwnDescriptionForDistributionEditor){
502
                ownDescriptionForDistributionEditor = PreferencesUtil.isOwnDescriptionForChecklistEditor();
503
            }else{
504
                ownDescriptionForDistributionEditor = Boolean.valueOf(pref.getValue().toString());
505
            }
506
        }else{
507
            ownDescriptionForDistributionEditor = PreferencesUtil.isShowRankInChecklistEditor();
508
            ownDescriptionForDistributionEditor = true;
509
        }
434 510

  
435 511

  
436 512
        commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler";

Also available in: Unified diff