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 |