Project

General

Profile

Revision cf115b19

IDcf115b1978878f97d8471c8cebfbf8f90d336fd4
Parent 34ec6317
Child 793ded33

Added by Patrick Plitzner over 1 year ago

ref #8385 Remove publish flag preference when set to default

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/PublishFlagPreference.java
40 40
        if (!isApply()){
41 41
            return true;
42 42
        }
43
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
44
        if (controller == null){
45
            return false;
46
        }
47
        IPreferenceService service = controller.getPreferenceService();
43 48
        String text = publishFlagBehaviour.getText();
44
        text = text.replace(Messages.Preference_Use_Default, "");
49
        // default -> delete preference
50
        if(text.equals(Messages.Preference_Use_Default)){
51
            service.remove(pref.getKey());
52
            PreferencesUtil.updateDBPreferences();
53
            return true;
54
        }
55

  
45 56
        for (PublishEnum display: PublishEnum.values()){
46 57
            if (display.getLabel().equals(text)){
47 58
                text = display.getKey();
......
51 62
        CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DefaultBehaviourForPublishFlag, text);
52 63
        pref.setAllowOverride(allowOverride);
53 64

  
54
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
55
        if (controller == null){
56
            return false;
57
        }
58
        IPreferenceService service = controller.getPreferenceService();
59 65
        service.set(pref);
60 66
        PreferencesUtil.updateDBPreferences();
61 67

  
......
70 76
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
71 77
        if (pref == null){
72 78
            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DefaultBehaviourForPublishFlag, ((PublishEnum)PreferencePredicate.DefaultBehaviourForPublishFlag.getDefaultValue()).getKey());
79
            publishBehaviour = null;
80
            allowOverride = pref.isAllowOverride();
81
        }
82
        else {
83
            allowOverride = pref.isAllowOverride();
84
            publishBehaviour = PublishEnum.valueOf(pref.getValue());
73 85
        }
74
        allowOverride = pref.isAllowOverride();
75
        publishBehaviour = PublishEnum.valueOf(pref.getValue());
76 86
    }
77 87

  
78 88

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PublishFlagLocalPreference.java
112 112
        }
113 113
        int index = 0;
114 114

  
115

  
116
        for (String itemLabel : publishFlagBehaviour.getItems()){
117
           if (itemLabel.startsWith(publishBehaviour.getLabel())){
118
                publishFlagBehaviour.select(index);
119
                break;
115
        if(publishBehaviour==null){
116
            publishFlagBehaviour.select(0);
117
        }
118
        else{
119
            for (String itemLabel : publishFlagBehaviour.getItems()){
120
                if (itemLabel.startsWith(publishBehaviour.getLabel())){
121
                    publishFlagBehaviour.select(index);
122
                    break;
123
                }
124
                index++;
120 125
            }
121
            index++;
122 126
        }
123 127

  
124 128
        return composite;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)