Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 243229
Collapse All | Expand All

(-)a/editor.bracesmatching/src/org/netbeans/modules/editor/bracesmatching/BraceMatchingSidebarComponent.java (-25 / +50 lines)
 Lines 58-63    Link Here 
58
import java.awt.event.HierarchyListener;
58
import java.awt.event.HierarchyListener;
59
import java.awt.event.MouseAdapter;
59
import java.awt.event.MouseAdapter;
60
import java.awt.event.MouseEvent;
60
import java.awt.event.MouseEvent;
61
import java.beans.PropertyChangeEvent;
62
import java.beans.PropertyChangeListener;
63
import java.util.Hashtable;
61
import java.util.Iterator;
64
import java.util.Iterator;
62
import java.util.prefs.PreferenceChangeEvent;
65
import java.util.prefs.PreferenceChangeEvent;
63
import java.util.prefs.PreferenceChangeListener;
66
import java.util.prefs.PreferenceChangeListener;
 Lines 79-87    Link Here 
79
import javax.swing.text.Element;
82
import javax.swing.text.Element;
80
import javax.swing.text.JTextComponent;
83
import javax.swing.text.JTextComponent;
81
import javax.swing.text.Position;
84
import javax.swing.text.Position;
85
import javax.swing.text.SimpleAttributeSet;
86
import javax.swing.text.StyleConstants;
82
import org.netbeans.api.editor.mimelookup.MimeLookup;
87
import org.netbeans.api.editor.mimelookup.MimeLookup;
83
import org.netbeans.api.editor.mimelookup.MimePath;
88
import org.netbeans.api.editor.mimelookup.MimePath;
84
import org.netbeans.api.editor.settings.AttributesUtilities;
89
import org.netbeans.api.editor.settings.AttributesUtilities;
90
import org.netbeans.api.editor.settings.EditorStyleConstants;
85
import org.netbeans.api.editor.settings.FontColorNames;
91
import org.netbeans.api.editor.settings.FontColorNames;
86
import org.netbeans.api.editor.settings.FontColorSettings;
92
import org.netbeans.api.editor.settings.FontColorSettings;
87
import org.netbeans.api.editor.settings.SimpleValueNames;
93
import org.netbeans.api.editor.settings.SimpleValueNames;
 Lines 112-118    Link Here 
112
 * @author sdedic
118
 * @author sdedic
113
 */
119
 */
114
public class BraceMatchingSidebarComponent extends JComponent implements 
120
public class BraceMatchingSidebarComponent extends JComponent implements 
115
        MatchListener, FocusListener, ViewHierarchyListener, ChangeListener {
121
        MatchListener, FocusListener, ViewHierarchyListener, ChangeListener, Runnable, LookupListener {
116
    
122
    
117
    private static final int TOOLTIP_CHECK_DELAY = 700;
123
    private static final int TOOLTIP_CHECK_DELAY = 700;
118
    
124
    
 Lines 182-188    Link Here 
182
    /**
188
    /**
183
     * Prevent listeners from being reclaimed before this Component
189
     * Prevent listeners from being reclaimed before this Component
184
     */
190
     */
185
    private LookupListener  lookupListenerGC;
186
    private PreferenceChangeListener prefListenerGC;
191
    private PreferenceChangeListener prefListenerGC;
187
    private JViewport viewport;
192
    private JViewport viewport;
188
193
 Lines 191-198    Link Here 
191
     */
196
     */
192
    private Coloring coloring;
197
    private Coloring coloring;
193
    
198
    
199
    /**
200
     * Background color handled specially, inherit means inherit from
201
     * parent JComponent, not from default Coloring.
202
     */
203
    private Color    backColor;
204
    
194
    private static final RequestProcessor RP = new RequestProcessor(BraceMatchingSidebarComponent.class);
205
    private static final RequestProcessor RP = new RequestProcessor(BraceMatchingSidebarComponent.class);
195
    
206
    
207
    private final Lookup.Result colorResult;
208
        
209
    @SuppressWarnings("LeakingThisInConstructor")
196
    public BraceMatchingSidebarComponent(JTextComponent editor) {
210
    public BraceMatchingSidebarComponent(JTextComponent editor) {
197
        this.editor = editor;
211
        this.editor = editor;
198
        this.mimeType = DocumentUtilities.getMimeType(editor);
212
        this.mimeType = DocumentUtilities.getMimeType(editor);
 Lines 200-217    Link Here 
200
        
214
        
201
        final Lookup.Result r = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(editor)).lookupResult(
215
        final Lookup.Result r = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(editor)).lookupResult(
202
                FontColorSettings.class);
216
                FontColorSettings.class);
203
        lookupListenerGC = new LookupListener() {
204
            @Override
205
            public void resultChanged(LookupEvent ev) {
206
                Iterator<FontColorSettings> fcsIt = r.allInstances().iterator();
207
                if (fcsIt.hasNext()) {
208
                  updateColors(r);
209
                }
210
            }
211
        };
212
        prefListenerGC = new PrefListener();
217
        prefListenerGC = new PrefListener();
213
218
        this.colorResult = r;
214
        r.addLookupListener(WeakListeners.create(LookupListener.class, lookupListenerGC , r));
219
        r.addLookupListener(WeakListeners.create(LookupListener.class, this , r));
215
        prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListenerGC, prefs));
220
        prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListenerGC, prefs));
216
        loadPreferences();
221
        loadPreferences();
217
        
222
        
 Lines 226-239    Link Here 
226
        if (ui instanceof BaseTextUI) {
231
        if (ui instanceof BaseTextUI) {
227
            baseUI = (BaseTextUI)ui;
232
            baseUI = (BaseTextUI)ui;
228
            MasterMatcher.get(editor).addMatchListener(this);
233
            MasterMatcher.get(editor).addMatchListener(this);
229
            updateColors(r);
230
        } else {
234
        } else {
231
            baseUI = null;
235
            baseUI = null;
232
        }
236
        }
233
        setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
237
        setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
234
        updatePreferredSize();
238
        updatePreferredSize();
235
    }
239
    }
236
240
    
237
    private void loadPreferences() {
241
    private void loadPreferences() {
238
        showOutline = prefs.getBoolean(SimpleValueNames.BRACE_SHOW_OUTLINE, true);
242
        showOutline = prefs.getBoolean(SimpleValueNames.BRACE_SHOW_OUTLINE, true);
239
        showToolTip = prefs.getBoolean(SimpleValueNames.BRACE_FIRST_TOOLTIP, true);
243
        showToolTip = prefs.getBoolean(SimpleValueNames.BRACE_FIRST_TOOLTIP, true);
 Lines 265-270    Link Here 
265
    });
269
    });
266
270
267
    @Override
271
    @Override
272
    public void resultChanged(LookupEvent ev) {
273
        if (!SwingUtilities.isEventDispatchThread()) {
274
            SwingUtilities.invokeLater(this);
275
        } else {
276
            run();
277
        }
278
    }
279
    
280
    public void run() {
281
        Iterator<FontColorSettings> fcsIt = colorResult.allInstances().iterator();
282
        if (fcsIt.hasNext()) {
283
            updateColors(fcsIt.next());
284
        }
285
    }
286
    
287
    @Override
268
    public void stateChanged(ChangeEvent e) {
288
    public void stateChanged(ChangeEvent e) {
269
        scrollUpdater.schedule(TOOLTIP_CHECK_DELAY);
289
        scrollUpdater.schedule(TOOLTIP_CHECK_DELAY);
270
    }
290
    }
 Lines 282-288    Link Here 
282
                showToolTip = prefs.getBoolean(SimpleValueNames.BRACE_FIRST_TOOLTIP, true);
302
                showToolTip = prefs.getBoolean(SimpleValueNames.BRACE_FIRST_TOOLTIP, true);
283
            }
303
            }
284
        }
304
        }
285
        
286
    }
305
    }
287
    
306
    
288
    private static JEditorPane findEditorPane(JTextComponent editor) {
307
    private static JEditorPane findEditorPane(JTextComponent editor) {
 Lines 306-311    Link Here 
306
    @Override
325
    @Override
307
    public void addNotify() {
326
    public void addNotify() {
308
        super.addNotify();
327
        super.addNotify();
328
        run();
309
        ViewHierarchy.get(editor).addViewHierarchyListener(this);
329
        ViewHierarchy.get(editor).addViewHierarchyListener(this);
310
        editor.addFocusListener(this);
330
        editor.addFocusListener(this);
311
    }
331
    }
 Lines 318-336    Link Here 
318
    }
338
    }
319
    
339
    
320
    
340
    
321
    
341
    private void updateColors(final FontColorSettings fcs) {
322
    private void updateColors(Lookup.Result r) {
342
        if (getParent() == null) {
323
        Iterator<FontColorSettings> fcsIt = r.allInstances().iterator();
343
            return;
324
        if (!fcsIt.hasNext()) {
325
          return;
326
        }
344
        }
327
        FontColorSettings fcs = fcsIt.next();
328
        
329
        AttributeSet as = fcs.getFontColors(BRACES_COLORING);
345
        AttributeSet as = fcs.getFontColors(BRACES_COLORING);
330
        if (as == null) {
346
        if (as == null) {
331
            as = fcs.getFontColors(FontColorNames.DEFAULT_COLORING);
347
            as = fcs.getFontColors(FontColorNames.DEFAULT_COLORING);
348
            this.backColor = (Color)as.getAttribute(StyleConstants.ColorConstants.Background);
332
        } else {
349
        } else {
333
            as = AttributesUtilities.createComposite(as, fcs.getFontColors(FontColorNames.DEFAULT_COLORING));
350
            this.backColor = (Color)as.getAttribute(StyleConstants.ColorConstants.Background);
351
            as = AttributesUtilities.createComposite(
352
                    as, 
353
                    fcs.getFontColors(FontColorNames.DEFAULT_COLORING));
334
        }
354
        }
335
        this.coloring = Coloring.fromAttributeSet(as);
355
        this.coloring = Coloring.fromAttributeSet(as);
336
        int w = 0;
356
        int w = 0;
 Lines 373-379    Link Here 
373
        int[] points;
393
        int[] points;
374
        
394
        
375
        Rectangle clip = getVisibleRect();//g.getClipBounds();
395
        Rectangle clip = getVisibleRect();//g.getClipBounds();
376
        g.setColor(coloring.getBackColor());
396
        Color backColor = this.backColor;
397
        if (backColor == null) {
398
            // assume get from parent
399
            backColor = getBackground();
400
        }
401
        g.setColor(backColor);
377
        g.fillRect(clip.x, clip.y, clip.width, clip.height);
402
        g.fillRect(clip.x, clip.y, clip.width, clip.height);
378
        g.setColor(coloring.getForeColor());
403
        g.setColor(coloring.getForeColor());
379
404
(-)a/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/CodeFoldingSideBar.java (-4 / +24 lines)
 Lines 79-84    Link Here 
79
import javax.swing.text.BadLocationException;
79
import javax.swing.text.BadLocationException;
80
import javax.swing.text.Document;
80
import javax.swing.text.Document;
81
import javax.swing.text.JTextComponent;
81
import javax.swing.text.JTextComponent;
82
import javax.swing.text.SimpleAttributeSet;
83
import javax.swing.text.StyleConstants;
82
import javax.swing.text.View;
84
import javax.swing.text.View;
83
import org.netbeans.api.editor.fold.Fold;
85
import org.netbeans.api.editor.fold.Fold;
84
import org.netbeans.api.editor.fold.FoldHierarchy;
86
import org.netbeans.api.editor.fold.FoldHierarchy;
 Lines 304-309    Link Here 
304
        if (o == null) {
306
        if (o == null) {
305
            component.putClientProperty(PROP_SIDEBAR_MARK, this);
307
            component.putClientProperty(PROP_SIDEBAR_MARK, this);
306
        }
308
        }
309
        prefsListener.preferenceChange(null);
307
    }
310
    }
308
    
311
    
309
    
312
    
 Lines 336-342    Link Here 
336
        
339
        
337
        prefs = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(component)).lookup(Preferences.class);
340
        prefs = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(component)).lookup(Preferences.class);
338
        prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs));
341
        prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs));
339
        prefsListener.preferenceChange(null);
340
        
342
        
341
        if (LOG.isLoggable(Level.FINE)) {
343
        if (LOG.isLoggable(Level.FINE)) {
342
            LOG.log(Level.FINE, "Code folding sidebar initialized for: {0}", doc);
344
            LOG.log(Level.FINE, "Code folding sidebar initialized for: {0}", doc);
 Lines 363-372    Link Here 
363
        }
365
        }
364
        revalidate();
366
        revalidate();
365
    }
367
    }
368
    
369
    /**
370
     * Resolves background color. Must be called after getColoring(), satisfied in updateColors.
371
     * @return 
372
     */
373
    private Color resolveBackColor() {
374
        AttributeSet attr = specificAttrs;
375
        Color x = (Color)attr.getAttribute(StyleConstants.ColorConstants.Background);
376
        if (x == null) {
377
            x = getParent().getBackground();
378
        }
379
        return x;
380
    }
366
381
367
    private void updateColors() {
382
    private void updateColors() {
368
        Coloring c = getColoring();
383
        Coloring c = getColoring();
369
        this.backColor = c.getBackColor();
384
        this.backColor = resolveBackColor();
370
        this.foreColor = c.getForeColor();
385
        this.foreColor = c.getForeColor();
371
        this.font = c.getFont();
386
        this.font = c.getFont();
372
    }
387
    }
 Lines 1005-1011    Link Here 
1005
        visibleMarks.clear();
1020
        visibleMarks.clear();
1006
        
1021
        
1007
        Coloring coloring = getColoring();
1022
        Coloring coloring = getColoring();
1008
        g.setColor(coloring.getBackColor());
1023
        g.setColor(resolveBackColor());
1009
        g.fillRect(clip.x, clip.y, clip.width, clip.height);
1024
        g.fillRect(clip.x, clip.y, clip.width, clip.height);
1010
        g.setColor(coloring.getForeColor());
1025
        g.setColor(coloring.getForeColor());
1011
1026
 Lines 1526-1531    Link Here 
1526
        }
1541
        }
1527
        return accessibleContext;
1542
        return accessibleContext;
1528
    }
1543
    }
1544
    
1545
    private AttributeSet specificAttrs;
1529
1546
1530
    private Coloring getColoring() {
1547
    private Coloring getColoring() {
1531
        if (attribs == null) {
1548
        if (attribs == null) {
 Lines 1537-1546    Link Here 
1537
            
1554
            
1538
            FontColorSettings fcs = fcsLookupResult.allInstances().iterator().next();
1555
            FontColorSettings fcs = fcsLookupResult.allInstances().iterator().next();
1539
            AttributeSet attr = fcs.getFontColors(FontColorNames.CODE_FOLDING_BAR_COLORING);
1556
            AttributeSet attr = fcs.getFontColors(FontColorNames.CODE_FOLDING_BAR_COLORING);
1557
            specificAttrs = attr;
1540
            if (attr == null) {
1558
            if (attr == null) {
1541
                attr = fcs.getFontColors(FontColorNames.DEFAULT_COLORING);
1559
                attr = fcs.getFontColors(FontColorNames.DEFAULT_COLORING);
1542
            } else {
1560
            } else {
1543
                attr = AttributesUtilities.createComposite(attr, fcs.getFontColors(FontColorNames.DEFAULT_COLORING));
1561
                attr = AttributesUtilities.createComposite(
1562
                        attr, 
1563
                        fcs.getFontColors(FontColorNames.DEFAULT_COLORING));
1544
            }
1564
            }
1545
            attribs = attr;
1565
            attribs = attr;
1546
        }        
1566
        }        
(-)a/editor/src/org/netbeans/modules/editor/Bundle.properties (+1 lines)
 Lines 190-192    Link Here 
190
trailing-whitespace=Trailing Whitespace
190
trailing-whitespace=Trailing Whitespace
191
readonly-files=Readonly Files
191
readonly-files=Readonly Files
192
mark-occurrences=Mark Occurrences
192
mark-occurrences=Mark Occurrences
193
west-sidebars-color=Editor sidebars background
(-)a/editor/src/org/netbeans/modules/editor/impl/CustomizableSideBar.java (-2 / +150 lines)
 Lines 47-58    Link Here 
47
import java.util.logging.Level;
47
import java.util.logging.Level;
48
import org.netbeans.modules.editor.*;
48
import org.netbeans.modules.editor.*;
49
import java.awt.BorderLayout;
49
import java.awt.BorderLayout;
50
import java.awt.Color;
51
import java.awt.Component;
52
import java.awt.Graphics;
53
import java.awt.Graphics2D;
54
import java.awt.Insets;
55
import java.beans.PropertyChangeEvent;
56
import java.beans.PropertyChangeListener;
50
import java.lang.ref.Reference;
57
import java.lang.ref.Reference;
51
import java.lang.ref.WeakReference;
58
import java.lang.ref.WeakReference;
52
import java.util.ArrayList;
59
import java.util.ArrayList;
53
import java.util.Arrays;
60
import java.util.Arrays;
54
import java.util.Collection;
61
import java.util.Collection;
55
import java.util.HashMap;
62
import java.util.HashMap;
63
import java.util.Iterator;
56
import java.util.List;
64
import java.util.List;
57
import java.util.Map;
65
import java.util.Map;
58
import java.util.WeakHashMap;
66
import java.util.WeakHashMap;
 Lines 61-76    Link Here 
61
import javax.swing.JComponent;
69
import javax.swing.JComponent;
62
import javax.swing.JPanel;
70
import javax.swing.JPanel;
63
import javax.swing.SwingUtilities;
71
import javax.swing.SwingUtilities;
72
import javax.swing.border.LineBorder;
64
import javax.swing.event.ChangeEvent;
73
import javax.swing.event.ChangeEvent;
65
import javax.swing.event.ChangeListener;
74
import javax.swing.event.ChangeListener;
75
import javax.swing.text.AttributeSet;
66
import javax.swing.text.JTextComponent;
76
import javax.swing.text.JTextComponent;
77
import javax.swing.text.StyleConstants;
67
import org.netbeans.api.editor.mimelookup.MimeLookup;
78
import org.netbeans.api.editor.mimelookup.MimeLookup;
68
import org.netbeans.api.editor.mimelookup.MimePath;
79
import org.netbeans.api.editor.mimelookup.MimePath;
80
import org.netbeans.api.editor.settings.AttributesUtilities;
81
import org.netbeans.api.editor.settings.FontColorNames;
82
import org.netbeans.api.editor.settings.FontColorSettings;
69
import org.netbeans.editor.WeakEventListenerList;
83
import org.netbeans.editor.WeakEventListenerList;
70
import org.openide.filesystems.FileObject;
84
import org.openide.filesystems.FileObject;
71
import org.openide.util.Lookup;
85
import org.openide.util.Lookup;
72
import org.openide.util.LookupEvent;
86
import org.openide.util.LookupEvent;
73
import org.openide.util.LookupListener;
87
import org.openide.util.LookupListener;
88
import org.openide.util.WeakListeners;
74
89
75
/**
90
/**
76
 *  Editor Customizable Side Bar.
91
 *  Editor Customizable Side Bar.
 Lines 95-100    Link Here 
95
    private static final Map<MimePath, Lookup.Result<SideBarFactoriesProvider>> LR = new WeakHashMap<MimePath, Lookup.Result<SideBarFactoriesProvider>>(5);
110
    private static final Map<MimePath, Lookup.Result<SideBarFactoriesProvider>> LR = new WeakHashMap<MimePath, Lookup.Result<SideBarFactoriesProvider>>(5);
96
    private static final Map<Lookup.Result<SideBarFactoriesProvider>, LookupListener> LL = new WeakHashMap<Lookup.Result<SideBarFactoriesProvider>, LookupListener>(5);
111
    private static final Map<Lookup.Result<SideBarFactoriesProvider>, LookupListener> LL = new WeakHashMap<Lookup.Result<SideBarFactoriesProvider>, LookupListener>(5);
97
    
112
    
113
    private static final String COLOR_WEST_SIDEBARS = "west-sidebars-color"; // NOI18N
114
    
98
    private CustomizableSideBar() {
115
    private CustomizableSideBar() {
99
    }
116
    }
100
117
 Lines 195-203    Link Here 
195
            for(SideBarPosition pos : sideBarsMap.keySet()) {
212
            for(SideBarPosition pos : sideBarsMap.keySet()) {
196
                List<JComponent> sideBars = sideBarsMap.get(pos);
213
                List<JComponent> sideBars = sideBarsMap.get(pos);
197
                
214
                
198
                JPanel panel = new JPanel();
215
                JPanel panel = pos.getPosition() == SideBarPosition.WEST ?
216
                        new WestSidebarHolder(target) :
217
                        new JPanel();
199
                panel.setLayout(new BoxLayout(panel, pos.getAxis()));
218
                panel.setLayout(new BoxLayout(panel, pos.getAxis()));
200
219
                
201
                for(JComponent c : sideBars) {
220
                for(JComponent c : sideBars) {
202
                    panel.add(c);
221
                    panel.add(c);
203
                }
222
                }
 Lines 211-216    Link Here 
211
        }
230
        }
212
    }
231
    }
213
    
232
    
233
    /**
234
     * Degenerated "right line border"; displays line at the right only. Pads
235
     * the line with the editor component's background, so the divisor and editor's
236
     * graphics (i.e. brace ruler) are separated.
237
     */
238
    private final static class WestSidebarHolder extends JPanel implements LookupListener, PropertyChangeListener, Runnable {
239
        /**
240
         * The text editor, whose background will be used as a padding
241
         */
242
        private final JComponent bkgSource;
243
        
244
        private final Lookup.Result<FontColorSettings>   colorResult;
245
        
246
        private Color   lineColor;
247
        
248
        private Color   textBkColor;
249
        
250
        private int     thickness = 1;
251
        
252
        @SuppressWarnings("LeakingThisInConstructor")
253
        public WestSidebarHolder(JTextComponent target) {
254
            this.bkgSource = target;
255
            
256
            String mimeType = NbEditorUtilities.getMimeType(target);
257
            colorResult = MimeLookup.getLookup(mimeType).lookupResult(FontColorSettings.class);
258
            colorResult.addLookupListener(WeakListeners.create(LookupListener.class, this, colorResult));
259
            bkgSource.addPropertyChangeListener(WeakListeners.propertyChange(this, "background", bkgSource));
260
            getInsets().set(0, 0, 0, 1);
261
            setOpaque(true);
262
        }
263
264
        @Override
265
        public void resultChanged(LookupEvent ev) {
266
            run();
267
        }
268
269
        @Override
270
        public void propertyChange(PropertyChangeEvent evt) {
271
            if (evt.getSource() == bkgSource && "background".equals(evt.getPropertyName())) {
272
                run();
273
            }
274
        }
275
276
        @Override
277
        public void run() {
278
            if (!SwingUtilities.isEventDispatchThread()) {
279
                SwingUtilities.invokeLater(this);
280
                return;
281
            }
282
            updateUIConfig();
283
        }
284
285
        public int getThickness() {
286
            return thickness;
287
        }
288
289
        @Override
290
        public void addNotify() {
291
            super.addNotify();
292
            updateUIConfig();
293
        }
294
        
295
        @Override
296
        protected void paintComponent(Graphics g) {
297
            super.paintComponent(g);
298
            if (lineColor == null) {
299
                return;
300
            }
301
            // paint the border:
302
            paintBorder(this, g, 0, 0, getWidth(), getHeight());
303
        }
304
        
305
        private void updateUIConfig() {
306
            Iterator<? extends FontColorSettings> it = colorResult.allInstances().iterator();
307
            if (!it.hasNext()) {
308
                return;
309
            }
310
            FontColorSettings fcs = it.next();
311
            Color line;
312
            Color back;
313
            
314
            AttributeSet as = fcs.getFontColors(COLOR_WEST_SIDEBARS);
315
            if (as == null) {
316
                // backwards - compatible behaviour: use the line number stuff:
317
                as = fcs.getFontColors(FontColorNames.LINE_NUMBER_COLORING);
318
                back = (Color)as.getAttribute(StyleConstants.Background);
319
                line = null;
320
            } else {
321
                Object o;
322
                back = (Color)as.getAttribute(StyleConstants.Background);
323
                line = (Color)as.getAttribute(StyleConstants.Foreground);
324
            }
325
            textBkColor = bkgSource.getBackground();
326
            if (back == null) {
327
                back = textBkColor;
328
            }
329
            setBackground(back);
330
            if (line == null || line.equals(back)) {
331
                lineColor = null;
332
            } else {
333
                this.lineColor = line;
334
            }
335
            revalidate();
336
        }
337
338
        @Override
339
        public Insets getInsets() {
340
            Insets s = super.getInsets();
341
            if (lineColor != null) {
342
                s.right += getThickness() + 1;
343
            }
344
            return s;
345
        }
346
        
347
        public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
348
            int thick = getThickness();
349
            if (thick < 1 || !(g instanceof Graphics2D)) {
350
                return;
351
            }
352
            Graphics2D g2d = (Graphics2D)g.create();
353
            g2d.setColor(this.lineColor);
354
            int x2 = x + width - ((thick +1) / 2);
355
            g2d.drawLine(x2 - 1, 
356
                    0, x2 - 1, y + height - 1);
357
            g2d.setColor(textBkColor);
358
            g2d.drawLine(x2, 0, x2, y + height - 1);
359
        }
360
    }
361
    
214
    @SuppressWarnings("deprecation")
362
    @SuppressWarnings("deprecation")
215
    private static Map<SideBarPosition, List<JComponent>> createSideBarsMap(JTextComponent target) {
363
    private static Map<SideBarPosition, List<JComponent>> createSideBarsMap(JTextComponent target) {
216
        String mimeType = NbEditorUtilities.getMimeType(target);
364
        String mimeType = NbEditorUtilities.getMimeType(target);
(-)a/editor/src/org/netbeans/modules/editor/resources/NetBeans-editor.xml (+1 lines)
 Lines 66-69    Link Here 
66
    <fontcolor name="synchronized-text-blocks-ext-slave" foreColor="ff996600"/>
66
    <fontcolor name="synchronized-text-blocks-ext-slave" foreColor="ff996600"/>
67
    <fontcolor name="indent-whitespace"/>
67
    <fontcolor name="indent-whitespace"/>
68
    <fontcolor name="trailing-whitespace"/>
68
    <fontcolor name="trailing-whitespace"/>
69
    <fontcolor name="west-sidebars-color"/>
69
</fontscolors>
70
</fontscolors>
(-)a/versioning.ui/src/org/netbeans/modules/versioning/ui/diff/DiffSidebar.java (-21 / +28 lines)
 Lines 152-157    Link Here 
152
    private VersioningSystem ownerVersioningSystem;
152
    private VersioningSystem ownerVersioningSystem;
153
    private final LookupListener lookupListenerGC;
153
    private final LookupListener lookupListenerGC;
154
    private Color bgColor = Color.WHITE;
154
    private Color bgColor = Color.WHITE;
155
    private Lookup.Result   colorResult;
155
156
156
    public DiffSidebar(JTextComponent target, FileObject file) {
157
    public DiffSidebar(JTextComponent target, FileObject file) {
157
        LOG.log(Level.FINE, "creating DiffSideBar for {0}", file != null ? file.getPath() : null);
158
        LOG.log(Level.FINE, "creating DiffSideBar for {0}", file != null ? file.getPath() : null);
 Lines 160-183    Link Here 
160
        this.foldHierarchy = FoldHierarchy.get(target);
161
        this.foldHierarchy = FoldHierarchy.get(target);
161
        this.document = (BaseDocument) textComponent.getDocument();
162
        this.document = (BaseDocument) textComponent.getDocument();
162
        this.markProvider = new DiffMarkProvider();
163
        this.markProvider = new DiffMarkProvider();
163
        final Lookup.Result r = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(target)).lookupResult(FontColorSettings.class);
164
        colorResult = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(target)).lookupResult(FontColorSettings.class);
164
        lookupListenerGC = new LookupListener() {
165
        
166
        class LL implements LookupListener, Runnable {
165
            @Override
167
            @Override
166
            public void resultChanged(LookupEvent ev) {
168
            public void resultChanged(LookupEvent ev) {
167
                Iterator<FontColorSettings> fcsIt = r.allInstances().iterator();
169
                if (!EventQueue.isDispatchThread()) {
168
                if (fcsIt.hasNext()) {
170
                    EventQueue.invokeLater(this);
169
                    updateColors(r);
171
                } else {
172
                    updateColors();
170
                }
173
                }
171
            }
174
            }
172
        };
175
173
        r.addLookupListener(WeakListeners.create(LookupListener.class, lookupListenerGC , r));
176
            @Override
177
            public void run() {
178
                updateColors();
179
            }
180
        }
181
        lookupListenerGC = new LL();
182
        colorResult.addLookupListener(WeakListeners.create(LookupListener.class, lookupListenerGC , colorResult));
174
        bgColor = defaultBackground();
183
        bgColor = defaultBackground();
175
        updateColors(r);
176
        setToolTipText(""); // NOI18N
184
        setToolTipText(""); // NOI18N
177
        refreshDiffTask = DiffSidebarManager.getInstance().createDiffSidebarTask(new RefreshDiffTask());
185
        refreshDiffTask = DiffSidebarManager.getInstance().createDiffSidebarTask(new RefreshDiffTask());
178
        setMaximumSize(new Dimension(BAR_WIDTH, Integer.MAX_VALUE));
186
        setMaximumSize(new Dimension(BAR_WIDTH, Integer.MAX_VALUE));
179
    }
187
    }
180
188
    
181
    FileObject getFileObject() {
189
    FileObject getFileObject() {
182
        return fileObject;
190
        return fileObject;
183
    }
191
    }
 Lines 626-631    Link Here 
626
                }
634
                }
627
            }).schedule(0);
635
            }).schedule(0);
628
        }
636
        }
637
        updateColors();
629
    }
638
    }
630
639
631
    private void shutdown() {
640
    private void shutdown() {
 Lines 1276-1296    Link Here 
1276
        }
1285
        }
1277
    }
1286
    }
1278
    
1287
    
1279
    private void updateColors (Lookup.Result r) {
1288
    private void updateColors() {
1280
        Iterator<FontColorSettings> fcsIt = r.allInstances().iterator();
1289
        if (getParent() == null) {
1281
        if (!fcsIt.hasNext()) {
1282
            return;
1290
            return;
1283
        }
1291
        }
1284
        FontColorSettings fcs = fcsIt.next();
1292
        Iterator<FontColorSettings> fcsIt = colorResult.allInstances().iterator();
1285
        
1293
        if (fcsIt.hasNext()) {
1286
        AttributeSet as = fcs.getFontColors(FontColorNames.DEFAULT_COLORING);
1294
            updateColors(fcsIt.next());
1295
        }
1296
    }
1297
1298
    private void updateColors (FontColorSettings fcs) {
1287
        Color oldC = bgColor;
1299
        Color oldC = bgColor;
1288
        Coloring coloring = as == null ? null : Coloring.fromAttributeSet(as);
1300
        bgColor = getParent().getBackground();
1289
        Color newC = null;
1290
        if (coloring != null) {
1291
            newC = coloring.getBackColor();
1292
        }
1293
        bgColor = newC == null ? defaultBackground() : newC;
1294
        if (!bgColor.equals(oldC)) {
1301
        if (!bgColor.equals(oldC)) {
1295
            EventQueue.invokeLater(new Runnable() {
1302
            EventQueue.invokeLater(new Runnable() {
1296
1303

Return to bug 243229
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo