Project

General

Profile

« Previous | Next » 

Revision d147dfd6

Added by Katja Luther about 4 years ago

ref #8562: continue work on preference pages

View differences:

eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
188 188
command.name.OPEN_REFERENCING_OBJECTS_VIEW = Open Referencing Objects View
189 189
extension.name.1 = Store Workbench Model
190 190
page.name.21 = Distribution Editor
191
page.name.140 = Import/Export
191 192
page.name.40 = ABCD Import
192 193
page.name.41 = ABCD Import Provider
193 194
page.name.42 = Serverside Preferences
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
188 188
command.name.OPEN_REFERENCING_OBJECTS_VIEW = ?ffne Referenzierende Objekte
189 189
extension.name.1 = Store Workbench Model
190 190
page.name.21 = Verbreitungs-Editor
191
page.name.140 = Import/Export
191 192
page.name.40 = ABCD Import
192 193
page.name.41 = Biocase Provider
193 194
page.name.42 = Serverseitige Pr?ferenzen
eu.etaxonomy.taxeditor.store/plugin.xml
387 387
</extension>
388 388
<extension
389 389
      point="eu.etaxonomy.taxeditor.store.preferencePage">
390
<page
390
    <page
391 391
         category="eu.etaxonomy.taxeditor.preferences.general"
392 392
         class="eu.etaxonomy.taxeditor.preference.DebugPreferences"
393 393
         id="eu.etaxonomy.taxeditor.preference.DebugPreferences"
394 394
         name="%page.name.34">
395
   </page>
396
   <page
397
            category="eu.etaxonomy.taxeditor.preferences.general"
398
            class="eu.etaxonomy.taxeditor.preference.AbcdImportPreference"
399
            id="eu.etaxonomy.taxeditor.store.abcdImportPreference"
400
            name="%page.name.40">
401
   </page>
402
   <page
395
    </page>
396
    <page
397
         category="eu.etaxonomy.taxeditor.preferences.general"
398
         class="eu.etaxonomy.taxeditor.preference.IOPreferences"
399
         id="eu.etaxonomy.taxeditor.store.IOPreferences"
400
         name="%page.name.140">
401
    </page>
402
    <page
403
         category="eu.etaxonomy.taxeditor.store.IOPreferences"
404
         class="eu.etaxonomy.taxeditor.preference.AbcdImportPreference"
405
         id="eu.etaxonomy.taxeditor.store.abcdImportPreference"
406
         name="%page.name.40">
407
    </page>
408
    <page
403 409
         category="eu.etaxonomy.taxeditor.store.abcdImportPreference"
404 410
         class="eu.etaxonomy.taxeditor.preference.AbcdImportProvider"
405 411
         id="eu.etaxonomy.taxeditor.store.abcdImportProvider"
406 412
         name="%page.name.41">
407
   </page>
408
   <page
413
    </page>
414
    <page
409 415
         class="eu.etaxonomy.taxeditor.preference.TaxonomicEditorGeneralPreferences"
410 416
         id="eu.etaxonomy.taxeditor.preferences.general"
411 417
         name="%page.name">
412
   </page>
413
   <page
418
    </page>
419
    <page
414 420
         category="eu.etaxonomy.taxeditor.preferences.general"
415 421
         class="eu.etaxonomy.taxeditor.preference.FactualDataPreference"
416 422
         id="eu.etaxonomy.taxeditor.preferences.description"
417 423
         name="%page.name.0">
418
   </page>
424
    </page>
419 425
    <page
420 426
         category="eu.etaxonomy.taxeditor.preference.UIPreferences"
421 427
         class="eu.etaxonomy.taxeditor.preference.DescriptionPreferences"
......
560 566
         id="eu.etaxonomy.taxeditor.preferences.defaultFeatureTreePreferenecs"
561 567
         name="%page.name.22">
562 568
   </page>
563
      <page
564
            category="eu.etaxonomy.taxeditor.preferences.description"
565
            class="eu.etaxonomy.taxeditor.preference.CommonNameVocabularyPreferencePage"
566
            id="eu.etaxonomy.taxeditor.store.vocabularyPreference"
567
            name="%page.name.47">
568
      </page>
569
   <page
570
         category="eu.etaxonomy.taxeditor.preferences.description"
571
         class="eu.etaxonomy.taxeditor.preference.CommonNameVocabularyPreferencePage"
572
         id="eu.etaxonomy.taxeditor.store.vocabularyPreference"
573
         name="%page.name.47">
574
   </page>
569 575
   <page
570 576
         category="eu.etaxonomy.taxeditor.preference.defaultlanguagepditorpreferencePage"
571 577
         class="eu.etaxonomy.taxeditor.preference.LanguageRepresentationPreferencePage"
......
858 864
            id="eu.etaxonomy.taxeditor.store.page2"
859 865
            name="%page.name.43">
860 866
      </page>
861
      <page
867
       <page
862 868
            category="eu.etaxonomy.taxeditor.preferences.general"
869
            class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.IOAdminPreferences"
870
            id="eu.etaxonomy.taxeditor.store.IOPreference"
871
            name="%page.name.140">
872
      </page>
873
      <page
874
            category="eu.etaxonomy.taxeditor.store.IOPreference"
863 875
            class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.AbcdImportAdminPreference"
864 876
            id="eu.etaxonomy.taxeditor.store.abcdImportPreference"
865 877
            name="%page.name.40">
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/GeneralAdminPreferencePage.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
10 10

  
11
import eu.etaxonomy.cdm.api.application.ICdmRepository;
12
import eu.etaxonomy.cdm.api.service.IPreferenceService;
13 11
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
14
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
15 12
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
16
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
17 13
import eu.etaxonomy.taxeditor.preference.GeneralPreferencePage;
18 14
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
19
import eu.etaxonomy.taxeditor.store.CdmStore;
20 15

  
21 16
/**
22 17
 * @author k.luther
......
25 20
 */
26 21
public class GeneralAdminPreferencePage extends GeneralPreferencePage implements IE4AdminPreferencePage {
27 22

  
28
    ICdmRepository controller = null;
23

  
29 24
    CdmPreference isShowSpecimenPref = null;
30 25
    /**
31 26
     * {@inheritDoc}
......
34 29

  
35 30
    @Override
36 31
    public boolean performOk() {
37

  
38 32
        if (!isApply()){
39 33
            return true;
40 34
        }
41
       if (controller != null){
42
           IPreferenceService service = controller.getPreferenceService();
43
           CdmPreference pref;
44
           if (isShowIOMenu == null && isAllowOverrideShowIOMenu){
45
               service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowImportExportMenu));
46
           }else{
47
               pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowImportExportMenu, isShowIOMenu!= null? Boolean.toString(this.isShowIOMenu):null);
48
               pref.setAllowOverride(isAllowOverrideShowIOMenu);
49
               service.set(pref);
50
           }
51

  
52
           if(isShowCheckListPerspective == null && isAllowOverrideShowCheckListPerspective){
53
               service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowChecklistPerspective));
54
           }else{
55
               pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowChecklistPerspective, isShowCheckListPerspective != null?Boolean.toString(this.isShowCheckListPerspective): null);
56
               pref.setAllowOverride(isAllowOverrideShowCheckListPerspective);
57
               service.set(pref);
58
           }
59

  
60

  
61
           PreferencesUtil.updateDBPreferences();
35
        CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowChecklistPerspective, isShowCheckListPerspective!= null? Boolean.toString(this.isShowCheckListPerspective):null);
36
        pref.setAllowOverride(isAllowOverrideShowCheckListPerspective);
37
        PreferencesUtil.setPreferenceToDB(pref);
38
        setApply(false);
39
        return true;
62 40

  
63

  
64
       }
65
       return true;
66 41
   }
67 42
    @Override
68 43
    protected void getValues(){
69 44
        isAdminPreference = true;
70

  
71
        controller = CdmStore.getCurrentApplicationConfiguration();
72
        if (controller != null){
73
          IPreferenceService service = controller.getPreferenceService();
74
          PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowImportExportMenu);
75
          CdmPreference pref = service.find(key);
76
          if (pref != null){
77
              isShowIOMenu = pref.getValue()!= null?Boolean.valueOf(pref.getValue()): null;
78
              isAllowOverrideShowIOMenu = pref.isAllowOverride();
79
          }else{
80
              isShowIOMenu = null;
81
              isAllowOverrideShowIOMenu = true;
82
          }
83

  
84
//          key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowMediaView);
85
//          pref = service.find(key);
86
//          if (pref != null){
87
//              isShowMediaView = Boolean.valueOf(pref.getValue());
88
//              isAllowOverrideShowMediaView = pref.isAllowOverride();
89
//          }else{
90
//              isShowMediaView = Boolean.valueOf(PreferencePredicate.ShowMediaView.getDefaultValue().toString());
91
//              isAllowOverrideShowMediaView = true;
92
//          }
93

  
94
          key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowChecklistPerspective);
95
          pref = service.find(key);
96
          if (pref != null){
97
              isShowCheckListPerspective = pref.getValue()!= null?Boolean.valueOf(pref.getValue()): null;
98
              isAllowOverrideShowCheckListPerspective = pref.isAllowOverride();
99
          }else{
100
              isShowCheckListPerspective = null;
101
              isAllowOverrideShowCheckListPerspective = true;
102
          }
103

  
104
          key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonNodeWizard);
105
          pref = service.find(key);
106
//          if (pref != null){
107
//              isShowTaxonNodeWizard = pref.getValue() != null?Boolean.valueOf(pref.getValue()): null;
108
//              isAllowOverrideShowTaxonNodeWizard = pref.isAllowOverride();
109
//          }else{
110
//              isShowTaxonNodeWizard = null;
111
//              isAllowOverrideShowTaxonNodeWizard = true;
112
//          }
113
      }
114

  
45
        CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowChecklistPerspective);
46
        if (pref != null){
47
            isShowCheckListPerspective = pref.getValue()!= null?Boolean.valueOf(pref.getValue()): null;
48
            isAllowOverrideShowCheckListPerspective = pref.isAllowOverride();
49
        }else{
50
            isShowCheckListPerspective = null;
51
            isAllowOverrideShowCheckListPerspective = true;
52
        }
115 53
    }
116 54

  
117 55
    @Override
118 56
    protected void performDefaults() {
119
        isShowIOMenu = null;
120 57
        isShowCheckListPerspective = null;
121
        //isShowTaxonNodeWizard = null;
122

  
123

  
124
        isAllowOverrideShowIOMenu = true;
125

  
126

  
127 58
        isAllowOverrideShowCheckListPerspective = true;
128

  
129
        //isAllowOverrideShowTaxonNodeWizard = true;
130 59
        setSelections();
131 60
        super.performDefaults();
132 61
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/IOAdminPreferences.java
1
/**
2
* Copyright (C) 2020 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.databaseAdmin.preferencePage;
10

  
11
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
12
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
13
import eu.etaxonomy.taxeditor.preference.IOPreferences;
14
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
15

  
16
/**
17
 * @author k.luther
18
 * @since 11.02.2020
19
 */
20
public class IOAdminPreferences extends IOPreferences {
21
    @Override
22
    public boolean performOk() {
23
       if (!isApply()){
24
           return true;
25
       }
26
       showIOMenuPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowImportExportMenu, isShowIOMenu!= null? Boolean.toString(this.isShowIOMenu):null);
27
       showIOMenuPref.setAllowOverride(isAllowOverrideShowIOMenu);
28
       PreferencesUtil.setPreferenceToDB(showIOMenuPref);
29
       setApply(false);
30
       return true;
31

  
32
    }
33

  
34
    @Override
35
    protected void getValues(){
36
        isAdminPreference = true;
37
        showIOMenuPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowImportExportMenu);
38
        if (showIOMenuPref != null){
39
              isShowIOMenu = showIOMenuPref.getValue()!= null?Boolean.valueOf(showIOMenuPref.getValue()): null;
40
              isAllowOverrideShowIOMenu = showIOMenuPref.isAllowOverride();
41
          }else{
42
              isShowIOMenu = null;
43
              isAllowOverrideShowIOMenu = true;
44
          }
45
    }
46

  
47
    @Override
48
    protected void performDefaults() {
49
        isShowIOMenu = null;
50
        isAllowOverrideShowIOMenu = true;
51

  
52
        setSelections();
53
        super.performDefaults();
54
    }
55

  
56
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
728 728
    public static String SetAggregationConfiguration_Title;
729 729
    public static String StructuredDescriptionAggregationWizardPage_SELECT_SUBTREE;
730 730
    public static String StructuredDescriptionAggregationWizardPage_TOOLTIP_SELECT_SUBTREE;
731
    public static String CommonNameLanguages_Title;
731 732

  
732 733

  
733 734

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
560 560
AggregationWizardPage_SINGLE_TAXON=Aggregation only for
561 561
SetAggregationConfiguration_Title=Aggregation configuration;
562 562
StructuredDescriptionAggregationWizardPage_SELECT_SUBTREE=Select subtree(s) for aggregation
563
StructuredDescriptionAggregationWizardPage_TOOLTIP_SELECT_SUBTREE=If not all subtrees included in the descriptive data set should be aggregated, select the subtrees for the aggregation
563
StructuredDescriptionAggregationWizardPage_TOOLTIP_SELECT_SUBTREE=If not all subtrees included in the descriptive data set should be aggregated, select the subtrees for the aggregation
564
CommonNameLanguages_Title=Common Name Languages
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
559 559
AggregationWizardPage_SINGLE_TAXON=Aggregation only for 
560 560
SetAggregationConfiguration_Title=Aggregationskonfiguration
561 561
StructuredDescriptionAggregationWizardPage_SELECT_SUBTREE=Select subtree(s) for aggregation
562
StructuredDescriptionAggregationWizardPage_TOOLTIP_SELECT_SUBTREE=If not all subtrees included in the descriptive data set should be aggregated, select the subtrees for the aggregation
562
StructuredDescriptionAggregationWizardPage_TOOLTIP_SELECT_SUBTREE=If not all subtrees included in the descriptive data set should be aggregated, select the subtrees for the aggregation
563
CommonNameLanguages_Title=Sprachen f?r Trivialnamen
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/AbcdImportPreference.java
10 10

  
11 11
import java.net.URI;
12 12

  
13
import org.eclipse.jface.layout.GridLayoutFactory;
13 14
import org.eclipse.swt.SWT;
14 15
import org.eclipse.swt.custom.CLabel;
15 16
import org.eclipse.swt.events.SelectionAdapter;
......
140 141

  
141 142
        GridData gridData = new GridData();
142 143
        gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
143
        gridData.horizontalIndent = 5;
144
        gridData.horizontalIndent = 9;
144 145
        gridData.minimumWidth=100;
145 146
//      classificationSelection.setLayoutData(gridData);
146 147
        Label unitIdLabel = new Label(composite, SWT.NONE);
......
238 239
        Label labelRef = new Label(composite, SWT.NONE);
239 240
        labelRef.setText("Biocase provider for associated DNA");
240 241
        textDNAProviderString = new Combo(composite, SWT.BORDER);
242

  
243
        gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
244
        gridData.horizontalIndent = 9;
245
        gridData.minimumWidth=200;
246

  
247
        textDNAProviderString.setLayoutData(gridData);
248
        GridLayoutFactory.fillDefaults();
241 249
        String biocaseProvider = null;
242 250
        CdmPreference pref = null;
243 251

  
......
253 261
        }
254 262

  
255 263
        textDNAProviderString.setEnabled(true);
256
        textDNAProviderString.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));
264
       // textDNAProviderString.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));
257 265
        textDNAProviderString.addSelectionListener(this);
258 266

  
259 267
        Label nomenclaturalCodeLabel = new Label(composite, SWT.NONE);
260 268
        nomenclaturalCodeLabel.setText("Nomenclatural Code");
261 269
        nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
270
        gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
271
        gridData.horizontalIndent = 9;
262 272
        nomenclaturalCodeSelectionCombo.setLayoutData(gridData);
263

  
273
        GridLayoutFactory.fillDefaults();
264 274
        for(NomenclaturalCode code: NomenclaturalCode.values()){
265 275
            nomenclaturalCodeSelectionCombo.add(code.getKey());
266 276
        }
......
271 281
        }
272 282

  
273 283
        Label sep = new Label(composite, SWT.HORIZONTAL|SWT.SEPARATOR);
274

  
284
        sep.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false));
285
        GridLayoutFactory.fillDefaults();
275 286
        useLocalOrAdmin = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
276 287
        if (!isAdminPreference){
277 288
            useLocalOrAdmin.add(LocalOrDefaultEnum.Default.getLabel(), 0);
......
302 313
        }
303 314
        GridData gridDataLocal = new GridData();
304 315
        gridDataLocal = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
305
        gridDataLocal.horizontalIndent = 9;
316
       // gridDataLocal.horizontalIndent = 9;
306 317
        gridDataLocal.minimumWidth=100;
307 318
        gridDataLocal.widthHint= nomenclaturalCodeSelectionCombo.getBorderWidth();
308 319
        useLocalOrAdmin.setLayoutData(gridDataLocal);
320
        GridLayoutFactory.fillDefaults();
309 321
        setSelections();
310 322

  
311 323
        return composite;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/AbstractGeneralTermPreference.java
67 67

  
68 68
    }
69 69

  
70
    /**
71
     * @param title
72
     */
73
    public AbstractGeneralTermPreference(String title) {
74
        super(title);
75
    }
76

  
70 77
    public boolean isLocalPref() {
71 78
        return !isAdminPreference;
72 79
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java
95 95
        getValues();
96 96
        Composite composite = new Composite(parent, SWT.NULL);
97 97
        composite.setLayout(new GridLayout());
98
        if (!isAdminPreference && distributionEditorPref != null && !distributionEditorPref.isAllowOverride()&& isEditorActivated != null && !isEditorActivated ) {
98
        if (!isAdminPreference && distributionEditorPref != null && !distributionEditorPref.isAllowOverride() ) {
99 99
            Label label = new Label(composite, SWT.NONE);
100 100
            label.setText(
101 101
                    "The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator.");
......
731 731

  
732 732
    @Override
733 733
    protected void performDefaults() {
734
        setApply(true);
735 734

  
735
        setApply(true);
736 736
        isEditorActivated = null;
737 737
        activateCombo.select(0);
738 738

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/DistributionStatusPreferencePage.java
452 452
        if (prefStatus == null){
453 453
            List<CdmPreference> prefsToDelete =cache.getAllForPredicate(PreferencePredicate.AvailableDistributionStatus.getKey());
454 454
            PreferencesUtil.removeFromDB(prefsToDelete);
455
            return true;
455 456
        }
456 457

  
457 458
        List<CdmPreference> toDelete = new ArrayList<>();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/GeneralPreferencePage.java
33 33
 */
34 34
public class GeneralPreferencePage extends CdmPreferencePage implements SelectionListener{
35 35

  
36

  
37
    protected Boolean isShowIOMenu;
38
//    protected boolean isShowMediaView;
39 36
    protected Boolean isShowCheckListPerspective;
40 37

  
41
    protected boolean isAllowOverrideShowIOMenu;
42 38
    protected boolean isAllowOverrideShowMediaView;
43 39
    protected boolean isAllowOverrideShowCheckListPerspective;
44 40

  
45
    protected boolean isOverrideShowIOMenu;
46 41
    protected boolean isOverrideShowMediaView;
47 42
    protected boolean isOverrideShowCheckListPerspective;
48 43

  
49

  
50
    protected Combo showIOMenuButton;
51
    protected Button allowOverrideShowIOMenuButton;
52 44
    protected Combo showChecklistPerspectiveButton;
53 45
    protected Button allowOverrideShowChecklistButton;
54 46

  
55
    final String SHOW = Messages.GeneralPreference_yes;
56
    final String DO_NOT_SHOW = Messages.GeneralPreference_no;
57
    /**
58
     * {@inheritDoc}
59
     */
60 47
    @Override
61 48
    protected Control createContents(Composite parent) {
62 49
        getValues();
......
68 55
        separator.setLayoutData(gridData);
69 56
        separator.setVisible(false);
70 57

  
71
        showIOMenuButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowImportExportMenu, "Show Export/Import Menu",
72
                isAdminPreference);
73

  
74
        showIOMenuButton.addSelectionListener(this);
75

  
76

  
77
        if (isAdminPreference){
78
        allowOverrideShowIOMenuButton = createAllowOverrideButton(composite);
79

  
80

  
81
            allowOverrideShowIOMenuButton.addSelectionListener(new SelectionAdapter(){
82
                @Override
83
                public void widgetSelected(SelectionEvent e) {
84
                    isAllowOverrideShowIOMenu = allowOverrideShowIOMenuButton.getSelection();
85
                    setApply(true);
86
                }
87
            });
88
        }
89 58

  
90 59

  
91 60
        showChecklistPerspectiveButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowChecklistPerspective, "Set Checklist Perspective as Default Perspective",
......
105 74
            });
106 75
        }
107 76

  
108

  
109
        if(!isAdminPreference){
110
            if (!isAllowOverrideShowIOMenu){
111
                showIOMenuButton.setEnabled(false);
112

  
113
            }
114
            if (!isAllowOverrideShowCheckListPerspective){
115
                showChecklistPerspectiveButton.setEnabled(false);
116

  
117
            }
118

  
119
        }
120

  
121 77
        setSelections();
122 78
        return composite;
123 79
    }
......
137 93

  
138 94

  
139 95
        }
140
        if (isAllowOverrideShowIOMenu){
141
            if (isShowIOMenu != null){
142
                PreferencesUtil.setBooleanValue(PreferencePredicate.ShowImportExportMenu.getKey(), isShowIOMenu);
143
            }
144
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), isOverrideShowIOMenu);
145
        }
146

  
147

  
96
        return true;
97
    }
148 98

  
149
       return true;
150
   }
151 99
    @Override
152 100
    protected void getValues(){
153 101
        isAdminPreference = false;
154 102

  
155 103
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
156
        isOverrideShowIOMenu = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), true) != null?
157
                PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), true): false;
158
        if (isOverrideShowIOMenu){
159
            isShowIOMenu = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowImportExportMenu.getKey(), true);
160
        }
161

  
162

  
163
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowImportExportMenu);
164
        CdmPreference pref = cache.findBestMatching(key);
165
        if (pref != null){
166
            isAllowOverrideShowIOMenu = pref.isAllowOverride();
167
        }else{
168
            isAllowOverrideShowIOMenu = true;
169
        }
170

  
171 104
        isOverrideShowCheckListPerspective = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowChecklistPerspective.getKey()), true) != null? PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowChecklistPerspective.getKey()), true): false;
172 105
        if (isOverrideShowCheckListPerspective){
173 106
            isShowCheckListPerspective = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowChecklistPerspective.getKey(), true);
174 107
        }
175 108

  
176

  
177
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowChecklistPerspective);
178
        pref = cache.findBestMatching(key);
109
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowChecklistPerspective);
110
        CdmPreference pref = cache.findBestMatching(key);
179 111
        if (pref != null){
180 112
            isAllowOverrideShowCheckListPerspective = pref.isAllowOverride();
181 113
        }else{
......
185 117

  
186 118
    }
187 119

  
188

  
189

  
190
    /**
191
     * {@inheritDoc}
192
     */
193 120
    @Override
194 121
    public void widgetSelected(SelectionEvent e) {
195

  
196
        if (e.getSource().equals(this.showIOMenuButton)) {
197
            String text = showIOMenuButton.getText();
198
            if (text.startsWith(Messages.Preference_Use_Default)){
199
                isOverrideShowIOMenu = false;
200
                isShowIOMenu = null;
201

  
202
            }else if (text.equals(SHOW)){
203
                isShowIOMenu = true;
204
                isOverrideShowIOMenu = true;
205

  
206
            }else{
207
                isShowIOMenu = false;
208
                isOverrideShowIOMenu = true;
209
            }
210
        }
211 122
        if (e.getSource().equals(this.showChecklistPerspectiveButton)) {
212 123
            String text = showChecklistPerspectiveButton.getText();
213 124
            if (text.startsWith(Messages.Preference_Use_Default)){
......
242 153

  
243 154
    @Override
244 155
    protected void performDefaults() {
245

  
246

  
247 156
        isOverrideShowCheckListPerspective = false;
248 157
        isShowCheckListPerspective = null;
249 158

  
250
        isOverrideShowIOMenu = false;
251
        isShowIOMenu = null;
252 159
        setSelections();
253 160
        setApply(true);
254 161
    }
255 162

  
256 163
    protected void setSelections(){
257
        if (isShowIOMenu == null || (!isOverrideShowIOMenu && !isAdminPreference)){
258
            showIOMenuButton.select(0);
259
//            if (isAdminPreference){
260
//                allowOverrideShowIOMenuButton.setEnabled(false);
261
//            }
262
        }else{
263
//            if (isAdminPreference){
264
//                allowOverrideShowIOMenuButton.setEnabled(true);
265
//            }
266
            if (isShowIOMenu){
267
                showIOMenuButton.select(1);
268
            }else{
269
                showIOMenuButton.select(2);
270
            }
271
        }
272

  
273 164
        if (isShowCheckListPerspective == null || (!isOverrideShowCheckListPerspective && !isAdminPreference)){
274 165
            showChecklistPerspectiveButton.select(0);
275 166
        }else{
......
280 171
            }
281 172
        }
282 173

  
283

  
284

  
285 174
        if (isAdminPreference){
286
            allowOverrideShowIOMenuButton.setSelection(isAllowOverrideShowIOMenu);
287 175
            allowOverrideShowChecklistButton.setSelection(isAllowOverrideShowCheckListPerspective);
288

  
289 176
        }
290 177
    }
291 178

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/GeneralTermPreferencePage.java
25 25
 */
26 26
public class GeneralTermPreferencePage extends AbstractGeneralTermPreference<TermDto> {
27 27

  
28

  
29
    public GeneralTermPreferencePage(String title) {
30
        super(title);
31
    }
32
    public GeneralTermPreferencePage() {
33
        super();
34
    }
35

  
28 36
    @Override
29 37
    protected List<TermDto> getTermsFromStringValues(List<String> listValue) {
30 38
        Collection<TermDto> termlist = new ArrayList<>();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IOPreferences.java
1
/**
2
* Copyright (C) 2020 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.CdmPreference.PrefKey;
24
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
25
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
26
import eu.etaxonomy.taxeditor.l10n.Messages;
27
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
28

  
29
/**
30
 * @author k.luther
31
 * @since 11.02.2020
32
 */
33
public class IOPreferences extends CdmPreferencePage implements SelectionListener {
34

  
35
    protected Boolean isShowIOMenu;
36
    protected CdmPreference showIOMenuPref;
37
    protected boolean isAllowOverrideShowIOMenu;
38
    protected boolean isOverrideShowIOMenu;
39

  
40
    protected Combo showIOMenuButton;
41
    protected Button allowOverrideShowIOMenuButton;
42

  
43
    @Override
44
    protected Control createContents(Composite parent) {
45
        getValues();
46
        final Composite composite = createComposite(parent);
47

  
48
        GridData gridData = createTextGridData();
49
        if (!isAdminPreference && showIOMenuPref != null && !showIOMenuPref.isAllowOverride() ) {
50
            Label label = new Label(composite, SWT.NONE);
51
            label.setText(
52
                    "The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator.");
53
            this.setDefaultButtonActivated(false);
54
        } else {
55
            Label separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
56
            separator.setLayoutData(gridData);
57
            separator.setVisible(false);
58
            showIOMenuButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowImportExportMenu, "Show Export/Import Menu",
59
                    isAdminPreference);
60

  
61
            int index = 0;
62
            for (String itemLabel : showIOMenuButton.getItems()) {
63
                if (isShowIOMenu == null && itemLabel.startsWith(Messages.Preference_Use_Default)) {
64
                    showIOMenuButton.select(index);
65
                    break;
66
                }
67
                if (isShowIOMenu != null && itemLabel.equals(SHOW) && isShowIOMenu){
68
                    showIOMenuButton.select(index);
69
                    break;
70
                }
71
                if (isShowIOMenu != null && itemLabel.equals(DO_NOT_SHOW) && !isShowIOMenu){
72
                    showIOMenuButton.select(index);
73
                    break;
74
                }
75
                index++;
76
            }
77

  
78
            showIOMenuButton.addSelectionListener(this);
79

  
80

  
81
            if (isAdminPreference){
82
                allowOverrideShowIOMenuButton = createAllowOverrideButton(composite);
83
                allowOverrideShowIOMenuButton.addSelectionListener(new SelectionAdapter(){
84
                    @Override
85
                    public void widgetSelected(SelectionEvent e) {
86
                        isAllowOverrideShowIOMenu = allowOverrideShowIOMenuButton.getSelection();
87
                        setApply(true);
88
                    }
89
                });
90
                allowOverrideShowIOMenuButton.setSelection(isAllowOverrideShowIOMenu);
91

  
92
            }
93
            if(!isAdminPreference){
94
                if (!isAllowOverrideShowIOMenu){
95
                    showIOMenuButton.setEnabled(false);
96
                }
97
            }
98
        }
99
        return composite;
100

  
101
    }
102

  
103
    @Override
104
    public boolean performOk() {
105
        if (!isApply()){
106
            return true;
107
        }
108

  
109
        if (isAllowOverrideShowIOMenu){
110
            if (isShowIOMenu != null){
111
                PreferencesUtil.setBooleanValue(PreferencePredicate.ShowImportExportMenu.getKey(), isShowIOMenu);
112
            }
113
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), isOverrideShowIOMenu);
114
        }
115

  
116

  
117

  
118
       return true;
119
   }
120

  
121
    @Override
122
    protected void getValues(){
123
        isAdminPreference = false;
124

  
125
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
126
        isOverrideShowIOMenu = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), true) != null?
127
                PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), true): false;
128
        if (isOverrideShowIOMenu){
129
            isShowIOMenu = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowImportExportMenu.getKey(), true);
130
        }
131

  
132

  
133
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowImportExportMenu);
134
        showIOMenuPref = cache.findBestMatching(key);
135
        if (showIOMenuPref != null){
136
            isAllowOverrideShowIOMenu = showIOMenuPref.isAllowOverride();
137
        }else{
138
            isAllowOverrideShowIOMenu = true;
139
        }
140
    }
141

  
142

  
143
    @Override
144
    public void widgetSelected(SelectionEvent e) {
145
        setApply(true);
146
        if (e.getSource().equals(this.showIOMenuButton)) {
147
            String text = showIOMenuButton.getText();
148
            if (text.startsWith(Messages.Preference_Use_Default)){
149
                isOverrideShowIOMenu = false;
150
                isShowIOMenu = null;
151

  
152
            }else if (text.equals(SHOW)){
153
                isShowIOMenu = true;
154
                isOverrideShowIOMenu = true;
155

  
156
            }else{
157
                isShowIOMenu = false;
158
                isOverrideShowIOMenu = true;
159
            }
160
        }
161
    }
162

  
163
    @Override
164
    protected void performDefaults() {
165
        isOverrideShowIOMenu = false;
166
        isShowIOMenu = null;
167
        setSelections();
168
        setApply(true);
169
    }
170

  
171
    protected void setSelections(){
172
        if (isShowIOMenu == null || (!isOverrideShowIOMenu && !isAdminPreference)){
173
            showIOMenuButton.select(0);
174
        }else{
175
            if (isShowIOMenu){
176
                showIOMenuButton.select(1);
177
            }else{
178
                showIOMenuButton.select(2);
179
            }
180
        }
181
        if (isAdminPreference){
182
            allowOverrideShowIOMenuButton.setSelection(isAllowOverrideShowIOMenu);
183
        }
184
    }
185

  
186
    @Override
187
    public void widgetDefaultSelected(SelectionEvent e) {
188
        // TODO Auto-generated method stub
189

  
190
    }
191

  
192
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ListComponent.java
10 10

  
11 11

  
12 12
import java.awt.Toolkit;
13
import java.io.BufferedReader;
14
import java.io.IOException;
15
import java.io.InputStreamReader;
16
import java.net.HttpURLConnection;
13 17
import java.net.URL;
18
import java.util.ArrayList;
14 19

  
15 20
import javax.swing.event.DocumentEvent;
16 21

  
17 22
import org.apache.commons.lang.StringUtils;
23
import org.eclipse.equinox.internal.p2.ui.misc.StringMatcher;
24
import org.eclipse.jface.fieldassist.ComboContentAdapter;
25
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
26
import org.eclipse.jface.fieldassist.IContentProposal;
27
import org.eclipse.jface.fieldassist.IContentProposalProvider;
18 28
import org.eclipse.jface.resource.JFaceResources;
19 29
import org.eclipse.swt.SWT;
20 30
import org.eclipse.swt.custom.CLabel;
......
25 35
import org.eclipse.swt.graphics.Rectangle;
26 36
import org.eclipse.swt.layout.GridData;
27 37
import org.eclipse.swt.widgets.Button;
38
import org.eclipse.swt.widgets.Combo;
28 39
import org.eclipse.swt.widgets.Composite;
29 40
import org.eclipse.swt.widgets.Display;
30 41
import org.eclipse.swt.widgets.Label;
31 42
import org.eclipse.swt.widgets.List;
32 43
import org.eclipse.swt.widgets.Text;
44
import org.json.JSONArray;
45
import org.json.JSONException;
46
import org.json.JSONObject;
33 47

  
34 48
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
35 49
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
......
51 65
    private static final String noProvider = Messages.ListComponent_NO_PROVIDER_AVAILABLE;
52 66
    private static final String serverSidePreference = "Server Side Preference:";
53 67
    private Button removeButton;
54
    private Text providerURI;
68
    private Combo providerURI;
55 69
    protected Label labelException;
56 70
    boolean isAdmin = false;
57 71
    CdmPreferencePage preferencePage;
58 72
    CdmPreference providerListPreference;
59 73
    String providerList;
74
    String[] items;
60 75

  
61 76

  
62 77
    public CdmPreference getProviderListPreference() {
......
129 144
        list.setLayoutData(dataList);
130 145

  
131 146

  
132
        providerURI = new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
147
        providerURI = new Combo(parent, SWT.BORDER);
148

  
149
        URL url;
150
        String response = null;
151
        try {
152
            url = new URL("https://www.biocase.org/whats_biocase/gbif_biocase.cgi");
153

  
154
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
155
            conn.setRequestProperty("Accept", "application/json");
156
    //        conn.setConnectTimeout(TIMEOUT*9);
157
    //        conn.setReadTimeout(TIMEOUT*9);
158

  
159
            if (conn.getResponseCode() != 200) {
160
                throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
161
            }
162
            BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
163

  
164
            StringBuilder  builder = new StringBuilder();
165
            String line;
166
            while ((line = br.readLine()) != null) {
167
                builder.append(line);
168
            }
169
            conn.disconnect();
170
            response = builder.toString();
171
        } catch (IOException e) {
172
            // TODO Auto-generated catch block
173
            e.printStackTrace();
174
        }
175

  
176
        JSONArray jsonResponseArray;
177
        try {
178
            jsonResponseArray =new JSONArray(response);
179

  
180
            int i = 0;
181
            String service_url = null;
182
            items = new String[jsonResponseArray.length()];
183
            while (i<jsonResponseArray.length()){
184
                JSONObject object = jsonResponseArray.getJSONObject(i);
185
                service_url = (String) object.get("service_url");
186
                if (service_url != null){
187
                    providerURI.add(service_url);
188
                    items[i] = service_url;
189
                }
190
                i++;
191
            }
192

  
193
        } catch (JSONException e) {
194
            // TODO Auto-generated catch block
195
            e.printStackTrace();
196
        }
197

  
198

  
133 199
        GridData dataProviderUri = new GridData();
134 200
        dataProviderUri.horizontalAlignment = GridData.FILL;
135 201
        dataProviderUri.horizontalSpan = 3;
136 202
        providerURI.setLayoutData(dataProviderUri);
137
        providerURI.addModifyListener(this);
203
      //  providerURI.setVisible(false);
204

  
205
        ContentProposalAdapter adapter = new ContentProposalAdapter(providerURI, new ComboContentAdapter(), getProposalProvider(), null, null);
206
        adapter.setPropagateKeys(true);
207
        adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
208
//        String[] proposals = new String[providerURI.getItems().length];
209
//
210
//        for (int i = 0; i < providerURI.getItems().length; i++) {
211
//            proposals[i] = providerURI.getItem(i);
212
//        }
213
//
214
//        ComboViewer comboViewer = new ComboViewer(parent, SWT.NONE);
215
//        comboViewer.setContentProvider(new ArrayContentProvider());
216
//        comboViewer.setLabelProvider(new LabelProvider(){
217
//            @Override
218
//            public String getText(final Object element){
219
//              if(element instanceof String){
220
//                return (String) element;
221
//              }
222
//              return element.toString();
223
//            }
224
//        });
225
//        comboViewer.setInput(proposals);
226
//        // additionally, configure the comboViewer arbitrary
227
//        AutoCompleteField field = new AutoCompleteField(comboViewer.getCombo(), new ComboContentAdapter(), proposals);
228

  
229

  
230

  
231

  
232
        //providerURI.addModifyListener(this);
138 233
        labelException = new Label(parent, SWT.NULL);
139 234
        labelException.setText("");
140 235

  
......
152 247
    }
153 248

  
154 249

  
250
    /**
251
     * @return
252
     */
253
    IContentProposalProvider getProposalProvider() {
254
        return new IContentProposalProvider() {
255
            @Override
256
            public IContentProposal[] getProposals(String contents, int position) {
257
                //String[] items = getStringItems();
258
                if (contents.length() == 0 || items.length == 0) {
259
                    return new IContentProposal[0];
260
                }
261
                StringMatcher matcher = new StringMatcher("*" + contents + "*", true, false); //$NON-NLS-1$ //$NON-NLS-2$
262
                ArrayList<String> matches = new ArrayList<String>();
263
                for (int i = 0; i < items.length; i++) {
264
                    if (matcher.match(items[i])) {
265
                        matches.add(items[i]);
266
                    }
267
                }
268

  
269
                // We don't want to autoactivate if the only proposal exactly matches
270
                // what is in the combo.  This prevents the popup from
271
                // opening when the user is merely scrolling through the combo values or
272
                // has accepted a combo value.
273
                if (matches.size() == 1 && matches.get(0).equals(providerURI.getText())) {
274
                    return new IContentProposal[0];
275
                }
276

  
277
                if (matches.isEmpty()) {
278
                    return new IContentProposal[0];
279
                }
280

  
281
                // Make the proposals
282
                IContentProposal[] proposals = new IContentProposal[matches.size()];
283
                for (int i = 0; i < matches.size(); i++) {
284
                    final String proposal = matches.get(i);
285
                    proposals[i] = new IContentProposal() {
286

  
287
                        @Override
288
                        public String getContent() {
289
                            return proposal;
290
                        }
291

  
292
                        @Override
293
                        public int getCursorPosition() {
294
                            return proposal.length();
295
                        }
296

  
297
                        @Override
298
                        public String getDescription() {
299
                            return null;
300
                        }
301

  
302
                        @Override
303
                        public String getLabel() {
304
                            return null;
305
                        }
306
                    };
307
                }
308
                return proposals;
309
            }
310
        };
311
    }
312

  
155 313
    public boolean isAdmin() {
156 314
        return isAdmin;
157 315
    }
......
276 434
            //User didn't type in a unique name...
277 435
            if (name.equals("") || alreadyInList(name) || !StringUtils.isBlank(labelException.getText())) { //$NON-NLS-1$
278 436
                Toolkit.getDefaultToolkit().beep();
279
                providerURI.selectAll();
437
                //providerURI.selectAll();
280 438
                return;
281 439
            }
282 440

  
......
312 470
        for (String item: list.getItems()){
313 471
            if (item.equals(noProvider) || item.equals(serverSidePreference)){
314 472
                //do nothing
315
            }else if (first || allProviderString == null || allProviderString == ""){ //$NON-NLS-1$
473
            }else if (first || StringUtils.isBlank(allProviderString)){ //$NON-NLS-1$
316 474
                allProviderString = item.trim();
317 475
                first = false;
318 476
            }else {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
57 57
import eu.etaxonomy.cdm.model.description.Feature;
58 58
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
59 59
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
60
import eu.etaxonomy.cdm.model.metadata.IKeyLabel;
61 60
import eu.etaxonomy.cdm.model.metadata.IPreferencePredicate;
62 61
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
63 62
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
......
232 231
        String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
233 232
        boolean override = getPreferenceStore().getBoolean(overrideKey);
234 233

  
235
        if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
234

  
235
        if (local || (pref == null && override)|| (pref != null && pref.isAllowOverride() && override)){
236
            //local preference
236 237
            String dbSpecific = prefKey(name);
237 238
            if (getPreferenceStore().contains(dbSpecific)){
238
                prefValue = getPreferenceStore().getString(dbSpecific);
239
            }else{
240
                prefValue = getPreferenceStore().
241
                        getString(name);
239
                return getPreferenceStore().getString(dbSpecific);
242 240
            }
243
            if (StringUtils.isBlank(prefValue) || (pref == null && !override)){
244
                IPreferencePredicate pred = PreferencePredicate.getByKey(name);
245
                if (pred != null){
246
                    if (pred.getDefaultValue() instanceof String){
247
                        return (String)pred.getDefaultValue();
248
                    }else if (pred.getDefaultValue() != null){
249
                        return pred.getDefaultValue().toString();
250
                    }
251
                }
252
                return prefValue;
241
         }else if (pref != null){
242
             //db preference
243
             if (pref.getValue() == null){
244
                 Object result = PreferencePredicate.getByKey(pref.getPredicate()).getDefaultValue();
245
                 if (result instanceof String){
246
                     return (String)result;
247
                 }else{
248
                     return result.toString();
249
                 }
250
             }
251
            return pref.getValue();
252
        }
253
        //no override but default value
254
        IPreferencePredicate pred = PreferencePredicate.getByKey(name);
255
        if (pred != null){
256
            if (pred.getDefaultValue() instanceof String){
257
                return (String)pred.getDefaultValue();
258
            }else if (pred.getDefaultValue() != null){
259
                return pred.getDefaultValue().toString();
253 260
            }
261
        }
262
        return null;
254 263

  
255
       }else if (pref != null){
256
           if (pref.getValue() == null){
257
               Object result = PreferencePredicate.getByKey(pref.getPredicate()).getDefaultValue();
258
               if (result instanceof String){
259
                   return (String)result;
260
               }else{
261
                   if (result == null){
262
                       return null;
263
                   }
264
                   if (result instanceof IKeyLabel){
265
                       return ((IKeyLabel)result).getKey();
266
                   }
267
                   return result.toString();
268
               }
269
           }
270
           prefValue = pref.getValue();
271
       }
272
        return prefValue;
264
//        if (local || (pref == null && override) || (pref != null && pref.isAllowOverride() && override)){
265
//            String dbSpecific = prefKey(name);
266
//            if (getPreferenceStore().contains(dbSpecific)){
267
//                prefValue = getPreferenceStore().getString(dbSpecific);
268
//            }else{
269
//                prefValue = getPreferenceStore().
270
//                        getString(name);
271
//            }
272
//            if (StringUtils.isBlank(prefValue) || (pref == null && !override)){
273
//                IPreferencePredicate pred = PreferencePredicate.getByKey(name);
274
//                if (pred != null){
275
//                    if (pred.getDefaultValue() instanceof String){
276
//                        return (String)pred.getDefaultValue();
277
//                    }else if (pred.getDefaultValue() != null){
278
//                        return pred.getDefaultValue().toString();
279
//                    }
280
//                }
281
//                return prefValue;
282
//            }
283
//
284
//       }else if (pref != null){
285
//           if (pref.getValue() == null){
286
//               Object result = PreferencePredicate.getByKey(pref.getPredicate()).getDefaultValue();
287
//               if (result instanceof String){
288
//                   return (String)result;
289
//               }else{
290
//                   if (result == null){
291
//                       return null;
292
//                   }
293
//                   if (result instanceof IKeyLabel){
294
//                       return ((IKeyLabel)result).getKey();
295
//                   }
296
//                   return result.toString();
297
//               }
298
//           }
299
//           prefValue = pref.getValue();
300
//       }
301
//        return prefValue;
273 302

  
274 303
    }
275 304

  
......
309 338
        }catch(NumberFormatException e){
310 339
            logger.debug("Preference value of " + name + " is not a number");
311 340
        }
312

  
313 341
        String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
314
        boolean override = true;
315
        if (getPreferenceStore().contains(overrideKey)){
316
            override = getPreferenceStore().getBoolean(overrideKey);
317
        }
318
        if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
342
        boolean override = getPreferenceStore().getBoolean(overrideKey);
343
        if (local || (pref == null && override) || (pref != null && pref.isAllowOverride() && override)){
319 344
            String dbSpecific = prefKey(name);
320 345
            if (getPreferenceStore().contains(dbSpecific)){
321 346
                result = getPreferenceStore().getInt(dbSpecific);
......
350 375
    public static Boolean getBooleanValue(String name, boolean local) {
351 376
        if (CdmStore.isActive()){
352 377
            CdmPreference pref = getDBPreferenceValue(name);
353

  
354 378
            String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
355 379
            boolean override = getPreferenceStore().getBoolean(overrideKey);
356 380

  
357
            if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
381
            if (local || (pref == null && override)|| (pref != null && pref.isAllowOverride() && override)){
382
                //local preference
358 383
                String dbSpecific = prefKey(name);
359 384
                if (getPreferenceStore().contains(dbSpecific)){
360 385
                    return getPreferenceStore().getBoolean(dbSpecific);
361
                }else{
362
                    IPreferencePredicate pred = PreferencePredicate.getByKey(name);
363
                    if (pred != null){
364
                        if (pred.getDefaultValue() instanceof Boolean){
365
                            return (Boolean)pred.getDefaultValue();
366
                        }else if (pred.getDefaultValue() != null){
367
                            return Boolean.valueOf(pred.getDefaultValue().toString());
368
                        }
369
                    }
370
                    return null;
371 386
                }
372
             }else{
387
             }else if (pref != null){
388
                 //db preference
373 389
                 if (pref.getValue() == null){
374 390
                     Object result = PreferencePredicate.getByKey(pref.getPredicate()).getDefaultValue();
375 391
                     if (result instanceof Boolean){
......
380 396
                 }
381 397
                return Boolean.valueOf(pref.getValue());
382 398
            }
383

  
399
            //no override but default value
400
            IPreferencePredicate pred = PreferencePredicate.getByKey(name);
401
            if (pred != null){
402
                if (pred.getDefaultValue() instanceof Boolean){
403
                    return (Boolean)pred.getDefaultValue();
404
                }else if (pred.getDefaultValue() != null){
405
                    return Boolean.valueOf(pred.getDefaultValue().toString());
406
                }
407
            }
408
            return null;
384 409
        }else{
410
            // no connection to db, use local preference
385 411
            return getPreferenceStore().getBoolean(name);
386 412
        }
387 413

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/CommonNameLanguagePreferences.java
11 11

  
12 12
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
13 13
import eu.etaxonomy.cdm.model.term.TermType;
14
import eu.etaxonomy.taxeditor.l10n.Messages;
14 15
import eu.etaxonomy.taxeditor.preference.GeneralTermPreferencePage;
15 16

  
16 17
/**
......
29 30
	 * <p>Constructor for LanguageMenuPreferences.</p>
30 31
	 */
31 32
	public CommonNameLanguagePreferences() {
32
	    super();
33
	    super(Messages.CommonNameLanguages_Title);
34

  
33 35
        isAdminPreference = false;
34 36
        setPredicate(PreferencePredicate.CommonNameLanguages);
35 37
        type = TermType.Language;
38

  
36 39
	}
37 40

  
38 41

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/LanguageMenuPreferences.java
142 142
            String text = multiLanguageEditing.getText();
143 143
            if(text.startsWith(Messages.Preference_Use_Default)){
144 144
                isMultilanguageTextEditingCapability = null;
145
                treeComposite.setEnabled(multiLangugeActivatedPref == null? true: multiLangugeActivatedPref.getValue() != null?Boolean.parseBoolean(multiLangugeActivatedPref.getValue().toString()): true);
145
                treeComposite.setEnabled(multiLangugeActivatedPref == null? true: multiLangugeActivatedPref.getValue() != null?Boolean.valueOf(multiLangugeActivatedPref.getValue().toString()): true);
146 146
                if (!isAdminPreference) {
147 147
                    overrideActivated = false;
148 148
                }
......
159 159
            if (isMultilanguageTextEditingCapability != null){
160 160
                treeComposite.setEnabled(isMultilanguageTextEditingCapability);
161 161
            }else{
162
                treeComposite.setEnabled(multiLangugeActivatedPref == null? true: multiLangugeActivatedPref.getValue() != null?Boolean.parseBoolean(multiLangugeActivatedPref.getValue().toString()): true);
162
                treeComposite.setEnabled(multiLangugeActivatedPref == null? true: multiLangugeActivatedPref.getValue() != null?Boolean.valueOf(multiLangugeActivatedPref.getValue().toString()): true);
163 163
            }
164 164

  
165 165
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionPage.java
138 138
                vocs.add(new TermVocabularyDto(voc.getUuid(), voc.getRepresentations(), voc.getTermType()));
139 139
            }
140 140

  
141

  
141 142
        }
142 143
        return vocs;
143 144
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionPerAreaStatusPage.java
111 111
        activateCheckButton.addSelectionListener(new SelectionAdapter(){
112 112
            @Override
113 113
            public void widgetSelected(SelectionEvent e) {
114
                actualPref.setAllowOverride(overrideButton.getSelection());
115
                override = overrideButton.getSelection();
114
                if (actualPref != null){
115
                   actualPref.setAllowOverride(activateCheckButton.getSelection());
116
                }
117
                override = activateCheckButton.getSelection();
116 118

  
117 119
            }
118 120
        });
121

  
119 122
         return activateCheckButton;
120 123
     }
121 124

  
......
250 253
       String checkedValues = null;
251 254
       if (actualArea == null){
252 255
           checkedValues = pref.getValue();
256
           override = pref.isAllowOverride();
253 257
       }else{
254 258
           if (actualPref == null){
255 259
               PrefKey key = newAreaSpecificStatusPreference();
......
293 297
        }
294 298
        if (actualArea == null){
295 299
            CdmPreference savePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionStatus, saveCheckedElements);
296
            savePref.setAllowOverride(pref.isAllowOverride());
300
            savePref.setAllowOverride(override);
297 301
            pref = savePref;
298 302
        }else{
299 303
            PrefKey key = newAreaSpecificStatusPreference();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionStatusPage.java
46 46
        }
47 47
        overrideButton = createAllowOverrideButton(parent);
48 48

  
49
        super.createControl(parent);
50 49

  
50
        super.createControl(parent);
51
        overrideButton.setSelection(override);
51 52
    }
52 53

  
53 54
    @Override

Also available in: Unified diff