Project

General

Profile

« Previous | Next » 

Revision 9fe7e119

Added by Katja Luther almost 5 years ago

ref #8045: show possible entries for preferences in combo boxes and show default value

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PublishFlagLocalPreference.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.preference;
10 10

  
11
import java.util.ArrayList;
12
import java.util.List;
13

  
11 14
import org.eclipse.swt.SWT;
12 15
import org.eclipse.swt.custom.CLabel;
13 16
import org.eclipse.swt.events.SelectionAdapter;
......
58 61
        }
59 62
        allowOverride = pref.isAllowOverride();
60 63
        Composite composite = createComposite(parent);
61
        final CLabel description = new CLabel(composite, SWT.NULL);
64

  
62 65
        if (!allowOverride && !isAdminPreference){
66
            final CLabel description = new CLabel(composite, SWT.NULL);
63 67
            description.setText(Messages.PublishFlagPreference_description_not_allowed);
64 68
            description.setLayoutData(createTextGridData());
65 69
            return composite;
66 70
        }
67 71

  
68 72

  
69
        description.setText(Messages.PublishFlagPreference_description);
70
        description.setLayoutData(createTextGridData());
71
        publishFlagBehaviour = new Combo(composite, SWT.READ_ONLY);
73
//        description.setText(Messages.PublishFlagPreference_description);
74
//        description.setLayoutData(createTextGridData());
75
//        publishFlagBehaviour = new Combo(composite, SWT.READ_ONLY);
76
        List<String> enumValues = new ArrayList();
72 77

  
73
        publishFlagBehaviour.setFont(parent.getFont());
74
        for(PublishEnum display: PublishEnum.values()){
75
            publishFlagBehaviour.add(display.getLabel());
76
        }
78
        publishFlagBehaviour = createCombo(composite, PublishEnum.values(), PreferencePredicate.DefaultBehaviourForPublishFlag, Messages.PublishFlagPreference_description, isAdminPreference);
79

  
80
//        publishFlagBehaviour.setFont(parent.getFont());
81
//        for(PublishEnum display: PublishEnum.values()){
82
//            if (pref.getValue().equals(display.getKey())){
83
//                publishFlagBehaviour.add(display.getLabel() + " (Default)");
84
//            }
85
//            else
86
//        }
77 87

  
78 88
        publishFlagBehaviour.addSelectionListener(new SelectionListener() {
79 89

  
......
88 98

  
89 99
            }
90 100
        });
91
        allowOverrideButton = createAllowOverrideButton(composite);
92
        allowOverrideButton.setText(Messages.GeneralPreference_override);
93
        allowOverrideButton.setSelection(allowOverride);
94
        allowOverrideButton.addSelectionListener(new SelectionAdapter(){
95
            @Override
96
            public void widgetSelected(SelectionEvent e) {
97
                allowOverride = !allowOverride;
98
                setApply(true);
99
                }
100
        });
101

  
101
        if (this.isAdminPreference){
102
            allowOverrideButton = createAllowOverrideButton(composite);
103
            allowOverrideButton.setText(Messages.GeneralPreference_override);
104
            allowOverrideButton.setSelection(allowOverride);
105
            allowOverrideButton.addSelectionListener(new SelectionAdapter(){
106
                @Override
107
                public void widgetSelected(SelectionEvent e) {
108
                    allowOverride = !allowOverride;
109
                    setApply(true);
110
                    }
111
            });
112
        }
102 113
        int index = 0;
103 114

  
104 115

  
105 116
        for (String itemLabel : publishFlagBehaviour.getItems()){
106
            if (itemLabel.equalsIgnoreCase(publishBehaviour.getLabel())){
117
           if (itemLabel.startsWith(publishBehaviour.getLabel())){
107 118
                publishFlagBehaviour.select(index);
108 119
                break;
109 120
            }
......
120 131
        if (publishFlagBehaviour != null){
121 132
            String text = publishFlagBehaviour.getText();
122 133
            for (PublishEnum display: PublishEnum.values()){
123
                if (display.getLabel().equals(text)){
134
                if (text.startsWith(display.getLabel())){
124 135
                    text = display.getKey();
125 136
                    break;
126 137
                }
......
143 154

  
144 155
    @Override
145 156
    protected void performDefaults() {
146
        publishBehaviour = (PublishEnum)PreferencePredicate.DefaultBehaviourForPublishFlag.getDefaultValue();
157
        publishBehaviour = PublishEnum.valueOf(pref.getValue());
147 158
        allowOverride = true;
148 159
        int index = 0;
149 160
        for (String itemLabel : publishFlagBehaviour.getItems()){
150
            if (itemLabel.equalsIgnoreCase(publishBehaviour.getLabel())){
161
            if (itemLabel.startsWith(publishBehaviour.getLabel())){
151 162
                publishFlagBehaviour.select(index);
152 163
                break;
153 164
            }

Also available in: Unified diff