Project

General

Profile

« Previous | Next » 

Revision 239530ee

Added by Katja Luther over 5 years ago

ref #7922: add preference to save distribution editor factual data to their own fact

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SpecimenAdminPreferences.java
12 12
import org.eclipse.swt.events.SelectionAdapter;
13 13
import org.eclipse.swt.events.SelectionEvent;
14 14
import org.eclipse.swt.layout.GridData;
15
import org.eclipse.swt.layout.GridLayout;
16 15
import org.eclipse.swt.widgets.Button;
17 16
import org.eclipse.swt.widgets.Composite;
18 17
import org.eclipse.swt.widgets.Control;
......
25 24
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
26 25
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
27 26
import eu.etaxonomy.taxeditor.l10n.Messages;
28
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
29 27
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
30 28
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
31 29
import eu.etaxonomy.taxeditor.store.CdmStore;
......
40 38
    }
41 39

  
42 40
    boolean isShowSpecimenRelatedIssues;
41
    boolean allowOverrideShowSpecimenRelatedIssues;
43 42
    boolean isShowCollectingAreaInGeneralSection;
43
    boolean allowOverrideShowCollectingAreaInGeneralSection;
44 44
    boolean isDeterminationOnlyForFieldUnits;
45
    boolean allowOverrideDeterminationOnlyForFieldUnits;
45 46
    boolean isShowTaxonAssociation;
47
    boolean allowOverrideShowTaxonAssociation;
46 48
    boolean isShowLifeForm;
47
    boolean isUseLocalPreference;
49
    boolean allowOverrideShowLifeForm;
50

  
48 51
    Composite composite;
49 52
    CdmPreference showSpecimenPref = null;
50 53

  
......
52 55
    protected Control createContents(Composite parent) {
53 56

  
54 57
        getValues();
55

  
58
        composite = createComposite(parent);
59
        composite.setEnabled(isShowSpecimenRelatedIssues);
56 60
        final Button showSpecimenButton = new Button(parent, SWT.CHECK);
57 61

  
58 62
        showSpecimenButton.setText(Messages.DatabasePreferncesPage_Show_Specimen);
......
71 75
                 }
72 76
              }
73 77
         });
74
        composite = new Composite(parent, SWT.NULL);
75
        GridLayout gridLayout = new GridLayout();
76
        composite.setLayout(gridLayout);
77
        composite.setEnabled(isShowSpecimenRelatedIssues);
78

  
78 79
        Label separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
79 80
        separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
80 81

  
......
130 131
    //    Composite useLocalComp = new Composite(composite, SWT.NONE);
131 132

  
132 133

  
133
        final Button useLocalPreference = new Button(composite, SWT.CHECK);
134

  
135
        useLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
136
        GridData gridData = new GridData(SWT.FILL, SWT.BOTTOM, false, false);
137
        gridData.verticalIndent = 10;
138
        useLocalPreference.setLayoutData(gridData);
139

  
140
        useLocalPreference.setSelection(isUseLocalPreference);
141
        useLocalPreference.addSelectionListener(new SelectionAdapter(){
142
             @Override
143
             public void widgetSelected(SelectionEvent e) {
144
                 isUseLocalPreference = useLocalPreference.getSelection();
145
                 PreferencesUtil.setBooleanValue(IPreferenceKeys.SHOW_SPECIMEN_ALLOW_OVERRIDE, isUseLocalPreference);
146
              }
147
         });
134
//        final Button useLocalPreference = new Button(composite, SWT.CHECK);
135
//
136
//        useLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
137
//        GridData gridData = new GridData(SWT.FILL, SWT.BOTTOM, false, false);
138
//        gridData.verticalIndent = 10;
139
//        useLocalPreference.setLayoutData(gridData);
140
//
141
//        useLocalPreference.setSelection(isUseLocalPreference);
142
//        useLocalPreference.addSelectionListener(new SelectionAdapter(){
143
//             @Override
144
//             public void widgetSelected(SelectionEvent e) {
145
//                 isUseLocalPreference = useLocalPreference.getSelection();
146
//                 PreferencesUtil.setBooleanValue(IPreferenceKeys.SHOW_SPECIMEN_ALLOW_OVERRIDE, isUseLocalPreference);
147
//              }
148
//         });
148 149
        return composite;
149 150
    }
150 151

  
......
164 165
            showSpecimenPref = service.find(key);
165 166
            if (showSpecimenPref != null){
166 167
                this.isShowSpecimenRelatedIssues = Boolean.valueOf(showSpecimenPref.getValue());
167
                this.isUseLocalPreference = showSpecimenPref.isAllowOverride();
168
                this.allowOverrideShowSpecimenRelatedIssues = showSpecimenPref.isAllowOverride();
168 169
            }else{
169 170
                showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(true));
170 171
                this.isShowSpecimenRelatedIssues = true;
171
                this.isUseLocalPreference = true;
172
                this.allowOverrideShowSpecimenRelatedIssues = true;
172 173
            }
173 174

  
174 175
            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
175 176
            CdmPreference isShowCollectingAreaInGeneralSectionPref = service.find(key);
176 177
            if (isShowCollectingAreaInGeneralSectionPref != null){
177 178
                this.isShowCollectingAreaInGeneralSection = Boolean.valueOf(isShowCollectingAreaInGeneralSectionPref.getValue());
179
                this.allowOverrideShowCollectingAreaInGeneralSection = isShowCollectingAreaInGeneralSectionPref.isAllowOverride();
178 180
            }
179 181

  
180 182
            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
181 183
            CdmPreference isDeterminationOnlyForFieldUnitsPref = service.find(key);
182 184
            if (isDeterminationOnlyForFieldUnitsPref != null){
183 185
                this.isDeterminationOnlyForFieldUnits = Boolean.valueOf(isDeterminationOnlyForFieldUnitsPref.getValue());
186
                this.allowOverrideDeterminationOnlyForFieldUnits = isDeterminationOnlyForFieldUnitsPref.isAllowOverride();
184 187
            }
185 188
            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
186 189
            CdmPreference isShowTaxonAssociationPref = service.find(key);
187 190
            if (isShowTaxonAssociationPref != null){
188 191
                this.isShowTaxonAssociation = Boolean.valueOf(isShowTaxonAssociationPref.getValue());
192
                this.allowOverrideShowTaxonAssociation = isShowTaxonAssociationPref.isAllowOverride();
189 193
            }
190 194

  
191 195
            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
192 196
            CdmPreference isShowLifeFormPref = service.find(key);
193 197
            if (isShowLifeFormPref != null){
194 198
                this.isShowLifeForm = Boolean.valueOf(isShowLifeFormPref.getValue());
199
                this.allowOverrideShowLifeForm = isShowLifeFormPref.isAllowOverride();
195 200
            }
196 201

  
197 202
        }
......
207 212
            IPreferenceService service = controller.getPreferenceService();
208 213

  
209 214
            CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, Boolean.toString(this.isShowCollectingAreaInGeneralSection));
210
            pref.setAllowOverride(isUseLocalPreference);
215
            pref.setAllowOverride(allowOverrideShowCollectingAreaInGeneralSection);
211 216
            service.set(pref);
212 217
            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(this.isShowSpecimenRelatedIssues));
213
            pref.setAllowOverride(isUseLocalPreference);
218
            pref.setAllowOverride(allowOverrideShowSpecimenRelatedIssues);
214 219
            service.set(pref);
215 220

  
216 221
            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, Boolean.toString(this.isDeterminationOnlyForFieldUnits));
217
            pref.setAllowOverride(isUseLocalPreference);
222
            pref.setAllowOverride(allowOverrideDeterminationOnlyForFieldUnits);
218 223
            service.set(pref);
219 224

  
220 225
            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, Boolean.toString(this.isShowTaxonAssociation));
221
            pref.setAllowOverride(isUseLocalPreference);
226
            pref.setAllowOverride(allowOverrideShowTaxonAssociation);
222 227
            service.set(pref);
223 228

  
224 229
            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, Boolean.toString(this.isShowLifeForm));
225
            pref.setAllowOverride(isUseLocalPreference);
230
            pref.setAllowOverride(allowOverrideShowLifeForm);
226 231
            service.set(pref);
227 232
            PreferencesUtil.updateDBPreferences();
228 233

  

Also available in: Unified diff