Project

General

Profile

Revision 8db3ccd6

ID8db3ccd6a1025d030b52a0a3607d3d08fb242195
Parent f4935f27
Child ae2066bc

Added by Katja Luther over 1 year ago

ref #7849: correct enabling of local prefs with no allowOverride and sortOrder for areas in distr. editor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistLabelProvider.java
46 46
import eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4;
47 47
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
48 48
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
49
import eu.etaxonomy.taxeditor.preference.TermOrder;
49 50
import eu.etaxonomy.taxeditor.store.CdmStore;
50 51

  
51 52
/**
......
190 191

  
191 192
            }
192 193

  
193
            if (PreferencesUtil.isSortNamedAreaByOrderInVocabulary()){
194
            String sortOrder = PreferencesUtil.getSortNamedAreasInDistributionEditor();
195
            if (sortOrder.equals(TermOrder.Natural.getKey())){
194 196
                return getTermsOrderedByVocabularyOrder(filteredList);
195
            } else if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
197
            }  else if (sortOrder.equals(TermOrder.IdInVoc.getKey())){
196 198
                return getTermsOrderedByIdInVocabulary(filteredList);
197 199
            }else{
198 200
                return getTermsOrderedByLabels(filteredList, CdmStore.getDefaultLanguage());
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditor.java
96 96
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
97 97
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
98 98
import eu.etaxonomy.taxeditor.preference.Resources;
99
import eu.etaxonomy.taxeditor.preference.TermOrder;
99 100
import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionWizard;
100 101
import eu.etaxonomy.taxeditor.store.CdmStore;
101 102
import eu.etaxonomy.taxeditor.store.StoreUtil;
......
469 470

  
470 471
        button3.setLayoutData(gridData3);
471 472
        button3.setText(Messages.ChecklistEditor_REMOVE_DEFAULT_SOURCE);
473
        button2.setToolTipText(Messages.ChecklistEditor_REMOVE_DEFAULT_SOURCE_TOOLTIP);
472 474
        button3.addSelectionListener(new SelectionAdapter() {
473 475

  
474 476
            @Override
......
657 659
            }
658 660

  
659 661
        }
660

  
661
        if (PreferencesUtil.isSortNamedAreaByOrderInVocabulary()){
662
        String sortOrder = PreferencesUtil.getSortNamedAreasInDistributionEditor();
663
        if (sortOrder.equals(TermOrder.Natural.getKey())){
662 664
            areas =  getTermsOrderedByVocabularyOrder(filteredList);
663
        } else if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
665
        } else if (sortOrder.equals(TermOrder.IdInVoc.getKey())){
664 666
            areas = getTermsOrderedByIdInVocabulary(filteredList);
665 667
        }else{
666 668
            areas =  getTermsOrderedByLabels(filteredList, CdmStore.getDefaultLanguage());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ChecklistEditorGeneralAdminPreference.java
60 60
        pref.setAllowOverride(this.allowOverrideRank);
61 61
        service.set(pref);
62 62

  
63
        pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.AreasSortedByIdInVocabulary, Boolean.toString(isSortByVocabularyOrder));
63
        pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.AreasSortedInDistributionEditor, this.orderAreas);
64 64
        pref.setAllowOverride(this.allowOverrideOrderAreas);
65 65
        service.set(pref);
66 66

  
......
102 102
            this.allowOverrideStatusDisplay = true;
103 103
        }
104 104

  
105
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.AreasSortedByIdInVocabulary);
105
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.AreasSortedInDistributionEditor);
106 106
        if (pref != null){
107
            this.isSortByVocabularyOrder = Boolean.valueOf(pref.getValue().toString());
107
            this.orderAreas = pref.getValue().toString();
108 108
            this.allowOverrideOrderAreas = pref.isAllowOverride();
109 109
        }else{
110
            this.isSortByVocabularyOrder = Boolean.valueOf(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getDefaultValue().toString());
110
            this.orderAreas = EditorPreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString();
111 111
            this.allowOverrideOrderAreas = true;
112 112
        }
113 113

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
600 600

  
601 601
    public static String StageMenuPreferences_choose;
602 602

  
603
    public static String TermOrder_idInVoc;
604
    public static String TermOrder_Title;
605
    public static String TermOrder_natural;
606

  
607
    public static String  ChecklistEditorGeneralPreference_Configure_area_order;
608

  
603 609

  
604 610
    static {
605 611
        // initialize resource bundle
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
469 469

  
470 470
DescriptionPreferences_1=Show vocabulary id for term labels
471 471
SupplementalDataPreferences_0=Show UUID and object ID in supplemental data view
472

  
473
TermOrder_idInVoc=Id in Vocabular
474
TermOrder_Title=Title
475
TermOrder_natural=Natural
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
467 467

  
468 468
DescriptionPreferences_1=Vokabular ID im Label von Termen anzeigen
469 469
SupplementalDataPreferences_0=UUID und Objekt ID unter Zusatzdaten anzeigen
470

  
471
TermOrder_idInVoc=Id im Vokabular
472
TermOrder_Title=Titel
473
TermOrder_natural=Nat?rlich
474

  
475
ChecklistEditorGeneralPreference_Configure_area_order=Sortierung der Areas
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/CdmPreferenceCache.java
134 134
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.ShowRankInDistributionEditor);
135 135
        loadAndPutPreference(controller, key);
136 136

  
137
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.AreasSortedByIdInVocabulary);
137
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.AreasSortedInDistributionEditor);
138 138
        loadAndPutPreference(controller, key);
139 139

  
140 140
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.OwnDescriptionForDistributionEditor);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java
42 42
    protected boolean overrideActivated;
43 43
    boolean isUseLocal;
44 44
    protected boolean isShowRank;
45
    protected boolean isSortByVocabularyOrder;
45
    protected String orderAreas;
46 46
    protected String displayStatus;
47 47
    protected String displayArea;
48 48
    protected boolean ownDescriptionForDistributionEditor;
......
60 60
    protected boolean overrideStatusDisplay;
61 61

  
62 62
    protected boolean allowOverrideStatus;
63
    Combo areaOrderSelectionCombo;
63 64
    Combo statusDisplaySelectionCombo;
64 65
    Combo areaDisplaySelectionCombo;
65 66

  
......
167 168
                    @Override
168 169
                    public void widgetSelected(SelectionEvent e) {
169 170
                        setApply(true);
170
                        overrideRank = allowOverrideRankButton.getSelection();
171
                        overrideRank = !overrideRank;
171 172
                    }
172 173
                });
173
                if (!allowOverrideRank){
174
                    activateRankButton.setEnabled(false);
175
                    allowOverrideRankButton.setEnabled(false);
174

  
175
            }
176

  
177
            final CLabel areaOrderLabel = new CLabel(child, SWT.NULL);
178
            areaOrderLabel.setText(Messages.ChecklistEditorGeneralPreference_Configure_area_order);
179
            areaOrderLabel.setLayoutData(textGrid);
180

  
181

  
182
            GridData gridData = new GridData();
183
            gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
184
            areaOrderSelectionCombo = new Combo(child, SWT.BORDER| SWT.READ_ONLY);
185
            areaOrderSelectionCombo.setLayoutData(gridData);
186

  
187
            for(TermOrder display: TermOrder.values()){
188
                areaOrderSelectionCombo.add(display.getLabel());
189
            }
190
            int index = 0;
191
            if (PreferencesUtil.getStringValue(EditorPreferencePredicate.DistributionEditorActivated.getKey()) != null){
192
                TermOrder areaOrder;
193
                try{
194
                    if (orderAreas != null){
195
                        areaOrder  = TermOrder.valueOf(orderAreas);
196
                    }else{
197
                        areaOrder = TermOrder.IdInVoc;
198
                    }
199
                }catch(IllegalArgumentException e){
200
                    areaOrder = TermOrder.IdInVoc;
201
                }
202
                for (String itemLabel : areaOrderSelectionCombo.getItems()){
203
                    if (itemLabel.equalsIgnoreCase(areaOrder.getLabel())){
204
                        areaOrderSelectionCombo.select(index);
205
                        break;
206
                    }
207
                    index++;
176 208
                }
177 209
            }
210
            areaOrderSelectionCombo.addSelectionListener(this);
178 211

  
179 212

  
180
            final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
181
            sortNamedAreaByVocabularyOrder.setText(Messages.ChecklistEditorGeneralPreference_sort_areas);
182
            sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
183
            sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
184
                @Override
185
                public void widgetSelected(SelectionEvent e) {
186
                    setApply(true);
187
                    isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
188
                 }
189
            });
213

  
214
//            final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
215
//            sortNamedAreaByVocabularyOrder.setText(Messages.ChecklistEditorGeneralPreference_sort_areas);
216
//            sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
217
//            sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
218
//                @Override
219
//                public void widgetSelected(SelectionEvent e) {
220
//                    setApply(true);
221
//                    isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
222
//                 }
223
//            });
190 224
            Button allowOverrideOrderAreasButton = createAllowOverrideButton(child);
191 225
            if (isAdminPreference){
192 226
                allowOverrideOrderAreasButton.setSelection(allowOverrideOrderAreas);
......
206 240
                        overrideOrderAreas = allowOverrideOrderAreasButton.getSelection();
207 241
                    }
208 242
                });
209
                if (!allowOverrideOrderAreas){
210
                    sortNamedAreaByVocabularyOrder.setEnabled(false);
211
                    allowOverrideOrderAreasButton.setEnabled(false);
212
                }
243

  
213 244
            }
214 245

  
215 246
//            final Button ownDescription = new Button(child, SWT.CHECK);
......
258 289
            description.setText(Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas);
259 290
            description.setLayoutData(textGrid);
260 291

  
261
            GridData gridData = new GridData();
262
            gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
292

  
263 293
            //gridData.horizontalIndent = 5;
264 294

  
265 295

  
......
269 299
            for(TermDisplayEnum display: TermDisplayEnum.values()){
270 300
                areaDisplaySelectionCombo.add(display.getLabel());
271 301
            }
272
            int index = 0;
302
            index = 0;
273 303
            if (PreferencesUtil.getStringValue(EditorPreferencePredicate.DistributionEditorActivated.getKey()) != null){
274 304
                TermDisplayEnum areaDisplay;
275 305
                try{
......
412 442
                if (!allowOverrideStatus){
413 443
                    button_openStatusWizard.setButtonEnabled(false);
414 444
                }
445
                if (!allowOverrideRank){
446
                    activateRankButton.setEnabled(false);
447
                    allowOverrideRankButton.setEnabled(false);
448
                }
449
                if (!allowOverrideOrderAreas){
450
                    areaOrderSelectionCombo.setEnabled(false);
451
                    allowOverrideOrderAreasButton.setEnabled(false);
452
                }
415 453
             }
416 454
        }
417 455

  
......
434 472

  
435 473
            PreferencesUtil.setBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey(), isEditorActivated);
436 474
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DistributionEditorActivated.getKey()), overrideActivated);
437
            PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
438
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey()), overrideOrderAreas);
475
            PreferencesUtil.setSortNamedAreasInDistributionEditor(orderAreas);
476
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedInDistributionEditor.getKey()), overrideOrderAreas);
439 477
            PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
440 478
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.ShowRankInDistributionEditor.getKey()), overrideRank);
441 479
            PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
......
550 588
            overrideStatusDisplay = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DisplayOfStatus.getKey()));
551 589
        }
552 590

  
553
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.AreasSortedByIdInVocabulary);
591
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.AreasSortedInDistributionEditor);
554 592
        if (pref != null){
555 593

  
556 594
            this.allowOverrideOrderAreas = pref.isAllowOverride();
557 595
            if (allowOverrideOrderAreas){
558
                isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
559
                overrideOrderAreas = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey()));
596
                orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
597
                overrideOrderAreas = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedInDistributionEditor.getKey()));
560 598
            }else{
561
                this.isSortByVocabularyOrder = Boolean.valueOf(pref.getValue().toString());
599
                this.orderAreas = pref.getValue().toString();
562 600
            }
563 601
        }else{
564
            isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
602
            orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
565 603
            this.allowOverrideOrderAreas = true;
566
            overrideOrderAreas = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey()));
604
            overrideOrderAreas = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedInDistributionEditor.getKey()));
567 605
        }
568 606

  
569 607
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.ShowRankInDistributionEditor);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/EditorPreferencePredicate.java
63 63

  
64 64
    //distribution editor
65 65
    DistributionEditorActivated(UUID.fromString("733e9bce-4394-4fae-97d3-1b7dfc48ee3c"), "Distribution Editor Is activated", "distribution.editor.activated",  Boolean.TRUE),
66
    AreasSortedByIdInVocabulary(UUID.fromString("513d7de9-fec4-432c-b4dd-75f9f6e74ad0"), "Distribution Editor: Areas sorted by ID in Vocabulary", "distribution.editor.areas.sortedByIDInVoc", Boolean.FALSE),  //unsure about correct default value, please decide
66
    AreasSortedInDistributionEditor(UUID.fromString("513d7de9-fec4-432c-b4dd-75f9f6e74ad0"), "Distribution Editor: Areas sorted in Distribution Editor", "distribution.editor.areas.sortedInDistributionEditor", TermOrder.IdInVoc),  //unsure about correct default value, please decide
67 67
    //the following 4 should be replaced by termLabelPreferenceEnum , enum should contain label, abbrevLabel, idInVoc, symbol1, symbol2, ...
68 68
    DisplayOfStatus(UUID.fromString("1ee6b945-0a81-4f05-b867-f9d105882249"), "Distribution Editor: Display of Status", "distribution.editor.status.display", TermDisplayEnum.Title),
69 69
    DisplayOfAreasInDistributionEditor(UUID.fromString("7b671bba-1b7f-4cb9-bbac-c914518a4bf8"), "Distribution Editor: Display of Areas", "distribution.editor.areas.displayAreas",  TermDisplayEnum.Title),
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NameDetailsViewConfiguration.java
362 362
    public boolean performOk() {
363 363
        if (nameDetailsConfig != null){
364 364
            PreferencesUtil.setStringValue(EditorPreferencePredicate.NameDetailsView.getKey(), nameDetailsConfig.toString());
365
            PreferencesUtil.setBooleanValue(IPreferenceKeys.OVERRIDE_NAME_DETAILS, isOverride);
365 366
        }
366 367

  
367

  
368
        PreferencesUtil.setBooleanValue(IPreferenceKeys.OVERRIDE_NAME_DETAILS, isOverride);
369 368
        return true;
370 369

  
371 370
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
125 125
    public static void setStringValue(String name, String value) {
126 126
        if (value != null){
127 127
            getPreferenceStore().setValue(prefKey(name), value);
128
        }else{
129
            getPreferenceStore().setToDefault(name);
128 130
        }
129 131
    }
130 132

  
......
1633 1635
/**
1634 1636
 * @return
1635 1637
 */
1636
public static boolean isSortNamedAreaByOrderInVocabulary() {
1638
public static String getSortNamedAreasInDistributionEditor() {
1637 1639

  
1638
    return getBooleanValue(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey());
1640
    return getStringValue(EditorPreferencePredicate.AreasSortedInDistributionEditor.getKey());
1639 1641
}
1640 1642

  
1641
public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder) {
1642
    setBooleanValue(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey(), isSortByVocabularyOrder);
1643
public static void setSortNamedAreasInDistributionEditor(String isSortByVocabularyOrder) {
1644
    setStringValue(EditorPreferencePredicate.AreasSortedInDistributionEditor.getKey(), isSortByVocabularyOrder);
1643 1645

  
1644 1646
}
1645 1647

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)