This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 216013
Collapse All | Expand All

(-)a/openide.awt/apichanges.xml (+13 lines)
Lines 50-55 Link Here
50
<apidef name="awt">AWT API</apidef>
50
<apidef name="awt">AWT API</apidef>
51
</apidefs>
51
</apidefs>
52
<changes>
52
<changes>
53
    <change id="ColorComboBox">
54
      <api name="awt"/>
55
      <summary>ColorComboBox for color selection.</summary>
56
      <version major="7" minor="49"/>
57
      <date day="26" month="7" year="2012"/>
58
      <author login="saubrecht"/>
59
      <compatibility addition="yes" binary="compatible" source="compatible" deprecation="no" semantic="compatible" modification="no" deletion="no"/>
60
      <description>
61
          There's a new class ColorComboBox that can be used as color picker.
62
      </description>
63
      <class package="org.openide.awt" name="ColorComboBox"/>
64
      <issue number="216013"/>
65
    </change>
53
    <change id="TabbedPaneFactorySubClass">
66
    <change id="TabbedPaneFactorySubClass">
54
      <api name="awt"/>
67
      <api name="awt"/>
55
      <summary>TabbedPaneFactory can be subclassed.</summary>
68
      <summary>TabbedPaneFactory can be subclassed.</summary>
(-)a/openide.awt/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.openide.awt
2
OpenIDE-Module: org.openide.awt
3
OpenIDE-Module-Localizing-Bundle: org/openide/awt/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/awt/Bundle.properties
4
AutoUpdate-Essential-Module: true
4
AutoUpdate-Essential-Module: true
5
OpenIDE-Module-Specification-Version: 7.48
5
OpenIDE-Module-Specification-Version: 7.49
6
6
(-)a/openide.awt/src/org/openide/awt/Bundle.properties (+18 lines)
Lines 125-127 Link Here
125
# either: default, never or always
125
# either: default, never or always
126
#NOI18N
126
#NOI18N
127
USE_MNEMONICS=default
127
USE_MNEMONICS=default
128
129
#ColorComboBox
130
Custom=Custom ...
131
Black=Black
132
Blue=Blue
133
Cyan=Cyan
134
Dark_Gray=Dark Gray
135
Gray=Gray
136
Green=Green
137
Light_Gray=Light Gray
138
Magenta=Magenta
139
Orange=Orange
140
Pink=Pink
141
Red=Red
142
White=White
143
Yellow=Yellow
144
145
SelectColor=Select Color
(-)a/options.editor/src/org/netbeans/modules/options/colors/AnnotationsPanel.form (-1 / +10 lines)
Lines 1-4 Link Here
1
<?xml version="1.1" encoding="UTF-8" ?>
1
<?xml version="1.0" encoding="UTF-8" ?>
2
2
3
<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
4
  <AuxValues>
Lines 121-126 Link Here
121
          <StringArray count="0"/>
121
          <StringArray count="0"/>
122
        </Property>
122
        </Property>
123
      </Properties>
123
      </Properties>
124
      <AuxValues>
125
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ColorComboBox();"/>
126
      </AuxValues>
124
    </Component>
127
    </Component>
125
    <Component class="javax.swing.JComboBox" name="cbBackground">
128
    <Component class="javax.swing.JComboBox" name="cbBackground">
126
      <Properties>
129
      <Properties>
Lines 128-133 Link Here
128
          <StringArray count="0"/>
131
          <StringArray count="0"/>
129
        </Property>
132
        </Property>
130
      </Properties>
133
      </Properties>
134
      <AuxValues>
135
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ColorComboBox();"/>
136
      </AuxValues>
131
    </Component>
137
    </Component>
132
    <Component class="javax.swing.JComboBox" name="cbWaveUnderlined">
138
    <Component class="javax.swing.JComboBox" name="cbWaveUnderlined">
133
      <Properties>
139
      <Properties>
Lines 135-140 Link Here
135
          <StringArray count="0"/>
141
          <StringArray count="0"/>
136
        </Property>
142
        </Property>
137
      </Properties>
143
      </Properties>
144
      <AuxValues>
145
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ColorComboBox();"/>
146
      </AuxValues>
138
    </Component>
147
    </Component>
139
  </SubComponents>
148
  </SubComponents>
140
</Form>
149
</Form>
(-)a/options.editor/src/org/netbeans/modules/options/colors/AnnotationsPanel.java (-35 / +23 lines)
Lines 6-18 Link Here
6
6
7
package org.netbeans.modules.options.colors;
7
package org.netbeans.modules.options.colors;
8
8
9
import org.netbeans.modules.options.colors.spi.FontsColorsController;
10
import java.awt.Color;
9
import java.awt.Color;
11
import java.awt.Component;
10
import java.awt.Component;
12
import java.awt.event.ActionEvent;
11
import java.awt.event.ActionEvent;
13
import java.awt.event.ActionListener;
12
import java.awt.event.ActionListener;
14
import java.beans.PropertyChangeEvent;
13
import java.awt.event.ItemEvent;
15
import java.beans.PropertyChangeListener;
14
import java.awt.event.ItemListener;
16
import java.util.ArrayList;
15
import java.util.ArrayList;
17
import java.util.Collection;
16
import java.util.Collection;
18
import java.util.Collections;
17
import java.util.Collections;
Lines 34-39 Link Here
34
import javax.swing.text.SimpleAttributeSet;
33
import javax.swing.text.SimpleAttributeSet;
35
import javax.swing.text.StyleConstants;
34
import javax.swing.text.StyleConstants;
36
import org.netbeans.api.editor.settings.EditorStyleConstants;
35
import org.netbeans.api.editor.settings.EditorStyleConstants;
36
import org.netbeans.modules.options.colors.spi.FontsColorsController;
37
import org.openide.awt.ColorComboBox;
37
import org.openide.awt.Mnemonics;
38
import org.openide.awt.Mnemonics;
38
import org.openide.util.NbBundle;
39
import org.openide.util.NbBundle;
39
40
Lines 42-48 Link Here
42
 * @author  Jan Jancura
43
 * @author  Jan Jancura
43
 */
44
 */
44
public class AnnotationsPanel extends JPanel implements ActionListener, 
45
public class AnnotationsPanel extends JPanel implements ActionListener, 
45
    PropertyChangeListener, FontsColorsController {
46
    ItemListener, FontsColorsController {
46
    
47
    
47
    private ColorModel          colorModel;
48
    private ColorModel          colorModel;
48
    private boolean		listen = false;
49
    private boolean		listen = false;
Lines 67-75 Link Here
67
        cbWaveUnderlined.getAccessibleContext ().setAccessibleDescription (loc ("AD_Wave_Underlined"));
68
        cbWaveUnderlined.getAccessibleContext ().setAccessibleDescription (loc ("AD_Wave_Underlined"));
68
        lCategories.getAccessibleContext ().setAccessibleName (loc ("AN_Categories"));
69
        lCategories.getAccessibleContext ().setAccessibleName (loc ("AN_Categories"));
69
        lCategories.getAccessibleContext ().setAccessibleDescription (loc ("AD_Categories"));
70
        lCategories.getAccessibleContext ().setAccessibleDescription (loc ("AD_Categories"));
70
        ColorComboBox.init (cbForeground);
71
        ColorComboBox.init (cbBackground);
72
        ColorComboBox.init (cbWaveUnderlined);
73
        lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
71
        lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
74
        lCategories.setVisibleRowCount (3);
72
        lCategories.setVisibleRowCount (3);
75
        lCategories.addListSelectionListener (new ListSelectionListener () {
73
        lCategories.addListSelectionListener (new ListSelectionListener () {
Lines 79-90 Link Here
79
            }
77
            }
80
        });
78
        });
81
	lCategories.setCellRenderer (new CategoryRenderer ());
79
	lCategories.setCellRenderer (new CategoryRenderer ());
82
        cbForeground.addPropertyChangeListener (this);
80
        cbForeground.addItemListener(this);
83
        ((JComponent)cbForeground.getEditor()).addPropertyChangeListener (this);
81
        cbBackground.addItemListener(this);
84
        cbBackground.addPropertyChangeListener (this);
82
        cbWaveUnderlined.addItemListener(this);
85
        ((JComponent)cbBackground.getEditor()).addPropertyChangeListener (this);
86
        cbWaveUnderlined.addPropertyChangeListener (this);
87
        ((JComponent)cbWaveUnderlined.getEditor()).addPropertyChangeListener (this);
88
        
83
        
89
        lCategory.setLabelFor (lCategories);
84
        lCategory.setLabelFor (lCategories);
90
        loc(lCategory, "CTL_Category");
85
        loc(lCategory, "CTL_Category");
Lines 107-115 Link Here
107
        lForeground = new javax.swing.JLabel();
102
        lForeground = new javax.swing.JLabel();
108
        lbackground = new javax.swing.JLabel();
103
        lbackground = new javax.swing.JLabel();
109
        lWaveUnderlined = new javax.swing.JLabel();
104
        lWaveUnderlined = new javax.swing.JLabel();
110
        cbForeground = new javax.swing.JComboBox();
105
        cbForeground = new ColorComboBox();
111
        cbBackground = new javax.swing.JComboBox();
106
        cbBackground = new ColorComboBox();
112
        cbWaveUnderlined = new javax.swing.JComboBox();
107
        cbWaveUnderlined = new ColorComboBox();
113
108
114
        lCategory.setText(org.openide.util.NbBundle.getMessage(AnnotationsPanel.class, "CTL_Category")); // NOI18N
109
        lCategory.setText(org.openide.util.NbBundle.getMessage(AnnotationsPanel.class, "CTL_Category")); // NOI18N
115
110
Lines 187-195 Link Here
187
        changed = true;
182
        changed = true;
188
    }
183
    }
189
    
184
    
190
    public void propertyChange (PropertyChangeEvent evt) {
185
    @Override
186
    public void itemStateChanged( ItemEvent e ) {
187
        if( e.getStateChange() == ItemEvent.DESELECTED )
188
            return;
191
        if (!listen) return;
189
        if (!listen) return;
192
        if (evt.getPropertyName () != ColorComboBox.PROP_COLOR) return;
193
        updateData ();
190
        updateData ();
194
    }
191
    }
195
    
192
    
Lines 271-291 Link Here
271
        Vector<AttributeSet> annotations = getAnnotations(currentScheme);
268
        Vector<AttributeSet> annotations = getAnnotations(currentScheme);
272
        SimpleAttributeSet c = (SimpleAttributeSet) annotations.get(lCategories.getSelectedIndex());
269
        SimpleAttributeSet c = (SimpleAttributeSet) annotations.get(lCategories.getSelectedIndex());
273
        
270
        
274
        Color color = ColorComboBox.getColor(cbBackground);
271
        Color color = ColorComboBoxSupport.getSelectedColor( (ColorComboBox)cbBackground );
275
        if (color != null) {
272
        if (color != null) {
276
            c.addAttribute(StyleConstants.Background, color);
273
            c.addAttribute(StyleConstants.Background, color);
277
        } else {
274
        } else {
278
            c.removeAttribute(StyleConstants.Background);
275
            c.removeAttribute(StyleConstants.Background);
279
        }
276
        }
280
        
277
        
281
        color = ColorComboBox.getColor(cbForeground);
278
        color = ColorComboBoxSupport.getSelectedColor( (ColorComboBox)cbForeground );
282
        if (color != null) {
279
        if (color != null) {
283
            c.addAttribute(StyleConstants.Foreground, color);
280
            c.addAttribute(StyleConstants.Foreground, color);
284
        } else {
281
        } else {
285
            c.removeAttribute(StyleConstants.Foreground);
282
            c.removeAttribute(StyleConstants.Foreground);
286
        }
283
        }
287
        
284
        
288
        color = ColorComboBox.getColor(cbWaveUnderlined);
285
        color = ColorComboBoxSupport.getSelectedColor( (ColorComboBox)cbWaveUnderlined );
289
        if (color != null) {
286
        if (color != null) {
290
            c.addAttribute(EditorStyleConstants.WaveUnderlineColor, color);
287
            c.addAttribute(EditorStyleConstants.WaveUnderlineColor, color);
291
        } else {
288
        } else {
Lines 317-346 Link Here
317
            if (inheritedForeground == null) {
314
            if (inheritedForeground == null) {
318
                inheritedForeground = Color.black;
315
                inheritedForeground = Color.black;
319
            }
316
            }
320
            ColorComboBox.setInheritedColor(cbForeground, inheritedForeground);
317
            ColorComboBoxSupport.setInheritedColor((ColorComboBox)cbForeground, inheritedForeground);
321
            
318
            
322
            Color inheritedBackground = (Color) defAs.getAttribute(StyleConstants.Background);
319
            Color inheritedBackground = (Color) defAs.getAttribute(StyleConstants.Background);
323
            if (inheritedBackground == null) {
320
            if (inheritedBackground == null) {
324
                inheritedBackground = Color.white;
321
                inheritedBackground = Color.white;
325
            }
322
            }
326
            ColorComboBox.setInheritedColor(cbBackground, inheritedBackground);
323
            ColorComboBoxSupport.setInheritedColor((ColorComboBox)cbBackground, inheritedBackground);
327
        }
324
        }
328
325
329
        // set values
326
        // set values
330
        Vector<AttributeSet> annotations = getAnnotations (currentScheme);
327
        Vector<AttributeSet> annotations = getAnnotations (currentScheme);
331
        AttributeSet c = annotations.get (index);
328
        AttributeSet c = annotations.get (index);
332
        ColorComboBox.setColor (
329
        ColorComboBoxSupport.setSelectedColor( (ColorComboBox)cbForeground, (Color) c.getAttribute (StyleConstants.Foreground));
333
            cbForeground,
330
        ColorComboBoxSupport.setSelectedColor( (ColorComboBox)cbBackground, (Color) c.getAttribute (StyleConstants.Background));
334
            (Color) c.getAttribute (StyleConstants.Foreground)
331
        ((ColorComboBox)cbWaveUnderlined).setSelectedColor((Color) c.getAttribute (EditorStyleConstants.WaveUnderlineColor));
335
        );
336
        ColorComboBox.setColor (
337
            cbBackground,
338
            (Color) c.getAttribute (StyleConstants.Background)
339
        );
340
        ColorComboBox.setColor (
341
            cbWaveUnderlined,
342
            (Color) c.getAttribute (EditorStyleConstants.WaveUnderlineColor)
343
        );
344
        listen = true;
332
        listen = true;
345
    }
333
    }
346
    
334
    
(-)a/options.editor/src/org/netbeans/modules/options/colors/ColorValue.java (-1 / +1 lines)
Lines 97-102 Link Here
97
    }
97
    }
98
    
98
    
99
    private static String loc (String key) {
99
    private static String loc (String key) {
100
        return NbBundle.getMessage (ColorComboBox.class, key);
100
        return NbBundle.getMessage (ColorComboBoxSupport.class, key);
101
    }
101
    }
102
}
102
}
(-)a/options.editor/src/org/netbeans/modules/options/colors/HighlightingPanel.form (+6 lines)
Lines 107-112 Link Here
107
          <StringArray count="0"/>
107
          <StringArray count="0"/>
108
        </Property>
108
        </Property>
109
      </Properties>
109
      </Properties>
110
      <AuxValues>
111
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ColorComboBox();"/>
112
      </AuxValues>
110
    </Component>
113
    </Component>
111
    <Component class="javax.swing.JComboBox" name="cbForeground">
114
    <Component class="javax.swing.JComboBox" name="cbForeground">
112
      <Properties>
115
      <Properties>
Lines 114-119 Link Here
114
          <StringArray count="0"/>
117
          <StringArray count="0"/>
115
        </Property>
118
        </Property>
116
      </Properties>
119
      </Properties>
120
      <AuxValues>
121
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ColorComboBox();"/>
122
      </AuxValues>
117
    </Component>
123
    </Component>
118
  </SubComponents>
124
  </SubComponents>
119
</Form>
125
</Form>
(-)a/options.editor/src/org/netbeans/modules/options/colors/HighlightingPanel.java (-29 / +20 lines)
Lines 44-56 Link Here
44
44
45
package org.netbeans.modules.options.colors;
45
package org.netbeans.modules.options.colors;
46
46
47
import org.netbeans.modules.options.colors.spi.FontsColorsController;
48
import java.awt.Color;
47
import java.awt.Color;
49
import java.awt.Component;
48
import java.awt.Component;
50
import java.awt.event.ActionEvent;
49
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionListener;
50
import java.awt.event.ActionListener;
52
import java.beans.PropertyChangeEvent;
51
import java.awt.event.ItemEvent;
53
import java.beans.PropertyChangeListener;
52
import java.awt.event.ItemListener;
54
import java.util.ArrayList;
53
import java.util.ArrayList;
55
import java.util.Collection;
54
import java.util.Collection;
56
import java.util.Collections;
55
import java.util.Collections;
Lines 71-76 Link Here
71
import javax.swing.text.AttributeSet;
70
import javax.swing.text.AttributeSet;
72
import javax.swing.text.SimpleAttributeSet;
71
import javax.swing.text.SimpleAttributeSet;
73
import javax.swing.text.StyleConstants;
72
import javax.swing.text.StyleConstants;
73
import org.netbeans.modules.options.colors.spi.FontsColorsController;
74
import org.openide.awt.ColorComboBox;
74
import org.openide.awt.Mnemonics;
75
import org.openide.awt.Mnemonics;
75
import org.openide.util.NbBundle;
76
import org.openide.util.NbBundle;
76
77
Lines 78-84 Link Here
78
 *
79
 *
79
 * @author  Jan Jancura
80
 * @author  Jan Jancura
80
 */
81
 */
81
public class HighlightingPanel extends JPanel implements ActionListener, PropertyChangeListener, FontsColorsController {
82
public class HighlightingPanel extends JPanel implements ActionListener, ItemListener, FontsColorsController {
82
    
83
    
83
    private ColorModel          colorModel = null;
84
    private ColorModel          colorModel = null;
84
    private boolean             listen = false;
85
    private boolean             listen = false;
Lines 103-110 Link Here
103
        cbForeground.getAccessibleContext ().setAccessibleDescription (loc ("AD_Foreground_Chooser"));
104
        cbForeground.getAccessibleContext ().setAccessibleDescription (loc ("AD_Foreground_Chooser"));
104
        cbBackground.getAccessibleContext ().setAccessibleName (loc ("AN_Background_Chooser"));
105
        cbBackground.getAccessibleContext ().setAccessibleName (loc ("AN_Background_Chooser"));
105
        cbBackground.getAccessibleContext ().setAccessibleDescription (loc ("AD_Background_Chooser"));
106
        cbBackground.getAccessibleContext ().setAccessibleDescription (loc ("AD_Background_Chooser"));
106
        ColorComboBox.init (cbForeground);
107
        ColorComboBox.init (cbBackground);
108
        lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
107
        lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
109
        lCategories.setVisibleRowCount (3);
108
        lCategories.setVisibleRowCount (3);
110
        lCategories.addListSelectionListener (new ListSelectionListener () {
109
        lCategories.addListSelectionListener (new ListSelectionListener () {
Lines 115-124 Link Here
115
            }
114
            }
116
        });
115
        });
117
        lCategories.setCellRenderer (new CategoryRenderer ());
116
        lCategories.setCellRenderer (new CategoryRenderer ());
118
        cbForeground.addActionListener (this);
117
        cbForeground.addItemListener(this);
119
        ((JComponent) cbForeground.getEditor ()).addPropertyChangeListener (this);
118
        cbBackground.addItemListener (this);
120
        cbBackground.addActionListener (this);
121
        ((JComponent) cbBackground.getEditor ()).addPropertyChangeListener (this);
122
119
123
        lCategory.setLabelFor (lCategories);
120
        lCategory.setLabelFor (lCategories);
124
        loc (lCategory, "CTL_Category");
121
        loc (lCategory, "CTL_Category");
Lines 139-146 Link Here
139
        lCategories = new javax.swing.JList();
136
        lCategories = new javax.swing.JList();
140
        lForeground = new javax.swing.JLabel();
137
        lForeground = new javax.swing.JLabel();
141
        lBackground = new javax.swing.JLabel();
138
        lBackground = new javax.swing.JLabel();
142
        cbBackground = new javax.swing.JComboBox();
139
        cbBackground = new ColorComboBox();
143
        cbForeground = new javax.swing.JComboBox();
140
        cbForeground = new ColorComboBox();
144
141
145
        lCategory.setText(org.openide.util.NbBundle.getMessage(HighlightingPanel.class, "CTL_Category")); // NOI18N
142
        lCategory.setText(org.openide.util.NbBundle.getMessage(HighlightingPanel.class, "CTL_Category")); // NOI18N
146
143
Lines 210-221 Link Here
210
    }
207
    }
211
    
208
    
212
    @Override
209
    @Override
213
    public void propertyChange (PropertyChangeEvent evt) {
210
    public void itemStateChanged( ItemEvent e ) {
211
        if( e.getStateChange() == ItemEvent.DESELECTED )
212
            return;
214
        if (!listen) return;
213
        if (!listen) return;
215
        if (ColorComboBox.PROP_COLOR.equals (evt.getPropertyName ())) {
214
        updateData ();
216
            updateData ();
215
        changed = true;
217
            changed = true;
218
        }
219
    }
216
    }
220
    
217
    
221
    @Override
218
    @Override
Lines 321-334 Link Here
321
        AttributeSet category = categories.get(lCategories.getSelectedIndex());
318
        AttributeSet category = categories.get(lCategories.getSelectedIndex());
322
        SimpleAttributeSet c = new SimpleAttributeSet(category);
319
        SimpleAttributeSet c = new SimpleAttributeSet(category);
323
        
320
        
324
        Color color = ColorComboBox.getColor(cbBackground);
321
        Color color = ColorComboBoxSupport.getSelectedColor( (ColorComboBox)cbBackground );
325
        if (color != null) {
322
        if (color != null) {
326
            c.addAttribute(StyleConstants.Background, color);
323
            c.addAttribute(StyleConstants.Background, color);
327
        } else {
324
        } else {
328
            c.removeAttribute(StyleConstants.Background);
325
            c.removeAttribute(StyleConstants.Background);
329
        }
326
        }
330
        
327
        
331
        color = ColorComboBox.getColor(cbForeground);
328
        color = ColorComboBoxSupport.getSelectedColor( (ColorComboBox)cbForeground );
332
        if (color != null) {
329
        if (color != null) {
333
            c.addAttribute(StyleConstants.Foreground, color);
330
            c.addAttribute(StyleConstants.Foreground, color);
334
        } else {
331
        } else {
Lines 361-384 Link Here
361
            if (inheritedForeground == null) {
358
            if (inheritedForeground == null) {
362
                inheritedForeground = Color.black;
359
                inheritedForeground = Color.black;
363
            }
360
            }
364
            ColorComboBox.setInheritedColor(cbForeground, inheritedForeground);
361
            ColorComboBoxSupport.setInheritedColor((ColorComboBox)cbForeground, inheritedForeground);
365
            
362
            
366
            Color inheritedBackground = (Color) defAs.getAttribute(StyleConstants.Background);
363
            Color inheritedBackground = (Color) defAs.getAttribute(StyleConstants.Background);
367
            if (inheritedBackground == null) {
364
            if (inheritedBackground == null) {
368
                inheritedBackground = Color.white;
365
                inheritedBackground = Color.white;
369
            }
366
            }
370
            ColorComboBox.setInheritedColor(cbBackground, inheritedBackground);
367
            ColorComboBoxSupport.setInheritedColor((ColorComboBox)cbBackground, inheritedBackground);
371
        }
368
        }
372
        
369
        
373
        // set values
370
        // set values
374
        ColorComboBox.setColor (
371
        ColorComboBoxSupport.setSelectedColor((ColorComboBox)cbForeground, (Color) category.getAttribute (StyleConstants.Foreground));
375
            cbForeground, 
372
        ColorComboBoxSupport.setSelectedColor((ColorComboBox)cbBackground, (Color) category.getAttribute (StyleConstants.Background));
376
            (Color) category.getAttribute (StyleConstants.Foreground)
377
        );
378
        ColorComboBox.setColor (
379
            cbBackground,
380
            (Color) category.getAttribute (StyleConstants.Background)
381
        );
382
        listen = true;
373
        listen = true;
383
    }
374
    }
384
    
375
    
(-)a/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.form (+9 lines)
Lines 219-224 Link Here
219
          <StringArray count="0"/>
219
          <StringArray count="0"/>
220
        </Property>
220
        </Property>
221
      </Properties>
221
      </Properties>
222
      <AuxValues>
223
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new org.openide.awt.ColorComboBox();"/>
224
      </AuxValues>
222
    </Component>
225
    </Component>
223
    <Component class="javax.swing.JComboBox" name="cbBackground">
226
    <Component class="javax.swing.JComboBox" name="cbBackground">
224
      <Properties>
227
      <Properties>
Lines 226-231 Link Here
226
          <StringArray count="0"/>
229
          <StringArray count="0"/>
227
        </Property>
230
        </Property>
228
      </Properties>
231
      </Properties>
232
      <AuxValues>
233
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ColorComboBox();"/>
234
      </AuxValues>
229
    </Component>
235
    </Component>
230
    <Component class="javax.swing.JComboBox" name="cbEffects">
236
    <Component class="javax.swing.JComboBox" name="cbEffects">
231
      <Properties>
237
      <Properties>
Lines 240-245 Link Here
240
          <StringArray count="0"/>
246
          <StringArray count="0"/>
241
        </Property>
247
        </Property>
242
      </Properties>
248
      </Properties>
249
      <AuxValues>
250
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ColorComboBox();"/>
251
      </AuxValues>
243
    </Component>
252
    </Component>
244
    <Component class="javax.swing.JTextField" name="tfFont">
253
    <Component class="javax.swing.JTextField" name="tfFont">
245
    </Component>
254
    </Component>
(-)a/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java (-59 / +36 lines)
Lines 44-56 Link Here
44
44
45
package org.netbeans.modules.options.colors;
45
package org.netbeans.modules.options.colors;
46
46
47
import org.netbeans.modules.options.colors.spi.FontsColorsController;
48
import java.awt.Color;
47
import java.awt.Color;
49
import java.awt.Component;
48
import java.awt.Component;
50
import java.awt.Font;
49
import java.awt.Font;
51
import java.awt.Insets;
50
import java.awt.Insets;
52
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionEvent;
53
import java.awt.event.ActionListener;
52
import java.awt.event.ActionListener;
53
import java.awt.event.ItemEvent;
54
import java.awt.event.ItemListener;
54
import java.beans.PropertyChangeEvent;
55
import java.beans.PropertyChangeEvent;
55
import java.beans.PropertyChangeListener;
56
import java.beans.PropertyChangeListener;
56
import java.beans.PropertyEditor;
57
import java.beans.PropertyEditor;
Lines 83-90 Link Here
83
import org.netbeans.api.editor.settings.FontColorNames;
84
import org.netbeans.api.editor.settings.FontColorNames;
84
import org.netbeans.api.editor.settings.FontColorSettings;
85
import org.netbeans.api.editor.settings.FontColorSettings;
85
import org.netbeans.modules.options.colors.ColorModel.Preview;
86
import org.netbeans.modules.options.colors.ColorModel.Preview;
87
import org.netbeans.modules.options.colors.spi.FontsColorsController;
86
import org.openide.DialogDescriptor;
88
import org.openide.DialogDescriptor;
87
import org.openide.DialogDisplayer;
89
import org.openide.DialogDisplayer;
90
import org.openide.awt.ColorComboBox;
88
import org.openide.awt.Mnemonics;
91
import org.openide.awt.Mnemonics;
89
import org.openide.util.NbBundle;
92
import org.openide.util.NbBundle;
90
import org.openide.util.RequestProcessor;
93
import org.openide.util.RequestProcessor;
Lines 95-101 Link Here
95
 * @author  Jan Jancura
98
 * @author  Jan Jancura
96
 */
99
 */
97
public class SyntaxColoringPanel extends JPanel implements ActionListener, 
100
public class SyntaxColoringPanel extends JPanel implements ActionListener, 
98
    PropertyChangeListener, FontsColorsController {
101
    PropertyChangeListener, FontsColorsController, ItemListener {
99
    
102
    
100
    
103
    
101
    private Preview             preview;
104
    private Preview             preview;
Lines 131-139 Link Here
131
        cbEffects.getAccessibleContext ().setAccessibleDescription (loc ("AD_Efects_Color_Chooser"));
134
        cbEffects.getAccessibleContext ().setAccessibleDescription (loc ("AD_Efects_Color_Chooser"));
132
        cbEffectColor.getAccessibleContext ().setAccessibleName (loc ("AN_Efects_Color"));
135
        cbEffectColor.getAccessibleContext ().setAccessibleName (loc ("AN_Efects_Color"));
133
        cbEffectColor.getAccessibleContext ().setAccessibleDescription (loc ("AD_Efects_Color"));
136
        cbEffectColor.getAccessibleContext ().setAccessibleDescription (loc ("AD_Efects_Color"));
134
        ColorComboBox.init (cbBackground);
135
        ColorComboBox.init (cbForeground);
136
        ColorComboBox.init (cbEffectColor);
137
        cbLanguage.addActionListener (this);
137
        cbLanguage.addActionListener (this);
138
        lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
138
        lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
139
        lCategories.setVisibleRowCount (3);
139
        lCategories.setVisibleRowCount (3);
Lines 149-159 Link Here
149
        tfFont.setEditable (false);
149
        tfFont.setEditable (false);
150
        bFont.addActionListener (this);
150
        bFont.addActionListener (this);
151
        bFont.setMargin (new Insets (0, 0, 0, 0));
151
        bFont.setMargin (new Insets (0, 0, 0, 0));
152
        cbForeground.addActionListener (this);
152
        cbForeground.addItemListener(this);
153
        ((JComponent)cbForeground.getEditor()).addPropertyChangeListener (this);
153
        cbBackground.addItemListener(this);
154
155
        cbBackground.addActionListener (this);
156
        ((JComponent)cbBackground.getEditor()).addPropertyChangeListener (this);
157
        
154
        
158
        cbEffects.addItem (loc ("CTL_Effects_None"));
155
        cbEffects.addItem (loc ("CTL_Effects_None"));
159
        cbEffects.addItem (loc ("CTL_Effects_Underlined"));
156
        cbEffects.addItem (loc ("CTL_Effects_Underlined"));
Lines 162-169 Link Here
162
        cbEffects.getAccessibleContext ().setAccessibleName (loc ("AN_Effects"));
159
        cbEffects.getAccessibleContext ().setAccessibleName (loc ("AN_Effects"));
163
        cbEffects.getAccessibleContext ().setAccessibleDescription (loc ("AD_Effects"));
160
        cbEffects.getAccessibleContext ().setAccessibleDescription (loc ("AD_Effects"));
164
        cbEffects.addActionListener (this);
161
        cbEffects.addActionListener (this);
165
        ((JComponent)cbEffectColor.getEditor()).addPropertyChangeListener (this);
162
        cbEffectColor.addItemListener(this);
166
        cbEffectColor.addActionListener (this);
167
        
163
        
168
        loc(bFont, "CTL_Font_button");
164
        loc(bFont, "CTL_Font_button");
169
        loc(lBackground, "CTL_Background_label");
165
        loc(lBackground, "CTL_Background_label");
Lines 208-217 Link Here
208
        lBackground = new javax.swing.JLabel();
204
        lBackground = new javax.swing.JLabel();
209
        lEffects = new javax.swing.JLabel();
205
        lEffects = new javax.swing.JLabel();
210
        lEffectColor = new javax.swing.JLabel();
206
        lEffectColor = new javax.swing.JLabel();
211
        cbForeground = new javax.swing.JComboBox();
207
        cbForeground = new org.openide.awt.ColorComboBox();
212
        cbBackground = new javax.swing.JComboBox();
208
        cbBackground = new ColorComboBox();
213
        cbEffects = new javax.swing.JComboBox();
209
        cbEffects = new javax.swing.JComboBox();
214
        cbEffectColor = new javax.swing.JComboBox();
210
        cbEffectColor = new ColorComboBox();
215
        tfFont = new javax.swing.JTextField();
211
        tfFont = new javax.swing.JTextField();
216
        bFont = new javax.swing.JButton();
212
        bFont = new javax.swing.JButton();
217
213
Lines 355-363 Link Here
355
    public void actionPerformed (ActionEvent evt) {
351
    public void actionPerformed (ActionEvent evt) {
356
        if (!listen) return;
352
        if (!listen) return;
357
	if (evt.getSource () == cbEffects) {
353
	if (evt.getSource () == cbEffects) {
354
            if (cbEffects.getSelectedIndex () == 0)
355
                cbEffectColor.setSelectedItem( null );
358
	    cbEffectColor.setEnabled (cbEffects.getSelectedIndex () > 0);
356
	    cbEffectColor.setEnabled (cbEffects.getSelectedIndex () > 0);
359
            if (cbEffects.getSelectedIndex () == 0)
360
                ColorComboBox.setColor (cbEffectColor, null);
361
            updateData ();
357
            updateData ();
362
	} else
358
	} else
363
	if (evt.getSource () == cbLanguage) {
359
	if (evt.getSource () == cbLanguage) {
Lines 438-445 Link Here
438
                    break;
434
                    break;
439
                }
435
                }
440
            }
436
            }
441
        } else if (ColorComboBox.PROP_COLOR.equals(evt.getPropertyName())) {
442
            updateData();
443
        }
437
        }
444
    }
438
    }
445
    
439
    
Lines 610-631 Link Here
610
              wave = null, 
604
              wave = null, 
611
              strikethrough = null;
605
              strikethrough = null;
612
        if (cbEffects.getSelectedIndex () == 1)
606
        if (cbEffects.getSelectedIndex () == 1)
613
            underline = ColorComboBox.getColor(cbEffectColor);
607
            underline = ((ColorComboBox)cbEffectColor).getSelectedColor();
614
        if (cbEffects.getSelectedIndex () == 2)
608
        if (cbEffects.getSelectedIndex () == 2)
615
            wave = ColorComboBox.getColor(cbEffectColor);
609
            wave = ((ColorComboBox)cbEffectColor).getSelectedColor();
616
        if (cbEffects.getSelectedIndex () == 3)
610
        if (cbEffects.getSelectedIndex () == 3)
617
            strikethrough = ColorComboBox.getColor(cbEffectColor);
611
            strikethrough = ((ColorComboBox)cbEffectColor).getSelectedColor();
618
        
612
        
619
        SimpleAttributeSet c = category != null ? new SimpleAttributeSet(category) : new SimpleAttributeSet();
613
        SimpleAttributeSet c = category != null ? new SimpleAttributeSet(category) : new SimpleAttributeSet();
620
        
614
        
621
        Color color = ColorComboBox.getColor(cbBackground);
615
        Color color = ColorComboBoxSupport.getSelectedColor( (ColorComboBox)cbBackground );
622
        if (color != null) {
616
        if (color != null) {
623
            c.addAttribute(StyleConstants.Background, color);
617
            c.addAttribute(StyleConstants.Background, color);
624
        } else {
618
        } else {
625
            c.removeAttribute(StyleConstants.Background);
619
            c.removeAttribute(StyleConstants.Background);
626
        }
620
        }
627
        
621
        
628
        color = ColorComboBox.getColor(cbForeground);
622
        color = ColorComboBoxSupport.getSelectedColor( (ColorComboBox)cbForeground );
629
        if (color != null) {
623
        if (color != null) {
630
            c.addAttribute(StyleConstants.Foreground, color);
624
            c.addAttribute(StyleConstants.Foreground, color);
631
        } else {
625
        } else {
Lines 724-730 Link Here
724
            bFont.setEnabled (false);
718
            bFont.setEnabled (false);
725
            cbEffects.setEnabled (false);
719
            cbEffects.setEnabled (false);
726
            cbForeground.setEnabled (false);
720
            cbForeground.setEnabled (false);
727
            cbForeground.setSelectedItem (new ColorValue (null, null));
721
            ((org.openide.awt.ColorComboBox)cbForeground).setSelectedColor( null );
728
            cbBackground.setEnabled (false);
722
            cbBackground.setEnabled (false);
729
            cbBackground.setSelectedItem (new ColorValue (null, null));
723
            cbBackground.setSelectedItem (new ColorValue (null, null));
730
            cbEffectColor.setEnabled (false);
724
            cbEffectColor.setEnabled (false);
Lines 741-810 Link Here
741
        Color inheritedForeground = (Color) getDefault 
735
        Color inheritedForeground = (Color) getDefault 
742
            (currentLanguage, category, StyleConstants.Foreground);
736
            (currentLanguage, category, StyleConstants.Foreground);
743
        if (inheritedForeground == null) inheritedForeground = Color.black;
737
        if (inheritedForeground == null) inheritedForeground = Color.black;
744
        ColorComboBox.setInheritedColor (cbForeground, inheritedForeground);
738
        ColorComboBoxSupport.setInheritedColor ((ColorComboBox)cbForeground, inheritedForeground);
745
        Color inheritedBackground = (Color) getDefault 
739
        Color inheritedBackground = (Color) getDefault 
746
            (currentLanguage, category, StyleConstants.Background);
740
            (currentLanguage, category, StyleConstants.Background);
747
        if (inheritedBackground == null) inheritedBackground = Color.white;
741
        if (inheritedBackground == null) inheritedBackground = Color.white;
748
        ColorComboBox.setInheritedColor (cbBackground, inheritedBackground);
742
        ColorComboBoxSupport.setInheritedColor ((ColorComboBox)cbBackground, inheritedBackground);
749
        
743
        
750
        String font = fontToString (category);
744
        String font = fontToString (category);
751
        tfFont.setText (font);
745
        tfFont.setText (font);
752
        ColorComboBox.setColor (
746
        ColorComboBoxSupport.setSelectedColor( (ColorComboBox)cbForeground, (Color) category.getAttribute (StyleConstants.Foreground));
753
            cbForeground,
747
        ColorComboBoxSupport.setSelectedColor( (ColorComboBox)cbBackground, (Color) category.getAttribute (StyleConstants.Background));
754
            (Color) category.getAttribute (StyleConstants.Foreground)
755
        );
756
        ColorComboBox.setColor (
757
            cbBackground,
758
            (Color) category.getAttribute (StyleConstants.Background)
759
        );
760
        
748
        
761
        if (category.getAttribute (StyleConstants.Underline) != null) {
749
        if (category.getAttribute (StyleConstants.Underline) != null) {
762
            cbEffects.setSelectedIndex (1);
750
            cbEffects.setSelectedIndex (1);
763
            cbEffectColor.setEnabled (true);
751
            cbEffectColor.setEnabled (true);
764
            ColorComboBox.setColor (
752
            ((ColorComboBox)cbEffectColor).setSelectedColor((Color) category.getAttribute (StyleConstants.Underline));
765
                cbEffectColor,
766
                (Color) category.getAttribute (StyleConstants.Underline)
767
            );
768
        } else
753
        } else
769
        if (category.getAttribute (EditorStyleConstants.WaveUnderlineColor) != null) {
754
        if (category.getAttribute (EditorStyleConstants.WaveUnderlineColor) != null) {
770
            cbEffects.setSelectedIndex (2);
755
            cbEffects.setSelectedIndex (2);
771
            cbEffectColor.setEnabled (true);
756
            cbEffectColor.setEnabled (true);
772
            ColorComboBox.setColor (
757
            ((ColorComboBox)cbEffectColor).setSelectedColor((Color) category.getAttribute (EditorStyleConstants.WaveUnderlineColor));
773
                cbEffectColor,
774
                (Color) category.getAttribute (EditorStyleConstants.WaveUnderlineColor)
775
            );
776
        } else
758
        } else
777
        if (category.getAttribute (StyleConstants.StrikeThrough) != null) {
759
        if (category.getAttribute (StyleConstants.StrikeThrough) != null) {
778
            cbEffects.setSelectedIndex (3);
760
            cbEffects.setSelectedIndex (3);
779
            cbEffectColor.setEnabled (true);
761
            cbEffectColor.setEnabled (true);
780
            ColorComboBox.setColor (
762
            ((ColorComboBox)cbEffectColor).setSelectedColor((Color) category.getAttribute (StyleConstants.StrikeThrough));
781
                cbEffectColor,
782
                (Color) category.getAttribute (StyleConstants.StrikeThrough)
783
            );
784
        } else
763
        } else
785
        if (getDefault (currentLanguage, category, StyleConstants.Underline) != null) {
764
        if (getDefault (currentLanguage, category, StyleConstants.Underline) != null) {
786
            cbEffects.setSelectedIndex (1);
765
            cbEffects.setSelectedIndex (1);
787
            cbEffectColor.setEnabled (true);
766
            cbEffectColor.setEnabled (true);
788
            ColorComboBox.setColor (
767
            ((ColorComboBox)cbEffectColor).setSelectedColor((Color) getDefault (currentLanguage, category, StyleConstants.Underline));
789
                cbEffectColor,
790
                (Color) getDefault (currentLanguage, category, StyleConstants.Underline)
791
            );
792
        } else
768
        } else
793
        if (getDefault (currentLanguage, category, EditorStyleConstants.WaveUnderlineColor) != null) {
769
        if (getDefault (currentLanguage, category, EditorStyleConstants.WaveUnderlineColor) != null) {
794
            cbEffects.setSelectedIndex (2);
770
            cbEffects.setSelectedIndex (2);
795
            cbEffectColor.setEnabled (true);
771
            cbEffectColor.setEnabled (true);
796
            ColorComboBox.setColor (
772
            ((ColorComboBox)cbEffectColor).setSelectedColor((Color) getDefault (currentLanguage, category, EditorStyleConstants.WaveUnderlineColor));
797
                cbEffectColor,
798
                (Color) getDefault (currentLanguage, category, EditorStyleConstants.WaveUnderlineColor)
799
            );
800
        } else
773
        } else
801
        if (getDefault (currentLanguage, category, StyleConstants.StrikeThrough) != null) {
774
        if (getDefault (currentLanguage, category, StyleConstants.StrikeThrough) != null) {
802
            cbEffects.setSelectedIndex (3);
775
            cbEffects.setSelectedIndex (3);
803
            cbEffectColor.setEnabled (true);
776
            cbEffectColor.setEnabled (true);
804
            ColorComboBox.setColor (
777
            ((ColorComboBox)cbEffectColor).setSelectedColor((Color) getDefault (currentLanguage, category, StyleConstants.StrikeThrough));
805
                cbEffectColor,
806
                (Color) getDefault (currentLanguage, category, StyleConstants.StrikeThrough)
807
            );
808
        } else {
778
        } else {
809
            cbEffects.setSelectedIndex (0);
779
            cbEffects.setSelectedIndex (0);
810
            cbEffectColor.setEnabled (false);
780
            cbEffectColor.setEnabled (false);
Lines 1058-1063 Link Here
1058
        convertALC.put("literal", "keyword"); //NOI18N
1028
        convertALC.put("literal", "keyword"); //NOI18N
1059
        convertALC.put("keyword-directive", "keyword"); //NOI18N
1029
        convertALC.put("keyword-directive", "keyword"); //NOI18N
1060
    }
1030
    }
1031
1032
    @Override
1033
    public void itemStateChanged( ItemEvent e ) {
1034
        if( e.getStateChange() == ItemEvent.DESELECTED )
1035
            return;
1036
        updateData();
1037
    }
1061
    
1038
    
1062
    private static final class LanguagesComparator implements Comparator<String> {
1039
    private static final class LanguagesComparator implements Comparator<String> {
1063
        @Override
1040
        @Override

Return to bug 216013