Project

General

Profile

« Previous | Next » 

Revision cc1302bd

Added by Katja Luther almost 5 years ago

ref #8045: check whether all db preferences are deleted from DB if value is default value

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/AbcdImportPreference.java
337 337
        }
338 338
        if (configurator != null){
339 339
            String configString = configurator.toString();
340

  
340
            Abcd206ImportConfigurator defaultConfig = Abcd206ImportConfigurator.NewInstance(null,null);
341
            if (configString.equals(defaultConfig.toString())){
342
                configString = null;
343
            }
341 344
            CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AbcdImportConfig, configString);
342 345
            pref.setAllowOverride(allowOverride);
343 346

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NameDetailsViewAdminConfiguration.java
56 56
        NameDetailsConfigurator config = createNameDetailsViewConfig();
57 57
        String value = config.toString();
58 58

  
59

  
59
        if (config.isAllowOverride() && !config.isSimpleDetailsViewActivated()){
60
            // is default, should delete from db
61
            value = null;
62
        }
60 63
        CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.NameDetailsView, value);
61 64
        pref.setAllowOverride(isAllowOverride);
62 65
        service.set(pref);
......
79 82
                isAllowOverride = pref.isAllowOverride();
80 83
                CdmPreferenceCache cache = CdmPreferenceCache.instance();
81 84
                cache.put(pref);
85
            }else {
86
                isAllowOverride = true;
82 87
            }
83 88

  
84 89

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NomenclaturalCodePreferences.java
45 45
 */
46 46
public class NomenclaturalCodePreferences extends CdmPreferencePage implements IE4AdminPreferencePage{
47 47

  
48
    String actualCode = null;
49
    Map<String, String>  labelAndValues;
50
    Map<String, Integer> keyAndIndex;
48
    NomenclaturalCode actualCode = null;
49
    Map<NomenclaturalCode, String>  labelAndValues;
50
    Map<NomenclaturalCode, Integer> keyAndIndex;
51 51
    Combo nomenclaturalCode;
52 52
    Button allowOverrideButton;
53 53
    boolean allowOverride;
......
62 62
            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
63 63
            CdmPreference pref = service.find(key);
64 64
            if (pref != null){
65
                actualCode = pref.getValue();
65
                actualCode = NomenclaturalCode.fromString(pref.getValue());
66 66
                allowOverride = pref.isAllowOverride();
67 67
            }else{
68
                actualCode = PreferencesUtil.getPreferenceKey(PreferencesUtil.getPreferredNomenclaturalCode());
68
                actualCode = NomenclaturalCode.fromString(PreferencePredicate.NomenclaturalCode.getDefaultValue().toString());
69 69
                allowOverride = true;
70 70
            }
71 71

  
......
85 85
        getLabelAndValues();
86 86
        keyAndIndex = new HashMap<>();
87 87
        Integer index = 0;
88
        for (String key: labelAndValues.keySet()) {
88
        for (NomenclaturalCode key: labelAndValues.keySet()) {
89 89
            nomenclaturalCode.add(labelAndValues.get(key));
90 90
            keyAndIndex.put(key, index);
91 91
            index++;
......
100 100
            public void widgetSelected(SelectionEvent evt) {
101 101
                setApply(true);
102 102
                String name = nomenclaturalCode.getText();
103
                for (Entry<String, String> label:labelAndValues.entrySet()){
103
                for (Entry<NomenclaturalCode, String> label:labelAndValues.entrySet()){
104 104
                    if (label.getValue().equals(name)){
105 105
                        actualCode = label.getKey();
106 106
                    }
......
125 125
	/**
126 126
	 * @return
127 127
	 */
128
	private Map<String, String> getLabelAndValues() {
128
	private Map<NomenclaturalCode, String> getLabelAndValues() {
129 129
		List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
130 130
				.getSupportedCodes();
131 131
		labelAndValues = new HashMap<>();
132 132
		for (int i = 0; i < supportedCodes.size(); i++) {
133
			labelAndValues.put(PreferencesUtil.getPreferenceKey(supportedCodes.get(i)), NomenclaturalCodeHelper
133
			labelAndValues.put(supportedCodes.get(i), NomenclaturalCodeHelper
134 134
                    .getDescription(supportedCodes.get(i))) ;
135 135

  
136 136
		}
......
156 156
	@Override
157 157
	 public boolean performOk() {
158 158
	    if (actualCode != null){
159
	        CdmPreference pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.NomenclaturalCode, actualCode);
159
	        CdmPreference pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.NomenclaturalCode, actualCode.toString());
160 160
	        pref.setAllowOverride(allowOverride);
161 161
	        PreferencesUtil.setPreferredNomenclaturalCode(pref);
162 162
	    }
......
165 165

  
166 166
	@Override
167 167
	protected void performDefaults() {
168
	    actualCode = PreferencePredicate.NomenclaturalCode.getDefaultValue().toString();
168
	    actualCode = (NomenclaturalCode)PreferencePredicate.NomenclaturalCode.getDefaultValue();
169 169
	    allowOverride = true;
170 170
	    Integer index = keyAndIndex.get(actualCode);
171 171
        if(index!=null){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/PublishFlagPreference.java
13 13
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
14 14
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
15 15
import eu.etaxonomy.cdm.model.metadata.PublishEnum;
16
import eu.etaxonomy.taxeditor.l10n.Messages;
16 17
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
17 18
import eu.etaxonomy.taxeditor.preference.PublishFlagLocalPreference;
18 19
import eu.etaxonomy.taxeditor.store.CdmStore;
......
40 41
            return true;
41 42
        }
42 43
        String text = publishFlagBehaviour.getText();
44
        text = text.replace(Messages.Preference_Use_Default, "");
43 45
        for (PublishEnum display: PublishEnum.values()){
44 46
            if (display.getLabel().equals(text)){
45 47
                text = display.getKey();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
628 628
    public static String TermOrder_natural;
629 629

  
630 630
    public static String  ChecklistEditorGeneralPreference_Configure_area_order;
631
    public static String Preference_Use_Default;
631 632

  
632 633

  
633 634
    static {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
491 491
TermOrder_natural=Natural
492 492

  
493 493
ChecklistEditorGeneralPreference_Configure_area_order=Order of Areas
494
Preference_Use_Default= (Use Default)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java
334 334

  
335 335
            PreferencesUtil.setBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(),
336 336
                    isEditorActivated);
337

  
337
            boolean override = false;
338 338
            if (distributionEditorPref == null
339 339
                    || isEditorActivated != Boolean.parseBoolean(distributionEditorPref.getValue())) {
340
                PreferencesUtil.setBooleanValue(
341
                        PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()),
342
                        true);
340
                override = true;
343 341
            }
342
            PreferencesUtil.setBooleanValue(
343
                    PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()),
344
                    override);
344 345
            PreferencesUtil.setSortNamedAreasInDistributionEditor(orderAreas);
346
            override = false;
345 347
            if (prefAreaSort == null || orderAreas != prefAreaSort.getValue()) {
346
                PreferencesUtil.setBooleanValue(
347
                        PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()),
348
                        true);
348
                override = true;
349 349
            }
350
            PreferencesUtil.setBooleanValue(
351
                    PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()),
352
                    override);
350 353
            PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
354
            override = false;
351 355
            if (prefRank == null || isShowRank != Boolean.parseBoolean(prefRank.getValue())) {
352
                PreferencesUtil.setBooleanValue(
353
                        PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()),
354
                        true);
356
                override = true;
355 357
            }
358
            PreferencesUtil.setBooleanValue(
359
                    PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()),
360
                    true);
356 361
            PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
362
            override = false;
357 363
            if (prefStatusDisplay == null || displayStatus != prefStatusDisplay.getValue()) {
358
                PreferencesUtil.setBooleanValue(
359
                        PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()),
360
                        true);
364
               override = true;
361 365
            }
366
            PreferencesUtil.setBooleanValue(
367
                    PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()),
368
                    true);
362 369
            PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);
370
            override = false;
363 371
            if (prefAreaDisplay == null || displayArea != prefAreaDisplay.getValue()) {
364
                PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(
365
                        PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), overrideAreaDisplay);
372
                override = true;
366 373
            }
374
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(
375
                    PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), overrideAreaDisplay);
367 376
            PreferencesUtil.setOwnDescriptionForChecklistEditor(ownDescriptionForDistributionEditor);
368 377
            PreferencesUtil.setBooleanValue(
369 378
                    PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()),
......
424 433
        }
425 434
        if (e.getSource().equals(this.activateRankCombo)) {
426 435
            String text = activateRankCombo.getText();
427
            text = text.replace(" (Default)", "");
436
            text = text.replace(Messages.Preference_Use_Default, "");
428 437
            if (text.equals(SHOW_RANK)){
429 438
                isShowRank = true;
430 439
            }else{
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/GeneralPreferencePage.java
223 223
    public void widgetSelected(SelectionEvent e) {
224 224
        if (e.getSource().equals(this.showIOMenuButton)) {
225 225
            String text = showIOMenuButton.getText();
226
            text = text.replace(" (Default)", "");
226
            text = text.replace(Messages.Preference_Use_Default, "");
227 227
            if (text.equals(SHOW)){
228 228
                isShowIOMenu = true;
229 229
            }else{
......
232 232
        }
233 233
        if (e.getSource().equals(this.showChecklistPerspectiveButton)) {
234 234
            String text = showChecklistPerspectiveButton.getText();
235
            text = text.replace(" (Default)", "");
235
            text = text.replace(Messages.Preference_Use_Default, "");
236 236
            if (text.equals(SHOW)){
237 237
                isShowCheckListPerspective = true;
238 238
            }else{
......
241 241
        }
242 242
        if (e.getSource().equals(this.showTaxonNodeWizardButton)) {
243 243
            String text = showTaxonNodeWizardButton.getText();
244
            text = text.replace(" (Default)", "");
244
            text = text.replace(Messages.Preference_Use_Default, "");
245 245
            if (text.equals(SHOW)){
246 246
                isShowTaxonNodeWizard = true;
247 247
            }else{
248 248
                isShowTaxonNodeWizard = false;
249 249
            }
250 250
        }
251
        this.setApply(true);
251 252

  
252 253

  
253 254
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NameDetailsViewConfiguration.java
9 9
import org.eclipse.swt.layout.GridData;
10 10
import org.eclipse.swt.layout.GridLayout;
11 11
import org.eclipse.swt.widgets.Button;
12
import org.eclipse.swt.widgets.Combo;
12 13
import org.eclipse.swt.widgets.Composite;
13 14
import org.eclipse.swt.widgets.Control;
14 15
import org.eclipse.swt.widgets.Label;
......
26 27
	protected NameDetailsConfigurator nameDetailsConfig;
27 28
    Composite localSettings ;
28 29

  
30
    CdmPreference nameDetailsPref;
29 31

  
30 32
    protected boolean isShowTaxon;
31 33
    protected boolean isShowNameApprobiation ;
......
51 53
    private Button showSecDetail;
52 54
    private Button secEnabled;
53 55

  
54
    protected Button activateCheckButton;
56
    protected Combo activateCheckButton;
55 57
    protected Button allowLocalPreference;
56 58
    protected Button showTaxon;
57 59
    protected Button showLsid;
......
84 86
                nameDetailsConfig = new NameDetailsConfigurator(false);
85 87
            }
86 88

  
87
            activateCheckButton = new Button(title, SWT.CHECK);
88
            allowLocalPreference = createAllowOverrideButton(title);
89
            activateCheckButton = createBooleanCombo(title, "Enable", "Disable", PreferencePredicate.SimpleDetailsViewActivated, Messages.NameDetailsViewConfiguration_activateSimpleDetailsView, isAdminPreference);
90
            if (isAdminPreference){
91
                allowLocalPreference = createAllowOverrideButton(title);
92

  
93
                allowLocalPreference.addSelectionListener(new SelectionAdapter(){
94
                    @Override
95
                    public void widgetSelected(SelectionEvent e) {
96
                        setApply(true);
97
                        if (isAdminPreference){
98
                            isAllowOverride = allowLocalPreference.getSelection();
99
                        }else{
100
                            isOverride = allowLocalPreference.getSelection();
101
                        }
102

  
103
                    }
104
                });
105

  
106
            }
89 107
            Composite dbSettings  = new Composite(parent, SWT.NONE);
90 108

  
91
            activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
92
            activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
109
//            activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
110
//            activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
93 111
            isSimpleDetailsViewActivated = nameDetailsConfig.isSimpleDetailsViewActivated();
94 112

  
95 113
            activateCheckButton.addSelectionListener(new SelectionAdapter(){
96 114
                @Override
97 115
                public void widgetSelected(SelectionEvent e) {
98 116
                    setApply(true);
99
                    isSimpleDetailsViewActivated = activateCheckButton.getSelection();
117
                    isSimpleDetailsViewActivated = activateCheckButton.getSelectionIndex() == 0? true:false;
100 118
                    nameDetailsConfig.setSimpleDetailsViewActivated(isSimpleDetailsViewActivated);
101 119
                    dbSettings.setEnabled(isSimpleDetailsViewActivated);
102 120
                    PreferencesUtil.recursiveSetEnabled(dbSettings, isSimpleDetailsViewActivated);
......
109 127
             });
110 128

  
111 129

  
112
            allowLocalPreference.addSelectionListener(new SelectionAdapter(){
113
                @Override
114
                public void widgetSelected(SelectionEvent e) {
115
                    setApply(true);
116
                    if (isAdminPreference){
117
                        isAllowOverride = allowLocalPreference.getSelection();
118
                    }else{
119
                        isOverride = allowLocalPreference.getSelection();
120
                    }
121

  
122
                }
123
            });
124

  
125 130
            dbSettings.setLayout(new GridLayout());
126 131
            dbSettings.setEnabled(isSimpleDetailsViewActivated);
127 132

  
......
396 401
    public boolean performOk() {
397 402
        if (nameDetailsConfig != null){
398 403
            PreferencesUtil.setStringValue(PreferencePredicate.NameDetailsView.getKey(), nameDetailsConfig.toString());
399
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.NameDetailsView.getKey()), isOverride);
404
            if (nameDetailsPref == null || !nameDetailsConfig.toString().equals(nameDetailsPref.getValue())) {
405
                PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.NameDetailsView.getKey()), true);
406
            }
400 407
        }
401 408

  
402 409
        return true;
......
406 413
    @Override
407 414
    public void getValues(){
408 415
        if (nameDetailsConfig == null){
409
            CdmPreference nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
416
            nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
410 417
            isAdminPreference = false;
411 418
            isAllowOverride = true;
412 419
            if (nameDetailsPref != null){
......
419 426
    }
420 427

  
421 428
    protected void setButtonSelections(){
422
        activateCheckButton.setSelection(isSimpleDetailsViewActivated);;
429
        int index = isSimpleDetailsViewActivated?0:1;
430
        activateCheckButton.select(index);
423 431
        if (isAdminPreference){
424 432
            allowLocalPreference.setSelection(isAllowOverride);
425
        }else{
426
            allowLocalPreference.setSelection(isOverride);
427 433
        }
428 434
        showTaxon.setSelection(isShowTaxon);
429 435
        showLsid.setSelection(isShowLSID);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
247 247
     *
248 248
     *
249 249
     **/
250
    public static int getIntValue(String name) {
250
    public static int getIntValue(String name, boolean local) {
251 251
        CdmPreference pref= getDBPreferenceValue(name);
252 252
        String prefValue = null;
253 253
        if (pref != null){
......
259 259
        }catch(NumberFormatException e){
260 260
            logger.debug("Preference value of " + name + " is not a number");
261 261
        }
262
        if (result == null){
262

  
263
        String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
264
        boolean override = true;
265
        if (getPreferenceStore().contains(overrideKey)){
266
            override = getPreferenceStore().getBoolean(overrideKey);
267
        }
268
        if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
263 269
            String dbSpecific = prefKey(name);
264 270
            if (getPreferenceStore().contains(dbSpecific)){
265 271
                result = getPreferenceStore().getInt(dbSpecific);
......
270 276
        }
271 277
        return result;
272 278

  
273

  
274 279
    }
275 280

  
276 281
    public static boolean getBooleanValue(String name) {
......
287 292
    public static boolean getBooleanValue(String name, boolean local) {
288 293
        if (CdmStore.isActive()){
289 294
            CdmPreference pref = getDBPreferenceValue(name);
290
            String prefValue = null;
291
            if (pref == null || local){
295

  
296
            String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
297
            boolean override = true;
298
            if (getPreferenceStore().contains(overrideKey)){
299
                override = getPreferenceStore().getBoolean(overrideKey);
300
            }
301
            if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
292 302
                String dbSpecific = prefKey(name);
293
                if (getPreferenceStore().contains(dbSpecific)){
294
                    return getPreferenceStore().getBoolean(dbSpecific);
295
                }else{
296
                    return getPreferenceStore().
297
                            getBoolean(name);
298
                }
299
            }else{
303
                return getPreferenceStore().getBoolean(dbSpecific);
304
             }else{
300 305
                return Boolean.valueOf(pref.getValue());
301 306
            }
302 307

  
......
345 350
     *
346 351
     *
347 352
     **/
348
    public static float getFloatValue(String name) {
353
    public static float getFloatValue(String name, boolean local) {
349 354
        CdmPreference pref = getDBPreferenceValue(name);
350 355
        String prefValue = null;
351 356
        if (pref != null){
......
357 362
        }catch(NumberFormatException e){
358 363
            logger.debug("Preference value of " + name + " is not a number");
359 364
        }
360
        if (result == null){
365
        String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
366
        boolean override = true;
367
        if (getPreferenceStore().contains(overrideKey)){
368
            override = getPreferenceStore().getBoolean(overrideKey);
369
        }
370
        if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
361 371
            String dbSpecific = prefKey(name);
362 372
            if (getPreferenceStore().contains(dbSpecific)){
363 373
                result = getPreferenceStore().getFloat(dbSpecific);
......
945 955
		getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowIdInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowIdInSource.getDefaultValue().toString()));
946 956
		getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisableMultiClassification.getKey()), Boolean.valueOf(PreferencePredicate.DisableMultiClassification.getDefaultValue().toString()));
947 957
		getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowImportExportMenu.getKey()), Boolean.valueOf(PreferencePredicate.ShowImportExportMenu.getDefaultValue().toString()));
958
		getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowSpecimen.getKey()), Boolean.valueOf(PreferencePredicate.ShowSpecimen.getDefaultValue().toString()));
948 959

  
949 960
	}
950 961

  
......
1492 1503
        }else{
1493 1504
            value = getStringValue(PreferencePredicate.NameDetailsView.getKey(), local);
1494 1505
        }
1495
        String [] sections = value.split(";");
1496
        Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
1497
        String[] sectionValues;
1498
        for (String sectionValue: sections){
1499
            sectionValues = sectionValue.split(":");
1500
            sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
1501
        }
1502

  
1503
        config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
1504

  
1505
        config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
1506

  
1507
        config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
1508
        config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
1509

  
1510
        config.setLSIDActivated(getValue(sectionMap, "lsid"));
1511

  
1512
        config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
1513

  
1514
        config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
1515

  
1516
        config.setRankActivated(getValue(sectionMap, "rank"));
1517

  
1518
        config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
1519

  
1520
        config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
1521

  
1522
        config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
1523

  
1524
        config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
1525

  
1526
        config.setProtologueActivated(getValue(sectionMap,"protologue"));
1527

  
1528
        config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
1529

  
1530
        config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
1531

  
1506
        if (value!= null){
1507
            String [] sections = value.split(";");
1508
            Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
1509
            String[] sectionValues;
1510
            for (String sectionValue: sections){
1511
                sectionValues = sectionValue.split(":");
1512
                sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
1513
            }
1514
            config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
1515
            config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
1516
            config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
1517
            config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
1518
            config.setLSIDActivated(getValue(sectionMap, "lsid"));
1519
            config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
1520
            config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
1521
            config.setRankActivated(getValue(sectionMap, "rank"));
1522
            config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
1523
            config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
1524
            config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
1525
            config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
1526
            config.setProtologueActivated(getValue(sectionMap,"protologue"));
1527
            config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
1528
            config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
1532 1529
            config.setHybridActivated(getValue(sectionMap,"hybrid"));
1533

  
1530
        }
1534 1531
        return config;
1535 1532
    }
1536 1533

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PublishFlagLocalPreference.java
137 137
                }
138 138
            }
139 139
            PreferencesUtil.setStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey(), text);
140
            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey()), allowOverride);
140
            if (pref == null || !pref.getValue().equals(text)){
141
                PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey()), true);
142
            }else{
143
                PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey()), false);
144
            }
141 145
        }
142 146
        return true;
143 147
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SpecimenOrObservationPreferences.java
11 11
import org.eclipse.swt.SWT;
12 12
import org.eclipse.swt.events.SelectionAdapter;
13 13
import org.eclipse.swt.events.SelectionEvent;
14
import org.eclipse.swt.events.SelectionListener;
14 15
import org.eclipse.swt.layout.GridData;
15 16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Combo;
16 18
import org.eclipse.swt.widgets.Composite;
17 19
import org.eclipse.swt.widgets.Control;
18 20
import org.eclipse.swt.widgets.Label;
......
30 32
 * @date 13.02.2014
31 33
 *
32 34
 */
33
public class SpecimenOrObservationPreferences extends CdmPreferencePage {
35
public class SpecimenOrObservationPreferences extends CdmPreferencePage implements SelectionListener{
34 36

  
35 37
    private static final String LOCAL_SETTINGS_NOT_ALLOWED = Messages.SpecimenOrObservationPreferences_0;
36 38
    private static final String DESCRIPTION = Messages.SpecimenOrObservationPreferences_1;
......
52 54
    protected boolean overrideShowLifeForm;
53 55
    Composite composite;
54 56

  
55
    protected Button showSpecimenButton;
57
    protected Combo showSpecimenButton;
56 58
    protected Button allowOverrideIsShowSpecimenRelatedIssuesButton;
57
    protected Button showCollectingAreaInGeneralSectionButton;
59
    protected Combo showCollectingAreaInGeneralSectionButton;
58 60
    protected Button allowOverrideShowCollectingAreaButton;
59
    protected Button determinationOnlyForFieldUnitsButton;
61
    protected Combo determinationOnlyForFieldUnitsButton;
60 62
    protected Button allowOverridesDeterminationOnlyForFieldUnitsButton;
61
    protected Button showTaxonAssociationButton;
63
    protected Combo showTaxonAssociationButton;
62 64
    protected Button allowOverrideIsShowTaxonAssociationButton;
63 65
    protected Button allowOverrideShowLifeFormButton;
64
    protected Button showLifeFormButton;
66
    protected Combo showLifeFormButton;
65 67

  
68
    CdmPreference showSpecimenPref;
69
    CdmPreference showCollectingAreaInGeneralSection;
70
    CdmPreference showDeterminationOnlyForFieldUnits;
71
    CdmPreference showTaxonAssociation;
72
    CdmPreference showLifeForm;
66 73

  
67 74
    @Override
68 75
    public void init() {
......
105 112
        Label separator= new Label(titleComp, SWT.HORIZONTAL | SWT.SEPARATOR);
106 113
        separator.setLayoutData(gridData);
107 114
        separator.setVisible(false);
108
        showSpecimenButton = new Button(titleComp, SWT.CHECK);
109

  
110
        showSpecimenButton.setText(Messages.DatabasePreferncesPage_Show_Specimen);
111

  
112
        showSpecimenButton.setSelection(isShowSpecimenRelatedIssues);
113
        showSpecimenButton.addSelectionListener(new SelectionAdapter(){
114
             @Override
115
             public void widgetSelected(SelectionEvent e) {
116
                 setApply(true);
117
                 isShowSpecimenRelatedIssues = showSpecimenButton.getSelection();
118
//                 if(isShowSpecimenRelatedIssues){
119
//                     //composite.setVisible(true);
120
//                     composite.setEnabled(true);
121
//                 }else{
122
//                     //composite.setVisible(false);
123
//                     composite.setEnabled(false);
124
//                 }
125
              }
126
         });
127
        allowOverrideIsShowSpecimenRelatedIssuesButton = createAllowOverrideButton(titleComp);
115
        showSpecimenButton = createBooleanCombo(titleComp, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowSpecimen, Messages.DatabasePreferncesPage_Show_Specimen, isAdminPreference);
116

  
117
        showSpecimenButton.addSelectionListener(this);
118
        if (isShowSpecimenRelatedIssues){
119
            showSpecimenButton.select(0);
120
        }else{
121
            showSpecimenButton.select(1);
122
        }
128 123

  
129 124

  
130 125
        if (isAdminPreference){
126
            allowOverrideIsShowSpecimenRelatedIssuesButton = createAllowOverrideButton(titleComp);
131 127
            allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
132 128
            allowOverrideIsShowSpecimenRelatedIssuesButton.addSelectionListener(new SelectionAdapter(){
133 129
                @Override
......
136 132
                    allowOverrideShowSpecimenRelatedIssues = allowOverrideIsShowSpecimenRelatedIssuesButton.getSelection();
137 133
                }
138 134
            });
139
        }else{
140
            allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(overrideShowSpecimenRelatedIssues);
141
            allowOverrideIsShowSpecimenRelatedIssuesButton.addSelectionListener(new SelectionAdapter(){
142
                @Override
143
                public void widgetSelected(SelectionEvent e) {
144
                    setApply(true);
145
                    overrideShowSpecimenRelatedIssues = allowOverrideIsShowSpecimenRelatedIssuesButton.getSelection();
146
                }
147
            });
148
            if (!allowOverrideShowSpecimenRelatedIssues){
149
                showSpecimenButton.setEnabled(false);
150
                allowOverrideIsShowSpecimenRelatedIssuesButton.setEnabled(false);
151
            }
152 135
        }
136

  
153 137
        composite = createComposite(parent);
154 138
        //composite.setEnabled(isShowSpecimenRelatedIssues);
155 139
        gridData = createTextGridData();
......
157 141
        separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
158 142
        separator.setLayoutData(gridData);
159 143

  
160
        showCollectingAreaInGeneralSectionButton = new Button(composite, SWT.CHECK);
161

  
162
        showCollectingAreaInGeneralSectionButton.setText(Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section);
144
        showCollectingAreaInGeneralSectionButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowCollectingAreasInGeneralSection, Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section, isAdminPreference);
163 145

  
164
        showCollectingAreaInGeneralSectionButton.setSelection(isShowCollectingAreaInGeneralSection);
165
        showCollectingAreaInGeneralSectionButton.addSelectionListener(new SelectionAdapter(){
166
             @Override
167
             public void widgetSelected(SelectionEvent e) {
168
                 setApply(true);
169
                 isShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSectionButton.getSelection();
170

  
171
              }
172
         });
173
        allowOverrideShowCollectingAreaButton = createAllowOverrideButton(composite);
146
        showCollectingAreaInGeneralSectionButton.addSelectionListener(this);
147
        if (isShowCollectingAreaInGeneralSection){
148
            showCollectingAreaInGeneralSectionButton.select(0);
149
        }else{
150
            showCollectingAreaInGeneralSectionButton.select(1);
151
        }
174 152
        if (isAdminPreference){
153
            allowOverrideShowCollectingAreaButton = createAllowOverrideButton(composite);
175 154
            allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowCollectingAreaInGeneralSection);
176 155
            allowOverrideShowCollectingAreaButton.addSelectionListener(new SelectionAdapter(){
177 156
                @Override
......
180 159
                    allowOverrideShowCollectingAreaInGeneralSection = allowOverrideShowCollectingAreaButton.getSelection();
181 160
                }
182 161
            });
183
        }else{
184
            allowOverrideShowCollectingAreaButton.setSelection(overrideShowCollectionAreaInGeneralSection);
185
            allowOverrideShowCollectingAreaButton.addSelectionListener(new SelectionAdapter(){
186
                @Override
187
                public void widgetSelected(SelectionEvent e) {
188
                    setApply(true);
189
                    overrideShowCollectionAreaInGeneralSection = allowOverrideShowCollectingAreaButton.getSelection();
190
                }
191
            });
192
            if (!allowOverrideShowCollectingAreaInGeneralSection){
193
                showCollectingAreaInGeneralSectionButton.setEnabled(false);
194
                allowOverrideShowCollectingAreaButton.setEnabled(false);
195
            }
196 162
        }
197 163

  
198
        determinationOnlyForFieldUnitsButton = new Button(composite, SWT.CHECK);
199
        determinationOnlyForFieldUnitsButton.setText(Messages.DatabasePreferncesPage_Determination_only_for_field_unnits);
200
        determinationOnlyForFieldUnitsButton.setSelection(isDeterminationOnlyForFieldUnits);
201
        determinationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
202
             @Override
203
             public void widgetSelected(SelectionEvent e) {
204
                 setApply(true);
205
                 isDeterminationOnlyForFieldUnits = determinationOnlyForFieldUnitsButton.getSelection();
206
             }
207
         });
164
        determinationOnlyForFieldUnitsButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.DeterminationOnlyForFieldUnits, Messages.DatabasePreferncesPage_Determination_only_for_field_unnits, isAdminPreference);
165

  
166

  
167
        determinationOnlyForFieldUnitsButton.addSelectionListener(this);
168
        if (isDeterminationOnlyForFieldUnits){
169
            determinationOnlyForFieldUnitsButton.select(0);
170
        }else{
171
            determinationOnlyForFieldUnitsButton.select(1);
172
        }
208 173

  
209
        allowOverridesDeterminationOnlyForFieldUnitsButton = createAllowOverrideButton(composite);
210 174
        if (isAdminPreference){
175
            allowOverridesDeterminationOnlyForFieldUnitsButton = createAllowOverrideButton(composite);
211 176
            allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideDeterminationOnlyForFieldUnits);
212 177
            allowOverridesDeterminationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
213 178
                @Override
......
216 181
                    allowOverrideDeterminationOnlyForFieldUnits = allowOverridesDeterminationOnlyForFieldUnitsButton.getSelection();
217 182
                }
218 183
            });
219
        }else{
220
            allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(overrideDeterminationOnlyForFieldUnits);
221
            allowOverridesDeterminationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
222
                @Override
223
                public void widgetSelected(SelectionEvent e) {
224
                    setApply(true);
225
                    overrideDeterminationOnlyForFieldUnits = allowOverridesDeterminationOnlyForFieldUnitsButton.getSelection();
226
                }
227
            });
228
            if (!allowOverrideDeterminationOnlyForFieldUnits){
229
                determinationOnlyForFieldUnitsButton.setEnabled(false);
230
                allowOverridesDeterminationOnlyForFieldUnitsButton.setEnabled(false);
231
            }
232 184
        }
233 185

  
234
        showTaxonAssociationButton = new Button(composite, SWT.CHECK);
186
        showTaxonAssociationButton =createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowTaxonAssociations, Messages.DatabasePreferncesPage_Taxon_Associations, isAdminPreference);
235 187

  
236
        showTaxonAssociationButton.setText(Messages.DatabasePreferncesPage_Taxon_Associations);
237 188

  
238
        showTaxonAssociationButton.setSelection(isShowTaxonAssociation);
239
        showTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
240
             @Override
241
             public void widgetSelected(SelectionEvent e) {
242
                 setApply(true);
243
                 isShowTaxonAssociation = showTaxonAssociationButton.getSelection();
244

  
245
              }
246
         });
247
        allowOverrideIsShowTaxonAssociationButton = createAllowOverrideButton(composite);
189
        showTaxonAssociationButton.addSelectionListener(this);
190
        if (isShowTaxonAssociation){
191
            showTaxonAssociationButton.select(0);
192
        }else{
193
            showTaxonAssociationButton.select(1);
194
        }
248 195
        if (isAdminPreference){
196
            allowOverrideIsShowTaxonAssociationButton = createAllowOverrideButton(composite);
249 197
            allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowTaxonAssociation);
250 198
            allowOverrideIsShowTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
251 199
                @Override
......
254 202
                    allowOverrideShowTaxonAssociation = allowOverrideIsShowTaxonAssociationButton.getSelection();
255 203
                }
256 204
            });
257
        }else{
258
            allowOverrideIsShowTaxonAssociationButton.setSelection(overrideShowTaxonAssociation);
259
            allowOverrideIsShowTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
260
                @Override
261
                public void widgetSelected(SelectionEvent e) {
262
                    setApply(true);
263
                    overrideShowTaxonAssociation = allowOverrideIsShowTaxonAssociationButton.getSelection();
264
                }
265
            });
266
            if (!allowOverrideShowTaxonAssociation){
267
                showTaxonAssociationButton.setEnabled(false);
268
                allowOverrideIsShowTaxonAssociationButton.setEnabled(false);
269
            }
270 205
        }
271 206

  
272
        showLifeFormButton = new Button(composite, SWT.CHECK);
273
        showLifeFormButton.setText(Messages.DatabasePreferncesPage_Life_Form);
274
        showLifeFormButton.setSelection(isShowLifeForm);
275
        showLifeFormButton.addSelectionListener(new SelectionAdapter(){
276
             @Override
277
             public void widgetSelected(SelectionEvent e) {
278
                 setApply(true);
279
                 isShowLifeForm = showLifeFormButton.getSelection();
207
        showLifeFormButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowLifeForm, Messages.DatabasePreferncesPage_Life_Form, isAdminPreference);
208
        showLifeFormButton.addSelectionListener(this);
280 209

  
281
              }
282
         });
210
        if (isShowLifeForm){
211
            showLifeFormButton.select(0);
212
        }else{
213
            showLifeFormButton.select(1);
214
        }
283 215

  
284
        allowOverrideShowLifeFormButton = createAllowOverrideButton(composite);
285 216
        if (isAdminPreference){
217
            allowOverrideShowLifeFormButton = createAllowOverrideButton(composite);
286 218
            allowOverrideShowLifeFormButton.setSelection(allowOverrideShowLifeForm);
287 219
            allowOverrideShowLifeFormButton.addSelectionListener(new SelectionAdapter(){
288 220
                @Override
......
291 223
                    allowOverrideShowLifeForm = allowOverrideShowLifeFormButton.getSelection();
292 224
                }
293 225
            });
294
        }else{
295
            allowOverrideShowLifeFormButton.setSelection(overrideShowLifeForm);
296
            //showLifeFormButton.setEnabled(overrideShowLifeForm);
297
            allowOverrideShowLifeFormButton.addSelectionListener(new SelectionAdapter(){
298
                @Override
299
                public void widgetSelected(SelectionEvent e) {
300
                    setApply(true);
301
                    overrideShowLifeForm = allowOverrideShowLifeFormButton.getSelection();
302
                    //showLifeFormButton.setEnabled(overrideShowLifeForm);
303
                }
304
            });
305
            if (!allowOverrideShowLifeForm){
306
                showLifeFormButton.setEnabled(false);
307
                allowOverrideShowLifeFormButton.setEnabled(false);
308
            }
309 226
        }
310 227

  
311 228
        if (!isEditingAllowed){
312 229
            PreferencesUtil.recursiveSetEnabled(composite, false);
313 230
        }
314
       // composite.setVisible(isShowSpecimenRelatedIssues);
315
       // composite.setEnabled(isShowSpecimenRelatedIssues);
231

  
316 232
        return composite;
317 233
    }
318 234

  
......
324 240
    protected void getValues() {
325 241
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
326 242

  
327
        isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), true);
243
        isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey());
328 244
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
329
        CdmPreference showSpecimenPref = cache.findBestMatching(key);
245
        showSpecimenPref = cache.findBestMatching(key);
246
        if (showSpecimenPref == null){
247
            showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, PreferencePredicate.ShowSpecimen.getDefaultValue() != null ?  PreferencePredicate.ShowSpecimen.getDefaultValue().toString(): null);
248
        }
330 249
        allowOverrideShowSpecimenRelatedIssues = showSpecimenPref != null ? showSpecimenPref.isAllowOverride():true;
331 250

  
332
        overrideShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowSpecimen.getKey()), true);
251

  
333 252

  
334 253
        isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
335 254
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
336
        CdmPreference showCollectingAreaInGeneralSection = cache.findBestMatching(key);
255
        showCollectingAreaInGeneralSection = cache.findBestMatching(key);
256
        if (showCollectingAreaInGeneralSection == null){
257
            showCollectingAreaInGeneralSection = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue() != null ?  PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue().toString(): null);
258
        }
337 259
        allowOverrideShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSection != null ? showCollectingAreaInGeneralSection.isAllowOverride():true;
338
        overrideShowCollectionAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true);
260

  
339 261

  
340 262
        isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
341 263
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
342
        CdmPreference showDeterminationOnlyForFieldUnits = cache.findBestMatching(key);
264
        showDeterminationOnlyForFieldUnits = cache.findBestMatching(key);
265
        if (showDeterminationOnlyForFieldUnits == null){
266
            showDeterminationOnlyForFieldUnits = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue() != null ?  PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue().toString(): null);
267
        }
343 268
        allowOverrideDeterminationOnlyForFieldUnits = showDeterminationOnlyForFieldUnits != null ? showDeterminationOnlyForFieldUnits.isAllowOverride():true;
344
        overrideDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true);
345 269

  
346 270
        isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
347
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
348
        CdmPreference showTaxonAssociation = cache.findBestMatching(key);
271
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
272
        showTaxonAssociation = cache.findBestMatching(key);
273
        if (showTaxonAssociation == null){
274
            showTaxonAssociation = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, PreferencePredicate.ShowTaxonAssociations.getDefaultValue() != null ?  PreferencePredicate.ShowTaxonAssociations.getDefaultValue().toString(): null);
275
        }
349 276
        allowOverrideShowTaxonAssociation = showTaxonAssociation != null ? showTaxonAssociation.isAllowOverride():true;
350
        overrideShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowTaxonAssociations.getKey()), true);
351 277

  
352 278
        isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
353
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
354
        CdmPreference showLifeForm = cache.findBestMatching(key);
279
        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
280
        showLifeForm = cache.findBestMatching(key);
281
        if (showLifeForm == null){
282
            showLifeForm = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, PreferencePredicate.ShowLifeForm.getDefaultValue() != null ?  PreferencePredicate.ShowLifeForm.getDefaultValue().toString(): null);
283
        }
355 284
        allowOverrideShowLifeForm = showLifeForm != null ? showLifeForm.isAllowOverride():true;
356
        overrideShowLifeForm = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowLifeForm.getKey()), true);
357 285

  
358 286

  
359 287
    }
......
362 290
    public boolean performOk() {
363 291
        if (allowOverrideShowSpecimenRelatedIssues){
364 292
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), isShowSpecimenRelatedIssues);
365
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowSpecimen.getKey()), overrideShowSpecimenRelatedIssues);
293
            boolean test = isShowSpecimenRelatedIssues != Boolean.parseBoolean(showSpecimenPref.getValue());
294
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowSpecimen.getKey()), isShowSpecimenRelatedIssues != Boolean.parseBoolean(showSpecimenPref.getValue()));
366 295
        }
367 296
        if (allowOverrideShowCollectingAreaInGeneralSection){
368 297
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), isShowCollectingAreaInGeneralSection);
369
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), overrideShowCollectionAreaInGeneralSection);
298
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), isShowCollectingAreaInGeneralSection != Boolean.parseBoolean(showCollectingAreaInGeneralSection.getValue()));
370 299
        }
371 300
        if (allowOverrideDeterminationOnlyForFieldUnits){
372 301
            PreferencesUtil.setBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), isDeterminationOnlyForFieldUnits);
373
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), overrideDeterminationOnlyForFieldUnits);
302
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), isDeterminationOnlyForFieldUnits != Boolean.parseBoolean(showDeterminationOnlyForFieldUnits.getValue()));
374 303
        }
375 304
        if (allowOverrideShowTaxonAssociation){
376 305
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey(), isShowTaxonAssociation);
377
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowTaxonAssociations.getKey()), overrideShowTaxonAssociation);
306
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowTaxonAssociations.getKey()), isShowTaxonAssociation != Boolean.parseBoolean(showTaxonAssociation.getValue()));
378 307
        }
379 308
        if (allowOverrideShowLifeForm){
380 309
            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowLifeForm.getKey(), isShowLifeForm);
381
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowLifeForm.getKey()), overrideShowLifeForm);
310
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowLifeForm.getKey()), isShowLifeForm != Boolean.parseBoolean(showLifeForm.getValue()));
382 311
        }
383 312
        return true;
384 313
    }
......
388 317
    @Override
389 318
    protected void performDefaults() {
390 319
        isShowSpecimenRelatedIssues = (Boolean)PreferencePredicate.ShowSpecimen.getDefaultValue();
391
        showSpecimenButton.setSelection(isShowSpecimenRelatedIssues);
392

  
393
        allowOverrideShowSpecimenRelatedIssues = true;
394
        allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
395

  
320
        if (isShowSpecimenRelatedIssues){
321
            showSpecimenButton.select(0);
322
        }else{
323
            showSpecimenButton.select(1);
324
        }
325
        if (allowOverrideIsShowSpecimenRelatedIssuesButton != null){
326
            allowOverrideShowSpecimenRelatedIssues = true;
327
            allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
328
        }
396 329
        isShowCollectingAreaInGeneralSection = (Boolean)PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue();
397
        showCollectingAreaInGeneralSectionButton.setSelection(isShowCollectingAreaInGeneralSection);
398

  
399
        allowOverrideShowCollectingAreaInGeneralSection = true;
400
        allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowCollectingAreaInGeneralSection);
401

  
330
        if (isShowCollectingAreaInGeneralSection){
331
            showCollectingAreaInGeneralSectionButton.select(0);
332
        }else{
333
            showCollectingAreaInGeneralSectionButton.select(1);
334
        }
335
        if (allowOverrideShowCollectingAreaButton != null){
336
            allowOverrideShowCollectingAreaInGeneralSection = true;
337
            allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
338
        }
402 339
        isDeterminationOnlyForFieldUnits = (Boolean) PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue();
403
        determinationOnlyForFieldUnitsButton.setSelection(isDeterminationOnlyForFieldUnits);
404

  
405
        allowOverrideDeterminationOnlyForFieldUnits = true;
406
        allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideDeterminationOnlyForFieldUnits);
340
        if (isDeterminationOnlyForFieldUnits){
341
            determinationOnlyForFieldUnitsButton.select(0);
342
        }else{
343
            determinationOnlyForFieldUnitsButton.select(1);
344
        }
345
        if (allowOverridesDeterminationOnlyForFieldUnitsButton != null){
346
            allowOverrideDeterminationOnlyForFieldUnits = true;
347
            allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
348
        }
407 349

  
408 350
        isShowTaxonAssociation = (Boolean) PreferencePredicate.ShowTaxonAssociations.getDefaultValue();
409
        showTaxonAssociationButton.setSelection(isShowTaxonAssociation);
351
        if (isShowTaxonAssociation){
352
            showTaxonAssociationButton.select(0);
353
        }else{
354
            showTaxonAssociationButton.select(1);
355
        }
356
        if (allowOverrideIsShowTaxonAssociationButton != null){
357
            allowOverrideShowTaxonAssociation = true;
358
            allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
359
        }
410 360

  
411
        allowOverrideShowTaxonAssociation = true;
412
        allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowTaxonAssociation);
413 361

  
414 362
        isShowLifeForm = (Boolean) PreferencePredicate.ShowLifeForm.getDefaultValue();
415
        showLifeFormButton.setSelection(isShowLifeForm);
416 363

  
417
        allowOverrideShowLifeForm = true;
418
        allowOverrideShowLifeFormButton.setSelection(allowOverrideShowLifeForm);
364
        if (isShowLifeForm){
365
            showLifeFormButton.select(0);
366
        }else{
367
            showLifeFormButton.select(1);
368
        }
369
        if (allowOverrideShowLifeFormButton != null){
370
            allowOverrideShowLifeForm = true;
371
            allowOverrideShowLifeFormButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
372
        }
373

  
419 374

  
420 375
        super.performDefaults();
421 376
    }
422 377

  
378
    /**
379
     * {@inheritDoc}
380
     */
381
    @Override
382
    public void widgetSelected(SelectionEvent e) {
383
       setApply(true);
384
       if (e.getSource().equals(showSpecimenButton)){
385
           String text = showSpecimenButton.getText();
386
           text = text.replace(Messages.Preference_Use_Default, "");
387
           if (text.equals(Messages.GeneralPreference_yes)){
388
               isShowSpecimenRelatedIssues = true;
389
           }else{
390
               isShowSpecimenRelatedIssues = false;
391
           }
392
       }
393
       if (e.getSource().equals(showCollectingAreaInGeneralSectionButton)){
394
           String text = showCollectingAreaInGeneralSectionButton.getText();
395
           text = text.replace(" (Use default)", "");
396
           if (text.equals(Messages.GeneralPreference_yes)){
397
               isShowCollectingAreaInGeneralSection = true;
398
           }else{
399
               isShowCollectingAreaInGeneralSection = false;
400
           }
401
       }
402

  
403
       if (e.getSource().equals(determinationOnlyForFieldUnitsButton)){
404
           String text = determinationOnlyForFieldUnitsButton.getText();
405
           text = text.replace(" (Use default)", "");
406
           if (text.equals(Messages.GeneralPreference_yes)){
407
               isDeterminationOnlyForFieldUnits = true;
408
           }else{
409
               isDeterminationOnlyForFieldUnits = false;
410
           }
411
       }
412
       if (e.getSource().equals(showTaxonAssociationButton)){
413
           String text = showTaxonAssociationButton.getText();
414
           text = text.replace(" (Use default)", "");
415
           if (text.equals(Messages.GeneralPreference_yes)){
416
               isShowTaxonAssociation = true;
417
           }else{
418
               isShowTaxonAssociation = false;
419
           }
420
       }
421
       if (e.getSource().equals(showLifeFormButton)){
422
           String text = showLifeFormButton.getText();
423
           text = text.replace(" (Use default)", "");
424
           if (text.equals(Messages.GeneralPreference_yes)){
425
               isShowLifeForm = true;
426
           }else{
427
               isShowLifeForm = false;
428
           }
429
       }
430
    }
431

  
432
    /**
433
     * {@inheritDoc}
434
     */
435
    @Override
436
    public void widgetDefaultSelected(SelectionEvent e) {
437
        // TODO Auto-generated method stub
438

  
439
    }
440

  
441

  
442

  
423 443

  
424 444
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/CdmPreferencePage.java
166 166
            defaultValue = (Boolean)predicate.getDefaultValue();
167 167
        }
168 168
        if (defaultValue){
169
            booleanCombo.add(textTrue + " (Use Default)");
169
            booleanCombo.add(textTrue + Messages.Preference_Use_Default);
170 170
            booleanCombo.add(textFalse);
171 171
        }else{
172 172
            booleanCombo.add(textTrue);
173
            booleanCombo.add(textFalse +" (Use Default)");
173
            booleanCombo.add(textFalse + Messages.Preference_Use_Default);
174 174
        }
175 175
        return booleanCombo;
176 176

  
......
204 204

  
205 205
        for (IKeyLabel value: enumValues){
206 206
            if (defaultValue.equals(value.getKey())){
207
                booleanCombo.add(value.getLabel() + " (Use Default)");
207
                booleanCombo.add(value.getLabel() + Messages.Preference_Use_Default);
208 208
            }else{
209 209
                booleanCombo.add(value.getLabel());
210 210
            }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/NomenclaturalCodePreferences.java
10 10

  
11 11
import java.util.List;
12 12

  
13
import org.eclipse.jface.preference.BooleanFieldEditor;
14 13
import org.eclipse.jface.preference.ComboFieldEditor;
15 14

  
16 15
import eu.etaxonomy.cdm.api.application.ICdmRepository;
......
40 39
	    PreferencesUtil.setPreferredNomenclaturalCode(null, false);
41 40
	    if (pref.isAllowOverride()) {
42 41
	        addField(new ComboFieldEditor(
43
	                PreferencesUtil.createPreferenceString(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NomenclaturalCode.getKey())),
42
	                PreferencesUtil.createPreferenceString(PreferencePredicate.NomenclaturalCode.getKey()),
44 43
				Messages.NomenclaturalCodePreferences_available_codes, getLabelAndValues(),
45 44
				getFieldEditorParent()));
46 45

  
47
            addField(new BooleanFieldEditor(
48
                    PreferencesUtil.createPreferenceString(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NomenclaturalCode.getKey())),
49
                    Messages.NomenclaturalCodePreferences_useLocalCode,
50
                    getFieldEditorParent()));
46

  
51 47
        } else {
52 48
            setDescription(Messages.NomenclaturalCodePreferences_localChangesNotAllowed);
53 49
        }
......
61 57
		List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
62 58
				.getSupportedCodes();
63 59
		String[][] labelAndValues = new String[supportedCodes.size()][2];
60
		String label;
64 61
		for (int i = 0; i < supportedCodes.size(); i++) {
65
			labelAndValues[i][0] = NomenclaturalCodeHelper
66
					.getDescription(supportedCodes.get(i));
62
		    label = NomenclaturalCodeHelper
63
                    .getDescription(supportedCodes.get(i));
64
		    String value = supportedCodes.get(i).toString();
65
		    String prefValue = pref.getValue();
66
		    if (pref.getValue().equals(supportedCodes.get(i).toString())) {
67
		         label +=Messages.Preference_Use_Default;
68
            }
69
		    labelAndValues[i][0] = label;
67 70
			labelAndValues[i][1] = PreferencesUtil
68 71
					.getPreferenceKey(supportedCodes.get(i));
69 72
		}
......
104 107
	 public boolean performOk() {
105 108

  
106 109
		boolean result = super.performOk();
107
//		if (result){
108
//			String value = getPreferenceStore().getString(IPreferenceKeys.PREFERRED_NOMENCLATURAL_CODE_KEY);
109
//			CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NomenclaturalCode, value);
110
//			ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
111
//			if (controller == null){
112
//				return false;
113
//			}
114
//			IPreferenceService service = controller.getPreferenceService();
115
//			service.set(pref);
116
//		}
117
        return result;
118
    }
110
		String value = pref.getValue();
111
		String test = PreferencesUtil.getStringValue(PreferencePredicate.NomenclaturalCode.getKey(), true);
112
		if (!pref.getValue().equals(PreferencesUtil.getStringValue(PreferencePredicate.NomenclaturalCode.getKey(), true))) {
113
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NomenclaturalCode.getKey()), true);
114
        }else{
115
            PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NomenclaturalCode.getKey()), false);
116
        }
117
		return result;
118
	}
119

  
119 120

  
120 121
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableVocabularyWizard.java
84 84
        Object[] checkedElements = aPage.getViewer().getCheckedElements();
85 85

  
86 86
        ArrayList<UUID> listUIIDChecked = new ArrayList<UUID>();
87
        int countChecked = 0;
87 88
        for (Object o : checkedElements) {
88 89
            if(o instanceof TermVocabularyDto){
89 90
                TermVocabularyDto vocDto = (TermVocabularyDto) o;
90 91
                listUIIDChecked.add(vocDto.getUuid());
92
                countChecked++;
91 93
            }
92 94
        }
93 95
        String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$
94

  
96
        int countVoc = aPage.getVocabularies().size();
95 97
        String predicate = null;
96 98
        pref = aPage.getPreference();
97 99
        if (pref != null){
......
99 101
        }
100 102

  
101 103
        if (!localPref){
102
            if (StringUtils.isBlank(saveCheckedElements)){
104
            if (StringUtils.isBlank(saveCheckedElements) || countChecked == countVoc){
103 105
                saveCheckedElements = null;
104 106
            }
105 107
            CdmPreference savePref = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.getByKey(predicate), saveCheckedElements);

Also available in: Unified diff