Project

General

Profile

Revision b91b98c5

IDb91b98c509dbfcad980393fed5ca2d361fe93597
Parent 456115c5
Child 660c3f90

Added by Patrick Plitzner about 1 year ago

ref #8294 Move supplemental data source preferences to sub menu

View differences:

eu.etaxonomy.taxeditor.store/plugin.xml
695 695
          id="eu.etaxonomy.taxeditor.preferences.feature2"
696 696
          name="%page.name.60">
697 697
    </page>
698
    <page
699
          category="eu.etaxonomy.taxeditor.preference.supplementalDataPreferences"
700
          class="eu.etaxonomy.taxeditor.preference.SupplementalDataSourcePreferences"
701
          id="eu.etaxonomy.taxeditor.preferences.supplementalDataSourcePreferences"
702
          name="Sources">
703
    </page>
698 704
   
699 705
   
700 706
</extension>
......
800 806
         id="eu.etaxonomy.taxeditor.store.supplementalDataPreferences"
801 807
         name="%page.name.55">
802 808
   </page>
809
   <page
810
         category="eu.etaxonomy.taxeditor.store.supplementalDataPreferences"
811
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.SupplementalDataSourceAdminPreference"
812
         id="eu.etaxonomy.taxeditor.store.supplementalDataSourcePreferences"
813
         name="Sources">
814
   </page>
803 815
</extension>
804 816
</plugin>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SupplementalDataAdminPreference.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
10 10

  
11
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
12
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
13
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
14
import eu.etaxonomy.taxeditor.preference.SupplementalDataPreferences;
11
import org.eclipse.swt.widgets.Composite;
12
import org.eclipse.swt.widgets.Control;
13

  
14
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
15 15

  
16 16
/**
17 17
 * @author k.luther
18 18
 * @since 28.06.2019
19 19
 *
20 20
 */
21
public class SupplementalDataAdminPreference extends SupplementalDataPreferences {
22

  
23
    private CdmPreference prefShowIdNamespace;
24
    private CdmPreference prefShowNamespace;
21
public class SupplementalDataAdminPreference extends CdmPreferencePage {
25 22

  
26 23
    @Override
27
    public boolean performOk() {
28
        if (!isApply()){
29
            return true;
30
        }
31
        boolean setToDefault = false;
32
        if (isShowIDNamspace == null){
33
            setToDefault = true;
34
            isShowIDNamspace = true;
35
        }
36
        CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSource, Boolean.toString(this.isShowIDNamspace));
37
        pref.setAllowOverride(isAllowOverrideShowIDNamspace);
38
        PreferencesUtil.setPreferencesToDB(pref, setToDefault);
39

  
40
        if (isShowIDSource == null){
41
            setToDefault = true;
42
            isShowIDSource = true;
43
        }
44
        pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowNamespaceInSource, Boolean.toString(this.isShowIDSource));
45
        pref.setAllowOverride(isAllowOverrideShowIDSource);
46
        PreferencesUtil.setPreferencesToDB(pref, setToDefault);
47

  
48
        PreferencesUtil.updateDBPreferences();
49
        return true;
24
    protected Control createContents(Composite parent) {
25
        noDefaultAndApplyButton();
26
        return null;
50 27
    }
51 28

  
52
    @Override
53
    protected void getValues(){
54
        isAdminPreference = true;
55

  
56
        prefShowIdNamespace = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInSource);
57
        if (prefShowIdNamespace == null){
58
            prefShowIdNamespace = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSource, null);
59
            prefShowIdNamespace.setAllowOverride(true);
60
        }
61
        isShowIDNamspace = prefShowIdNamespace.getValue()!= null? Boolean.parseBoolean(prefShowIdNamespace.getValue()): null;
62
        isAllowOverrideShowIDNamspace = prefShowIdNamespace.isAllowOverride();
63

  
64

  
65
        prefShowNamespace = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowNamespaceInSource);
66
        if (prefShowNamespace == null){
67
            prefShowNamespace = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowNamespaceInSource, null);
68
            prefShowNamespace.setAllowOverride(true);
69
        }
70
        isShowIDSource = prefShowNamespace.getValue()!= null? Boolean.parseBoolean(prefShowNamespace.getValue()): null;
71
        isAllowOverrideShowIDSource = prefShowNamespace.isAllowOverride();
72
    }
73 29
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SupplementalDataSourceAdminPreference.java
1
/**
2
* Copyright (C) 2019 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.PreferencesUtil;
14
import eu.etaxonomy.taxeditor.preference.SupplementalDataSourcePreferences;
15

  
16
/**
17
 * @author k.luther
18
 * @since 28.06.2019
19
 *
20
 */
21
public class SupplementalDataSourceAdminPreference extends SupplementalDataSourcePreferences implements IE4AdminPreferencePage{
22

  
23
    private CdmPreference prefShowIdNamespace;
24
    private CdmPreference prefShowNamespace;
25

  
26
    @Override
27
    public boolean performOk() {
28
        if (!isApply()){
29
            return true;
30
        }
31
        boolean setToDefault = false;
32
        if (isShowIDNamspace == null){
33
            setToDefault = true;
34
            isShowIDNamspace = true;
35
        }
36
        CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSource, Boolean.toString(this.isShowIDNamspace));
37
        pref.setAllowOverride(isAllowOverrideShowIDNamspace);
38
        PreferencesUtil.setPreferencesToDB(pref, setToDefault);
39

  
40
        if (isShowIDSource == null){
41
            setToDefault = true;
42
            isShowIDSource = true;
43
        }
44
        pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowNamespaceInSource, Boolean.toString(this.isShowIDSource));
45
        pref.setAllowOverride(isAllowOverrideShowIDSource);
46
        PreferencesUtil.setPreferencesToDB(pref, setToDefault);
47

  
48
        PreferencesUtil.updateDBPreferences();
49
        return true;
50
    }
51

  
52
    @Override
53
    protected void getValues(){
54
        isAdminPreference = true;
55

  
56
        prefShowIdNamespace = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInSource);
57
        if (prefShowIdNamespace == null){
58
            prefShowIdNamespace = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSource, null);
59
            prefShowIdNamespace.setAllowOverride(true);
60
        }
61
        isShowIDNamspace = prefShowIdNamespace.getValue()!= null? Boolean.parseBoolean(prefShowIdNamespace.getValue()): null;
62
        isAllowOverrideShowIDNamspace = prefShowIdNamespace.isAllowOverride();
63

  
64

  
65
        prefShowNamespace = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowNamespaceInSource);
66
        if (prefShowNamespace == null){
67
            prefShowNamespace = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowNamespaceInSource, null);
68
            prefShowNamespace.setAllowOverride(true);
69
        }
70
        isShowIDSource = prefShowNamespace.getValue()!= null? Boolean.parseBoolean(prefShowNamespace.getValue()): null;
71
        isAllowOverrideShowIDSource = prefShowNamespace.isAllowOverride();
72
    }
73
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SupplementalDataPreferences.java
9 9
package eu.etaxonomy.taxeditor.preference;
10 10

  
11 11
import org.eclipse.jface.preference.BooleanFieldEditor;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.events.SelectionListener;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.widgets.Button;
18
import org.eclipse.swt.widgets.Combo;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Label;
22 12

  
23
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
24
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
25
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
26
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
27 13
import eu.etaxonomy.taxeditor.l10n.Messages;
28
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
14
import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4;
29 15

  
30 16
/**
31 17
 * @author k.luther
32 18
 * @since 18.01.2019
33 19
 *
34 20
 */
35
public class SupplementalDataPreferences extends CdmPreferencePage implements SelectionListener{
36

  
37
    protected Boolean isShowIDNamspace;
38
    protected Boolean isShowIDSource;
39

  
40
    protected boolean isAllowOverrideShowIDNamspace;
41
    protected boolean isAllowOverrideShowIDSource;
42

  
43
    protected boolean isOverrideShowIDNamspace;
44
    protected boolean isOverrideShowIDSource;
45

  
46
    private BooleanFieldEditor show_debug;
47
    protected Combo showIDNamspaceButton;
48
    protected Button allowOverrideShowIDNamspaceButton;
49
    protected Combo showIDSourceButton;
50
    protected Button allowOverrideIDSourceButton;
51

  
52
    final String SHOW = Messages.GeneralPreference_yes;
53
    final String DO_NOT_SHOW = Messages.GeneralPreference_no;
54

  
55
    @Override
56
    protected Control createContents(Composite parent) {
57
        getValues();
58
        final Composite composite = createComposite(parent);
59

  
60
        GridData gridData = createTextGridData();
61

  
62
        Label separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
63
        separator.setLayoutData(gridData);
64
        separator.setVisible(false);
65

  
66
        if(!isAdminPreference){
67
            show_debug = new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SHOW_DEBUG_INFORMATION),
68
                    Messages.SupplementalDataPreferences_0,
69
                    composite);
70
            show_debug.setPreferenceStore(getPreferenceStore());
71
            show_debug.load();
72
        }
73

  
74
        showIDNamspaceButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowIdInSource, "Show ID in Namespace in Source",
75
                isAdminPreference);
76

  
77
        showIDNamspaceButton.addSelectionListener(this);
78

  
79
        if (isShowIDNamspace == null || (!isOverrideShowIDNamspace && !isAdminPreference)){
80
            showIDNamspaceButton.select(0);
81
        }else if (isShowIDNamspace){
82
            showIDNamspaceButton.select(1);
83
        }else{
84
            showIDNamspaceButton.select(2);
85
        }
86
        if (isAdminPreference){
87
            allowOverrideShowIDNamspaceButton = createAllowOverrideButton(composite);
88

  
89
            allowOverrideShowIDNamspaceButton.setSelection(isAllowOverrideShowIDNamspace);
90
            allowOverrideShowIDNamspaceButton.addSelectionListener(new SelectionAdapter(){
91
                @Override
92
                public void widgetSelected(SelectionEvent e) {
93
                    isAllowOverrideShowIDNamspace = allowOverrideShowIDNamspaceButton.getSelection();
94
                    setApply(true);
95
                }
96
            });
97
        }
98
        showIDSourceButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowNamespaceInSource, "Show ID in Source",
99
                isAdminPreference);
100
        showIDSourceButton.addSelectionListener(this);
101
        if (isShowIDSource == null || (!isOverrideShowIDSource && !isAdminPreference)){
102
            showIDSourceButton.select(0);
103
        }else if (isShowIDSource){
104
            showIDSourceButton.select(1);
105
        }else{
106
            showIDSourceButton.select(2);
107
        }
108

  
109
        if (isAdminPreference){
110
            allowOverrideIDSourceButton = createAllowOverrideButton(composite);
111
            allowOverrideIDSourceButton.setSelection(isAllowOverrideShowIDSource);
112
            allowOverrideIDSourceButton.addSelectionListener(new SelectionAdapter(){
113
                @Override
114
                public void widgetSelected(SelectionEvent e) {
115
                    isAllowOverrideShowIDSource = allowOverrideIDSourceButton.getSelection();
116
                    setApply(true);
117
                }
118
            });
119
        }
120
        if (!isAllowOverrideShowIDNamspace && !isAdminPreference){
121
            showIDNamspaceButton.setEnabled(false);
122
        }
123
        if (!isAllowOverrideShowIDSource && !isAdminPreference){
124
            showIDSourceButton.setEnabled(false);
125
        }
126
        return composite;
127
    }
128

  
129
    @Override
130
    public boolean performOk() {
131
        if (show_debug != null){
132
            show_debug.store();
133
        }
134
        if (isAllowOverrideShowIDNamspace){
135
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), isOverrideShowIDNamspace);
136
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowIdInSource.getKey(), isShowIDNamspace);
137
        }
138
        if (isAllowOverrideShowIDSource){
139
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey(), isShowIDSource);
140
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), isOverrideShowIDSource);
141
        }
142
        return true;
143
    }
144

  
145
    @Override
146
    protected void performDefaults() {
147
        show_debug.loadDefault();
148
        super.performDefaults();
149
    }
150

  
151
    @Override
152
    protected void getValues(){
153
        isAdminPreference = false;
154

  
155
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
156
        isShowIDNamspace = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey(), true);
157
        isOverrideShowIDNamspace = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), true) != null?PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), true): false;
158
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowIdInSource);
159
        CdmPreference pref = cache.findBestMatching(key);
160
        if (pref != null){
161
            isAllowOverrideShowIDNamspace = pref.isAllowOverride();
162
        }else{
163
            isAllowOverrideShowIDNamspace = true;
164
        }
165

  
166
        isShowIDSource = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey(), true);
167
        isOverrideShowIDSource = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), true) != null? PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), true):false;
168
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowNamespaceInSource);
169
        pref = cache.findBestMatching(key);
170
        if (pref != null){
171
            isAllowOverrideShowIDSource = pref.isAllowOverride();
172
        }else{
173
            isAllowOverrideShowIDSource = true;
174
        }
175
    }
176

  
177
    @Override
178
    public void widgetSelected(SelectionEvent e) {
179
        if (e.getSource().equals(this.showIDNamspaceButton)) {
180
            String text = showIDNamspaceButton.getText();
181
           // text = text.replace(Messages.Preference_Use_Default, "");
182
            if (text.equals(Messages.Preference_Use_Default)){
183
                isOverrideShowIDNamspace = false;
184
            }else{
185
                isOverrideShowIDNamspace = true;
186
            }
187
            if (text.equals(SHOW)){
188
                isShowIDNamspace = true;
189

  
190
            }else{
191
                isShowIDNamspace = false;
192
            }
193
        }
194
        if (e.getSource().equals(this.showIDSourceButton)) {
195
            String text = showIDSourceButton.getText();
196
            if (text.equals(Messages.Preference_Use_Default)){
197
                isOverrideShowIDSource = false;
198
            }else{
199
                isOverrideShowIDSource = true;
200
            }
201
            if (text.equals(SHOW)){
202
                isShowIDSource = true;
203
            }else{
204
                isShowIDSource = false;
205
            }
206
        }
207

  
208
        this.setApply(true);
209
    }
21
public class SupplementalDataPreferences extends FieldEditorPreferencePageE4 {
210 22

  
211 23
    @Override
212
    public void widgetDefaultSelected(SelectionEvent e) {
24
    protected void createFieldEditors() {
25
        addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SHOW_DEBUG_INFORMATION),
26
                Messages.SupplementalDataPreferences_0,
27
                getFieldEditorParent()));
213 28
    }
214 29

  
215 30
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SupplementalDataSourcePreferences.java
1
/**
2
* Copyright (C) 2019 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 18.01.2019
32
 *
33
 */
34
public class SupplementalDataSourcePreferences extends CdmPreferencePage implements SelectionListener{
35

  
36
    protected Boolean isShowIDNamspace;
37
    protected Boolean isShowIDSource;
38

  
39
    protected boolean isAllowOverrideShowIDNamspace;
40
    protected boolean isAllowOverrideShowIDSource;
41

  
42
    protected boolean isOverrideShowIDNamspace;
43
    protected boolean isOverrideShowIDSource;
44

  
45
    protected Combo showIDNamspaceButton;
46
    protected Button allowOverrideShowIDNamspaceButton;
47
    protected Combo showIDSourceButton;
48
    protected Button allowOverrideIDSourceButton;
49

  
50
    final String SHOW = Messages.GeneralPreference_yes;
51
    final String DO_NOT_SHOW = Messages.GeneralPreference_no;
52

  
53
    @Override
54
    protected Control createContents(Composite parent) {
55
        getValues();
56
        final Composite composite = createComposite(parent);
57

  
58
        GridData gridData = createTextGridData();
59

  
60
        Label separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
61
        separator.setLayoutData(gridData);
62
        separator.setVisible(false);
63

  
64
        showIDNamspaceButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowIdInSource, "Show ID in Namespace in Source",
65
                isAdminPreference);
66

  
67
        showIDNamspaceButton.addSelectionListener(this);
68

  
69
        if (isShowIDNamspace == null || (!isOverrideShowIDNamspace && !isAdminPreference)){
70
            showIDNamspaceButton.select(0);
71
        }else if (isShowIDNamspace){
72
            showIDNamspaceButton.select(1);
73
        }else{
74
            showIDNamspaceButton.select(2);
75
        }
76
        if (isAdminPreference){
77
            allowOverrideShowIDNamspaceButton = createAllowOverrideButton(composite);
78

  
79
            allowOverrideShowIDNamspaceButton.setSelection(isAllowOverrideShowIDNamspace);
80
            allowOverrideShowIDNamspaceButton.addSelectionListener(new SelectionAdapter(){
81
                @Override
82
                public void widgetSelected(SelectionEvent e) {
83
                    isAllowOverrideShowIDNamspace = allowOverrideShowIDNamspaceButton.getSelection();
84
                    setApply(true);
85
                }
86
            });
87
        }
88
        showIDSourceButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowNamespaceInSource, "Show ID in Source",
89
                isAdminPreference);
90
        showIDSourceButton.addSelectionListener(this);
91
        if (isShowIDSource == null || (!isOverrideShowIDSource && !isAdminPreference)){
92
            showIDSourceButton.select(0);
93
        }else if (isShowIDSource){
94
            showIDSourceButton.select(1);
95
        }else{
96
            showIDSourceButton.select(2);
97
        }
98

  
99
        if (isAdminPreference){
100
            allowOverrideIDSourceButton = createAllowOverrideButton(composite);
101
            allowOverrideIDSourceButton.setSelection(isAllowOverrideShowIDSource);
102
            allowOverrideIDSourceButton.addSelectionListener(new SelectionAdapter(){
103
                @Override
104
                public void widgetSelected(SelectionEvent e) {
105
                    isAllowOverrideShowIDSource = allowOverrideIDSourceButton.getSelection();
106
                    setApply(true);
107
                }
108
            });
109
        }
110
        if (!isAllowOverrideShowIDNamspace && !isAdminPreference){
111
            showIDNamspaceButton.setEnabled(false);
112
        }
113
        if (!isAllowOverrideShowIDSource && !isAdminPreference){
114
            showIDSourceButton.setEnabled(false);
115
        }
116
        return composite;
117
    }
118

  
119
    @Override
120
    public boolean performOk() {
121
        if (isAllowOverrideShowIDNamspace){
122
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), isOverrideShowIDNamspace);
123
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowIdInSource.getKey(), isShowIDNamspace);
124
        }
125
        if (isAllowOverrideShowIDSource){
126
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey(), isShowIDSource);
127
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), isOverrideShowIDSource);
128
        }
129
       return true;
130
   }
131
    @Override
132
    protected void getValues(){
133
        isAdminPreference = false;
134

  
135
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
136
        isShowIDNamspace = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey(), true);
137
        isOverrideShowIDNamspace = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), true) != null?PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), true): false;
138
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowIdInSource);
139
        CdmPreference pref = cache.findBestMatching(key);
140
        if (pref != null){
141
            isAllowOverrideShowIDNamspace = pref.isAllowOverride();
142
        }else{
143
            isAllowOverrideShowIDNamspace = true;
144
        }
145

  
146
        isShowIDSource = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey(), true);
147
        isOverrideShowIDSource = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), true) != null? PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), true):false;
148
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowNamespaceInSource);
149
        pref = cache.findBestMatching(key);
150
        if (pref != null){
151
            isAllowOverrideShowIDSource = pref.isAllowOverride();
152
        }else{
153
            isAllowOverrideShowIDSource = true;
154
        }
155
    }
156

  
157
    @Override
158
    public void widgetSelected(SelectionEvent e) {
159
        if (e.getSource().equals(this.showIDNamspaceButton)) {
160
            String text = showIDNamspaceButton.getText();
161
           // text = text.replace(Messages.Preference_Use_Default, "");
162
            if (text.equals(Messages.Preference_Use_Default)){
163
                isOverrideShowIDNamspace = false;
164
            }else{
165
                isOverrideShowIDNamspace = true;
166
            }
167
            if (text.equals(SHOW)){
168
                isShowIDNamspace = true;
169

  
170
            }else{
171
                isShowIDNamspace = false;
172
            }
173
        }
174
        if (e.getSource().equals(this.showIDSourceButton)) {
175
            String text = showIDSourceButton.getText();
176
            if (text.equals(Messages.Preference_Use_Default)){
177
                isOverrideShowIDSource = false;
178
            }else{
179
                isOverrideShowIDSource = true;
180
            }
181
            if (text.equals(SHOW)){
182
                isShowIDSource = true;
183
            }else{
184
                isShowIDSource = false;
185
            }
186
        }
187

  
188
        this.setApply(true);
189
    }
190

  
191
    @Override
192
    public void widgetDefaultSelected(SelectionEvent e) {
193
    }
194

  
195
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)