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 212297
Collapse All | Expand All

(-)a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/customizer/MainClassChooser.java (-3 / +5 lines)
Lines 58-66 Link Here
58
import java.util.concurrent.Future;
58
import java.util.concurrent.Future;
59
import java.util.concurrent.atomic.AtomicBoolean;
59
import java.util.concurrent.atomic.AtomicBoolean;
60
import javax.lang.model.element.TypeElement;
60
import javax.lang.model.element.TypeElement;
61
import javax.swing.DefaultListCellRenderer;
62
import javax.swing.JList;
61
import javax.swing.JList;
63
import javax.swing.JPanel;
62
import javax.swing.JPanel;
63
import javax.swing.ListCellRenderer;
64
import javax.swing.ListSelectionModel;
64
import javax.swing.ListSelectionModel;
65
import javax.swing.SwingUtilities;
65
import javax.swing.SwingUtilities;
66
import javax.swing.event.ChangeEvent;
66
import javax.swing.event.ChangeEvent;
Lines 79-84 Link Here
79
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
79
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
80
import org.openide.awt.Mnemonics;
80
import org.openide.awt.Mnemonics;
81
import org.openide.awt.MouseUtils;
81
import org.openide.awt.MouseUtils;
82
import org.openide.awt.Renderers;
82
import org.openide.filesystems.FileObject;
83
import org.openide.filesystems.FileObject;
83
import org.openide.util.Exceptions;
84
import org.openide.util.Exceptions;
84
import org.openide.util.NbBundle;
85
import org.openide.util.NbBundle;
Lines 392-398 Link Here
392
        return 0;
393
        return 0;
393
    }
394
    }
394
395
395
    private static final class MainClassRenderer extends DefaultListCellRenderer {
396
    private static final class MainClassRenderer implements ListCellRenderer {
397
        private final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
396
        @Override
398
        @Override
397
        public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
399
        public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
398
            String displayName;
400
            String displayName;
Lines 403-409 Link Here
403
            } else {
405
            } else {
404
                displayName = value.toString ();
406
                displayName = value.toString ();
405
            }
407
            }
406
            return super.getListCellRendererComponent (list, displayName, index, isSelected, cellHasFocus);
408
            return orig.getListCellRendererComponent (list, displayName, index, isSelected, cellHasFocus);
407
        }
409
        }
408
    }
410
    }
409
    
411
    
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/customizer/SourceRootsUi.java (-4 / +6 lines)
Lines 60-66 Link Here
60
import java.text.MessageFormat;
60
import java.text.MessageFormat;
61
import javax.swing.CellEditor;
61
import javax.swing.CellEditor;
62
import javax.swing.DefaultCellEditor;
62
import javax.swing.DefaultCellEditor;
63
import javax.swing.DefaultListCellRenderer;
64
import javax.swing.JButton;
63
import javax.swing.JButton;
65
import javax.swing.JComponent;
64
import javax.swing.JComponent;
66
import javax.swing.JFileChooser;
65
import javax.swing.JFileChooser;
Lines 71-76 Link Here
71
import javax.swing.JScrollPane;
70
import javax.swing.JScrollPane;
72
import javax.swing.JTable;
71
import javax.swing.JTable;
73
import javax.swing.JTextField;
72
import javax.swing.JTextField;
73
import javax.swing.ListCellRenderer;
74
import javax.swing.ListSelectionModel;
74
import javax.swing.ListSelectionModel;
75
import javax.swing.SwingUtilities;
75
import javax.swing.SwingUtilities;
76
import javax.swing.event.ListSelectionEvent;
76
import javax.swing.event.ListSelectionEvent;
Lines 89-94 Link Here
89
import org.netbeans.modules.java.api.common.SourceRoots;
89
import org.netbeans.modules.java.api.common.SourceRoots;
90
import org.openide.DialogDisplayer;
90
import org.openide.DialogDisplayer;
91
import org.openide.DialogDescriptor;
91
import org.openide.DialogDescriptor;
92
import org.openide.awt.Renderers;
92
import org.openide.filesystems.FileObject;
93
import org.openide.filesystems.FileObject;
93
import org.openide.filesystems.FileUtil;
94
import org.openide.filesystems.FileUtil;
94
import org.openide.util.NbBundle;
95
import org.openide.util.NbBundle;
Lines 606-614 Link Here
606
            this.add (label2);            
607
            this.add (label2);            
607
        }
608
        }
608
609
609
        private static class InvalidRootRenderer extends DefaultListCellRenderer {
610
        private static class InvalidRootRenderer implements ListCellRenderer {
610
            private static final long serialVersionUID = 194496879246810209L;
611
            private static final long serialVersionUID = 194496879246810209L;
611
612
613
            private final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
612
            private boolean projectConflict;
614
            private boolean projectConflict;
613
615
614
            public InvalidRootRenderer (boolean projectConflict) {
616
            public InvalidRootRenderer (boolean projectConflict) {
Lines 617-623 Link Here
617
619
618
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
620
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
619
                if (" ".equals(value)) { // NOI18N
621
                if (" ".equals(value)) { // NOI18N
620
                    return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
622
                    return orig.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
621
                }
623
                }
622
                File f = (File) value;
624
                File f = (File) value;
623
                String message = f.getAbsolutePath();
625
                String message = f.getAbsolutePath();
Lines 631-637 Link Here
631
                            projectName});
633
                            projectName});
632
                    }
634
                    }
633
                }
635
                }
634
                return super.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
636
                return orig.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
635
            }
637
            }
636
        }
638
        }
637
    }
639
    }
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/wizards/FolderList.java (-4 / +6 lines)
Lines 64-74 Link Here
64
import java.util.concurrent.atomic.AtomicReference;
64
import java.util.concurrent.atomic.AtomicReference;
65
import java.util.regex.Pattern;
65
import java.util.regex.Pattern;
66
import javax.swing.DefaultListModel;
66
import javax.swing.DefaultListModel;
67
import javax.swing.DefaultListCellRenderer;
68
import javax.swing.DropMode;
67
import javax.swing.DropMode;
69
import javax.swing.JComponent;
68
import javax.swing.JComponent;
70
import javax.swing.JFileChooser;
69
import javax.swing.JFileChooser;
71
import javax.swing.JList;
70
import javax.swing.JList;
71
import javax.swing.ListCellRenderer;
72
import javax.swing.TransferHandler;
72
import javax.swing.TransferHandler;
73
import javax.swing.event.ListSelectionListener;
73
import javax.swing.event.ListSelectionListener;
74
import javax.swing.event.ListSelectionEvent;
74
import javax.swing.event.ListSelectionEvent;
Lines 82-87 Link Here
82
import org.netbeans.api.project.Sources;
82
import org.netbeans.api.project.Sources;
83
import org.netbeans.modules.java.api.common.project.ui.customizer.SourceRootsUi;
83
import org.netbeans.modules.java.api.common.project.ui.customizer.SourceRootsUi;
84
import org.netbeans.spi.java.project.support.JavadocAndSourceRootDetection;
84
import org.netbeans.spi.java.project.support.JavadocAndSourceRootDetection;
85
import org.openide.awt.Renderers;
85
import org.openide.filesystems.FileObject;
86
import org.openide.filesystems.FileObject;
86
import org.openide.filesystems.FileUtil;
87
import org.openide.filesystems.FileUtil;
87
import org.openide.util.Cancellable;
88
import org.openide.util.Cancellable;
Lines 458-471 Link Here
458
        return false;
459
        return false;
459
    }
460
    }
460
461
461
    private static class Renderer extends DefaultListCellRenderer {
462
    private static class Renderer implements ListCellRenderer {
463
        private final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
462
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
464
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
463
            if (" ".equals(value)) { // NOI18N
465
            if (" ".equals(value)) { // NOI18N
464
                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
466
                return orig.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
465
            }
467
            }
466
            File f = (File) value;
468
            File f = (File) value;
467
            String message = f.getAbsolutePath();
469
            String message = f.getAbsolutePath();
468
            Component result = super.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
470
            Component result = orig.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
469
            return result;
471
            return result;
470
        }        
472
        }        
471
    }
473
    }
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/ui/PlatformUiSupport.java (-2 / +7 lines)
Lines 64-69 Link Here
64
import org.openide.DialogDisplayer;
64
import org.openide.DialogDisplayer;
65
import org.openide.NotifyDescriptor;
65
import org.openide.NotifyDescriptor;
66
import org.openide.awt.HtmlRenderer;
66
import org.openide.awt.HtmlRenderer;
67
import org.openide.awt.Renderers;
67
import org.openide.modules.SpecificationVersion;
68
import org.openide.modules.SpecificationVersion;
68
import org.openide.util.NbBundle;
69
import org.openide.util.NbBundle;
69
import org.openide.util.Parameters;
70
import org.openide.util.Parameters;
Lines 552-557 Link Here
552
    private static final class PlatformListCellRenderer implements ListCellRenderer {
553
    private static final class PlatformListCellRenderer implements ListCellRenderer {
553
554
554
        private final ListCellRenderer delegate;
555
        private final ListCellRenderer delegate;
556
        private final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
555
557
556
        public PlatformListCellRenderer() {
558
        public PlatformListCellRenderer() {
557
            delegate = HtmlRenderer.createRenderer();
559
            delegate = HtmlRenderer.createRenderer();
Lines 569-579 Link Here
569
                    name = "<html><font color=\"#A40000\">" //NOI18N
571
                    name = "<html><font color=\"#A40000\">" //NOI18N
570
                            + NbBundle.getMessage(
572
                            + NbBundle.getMessage(
571
                                    PlatformUiSupport.class, "TXT_BrokenPlatformFmt", key.getDisplayName());
573
                                    PlatformUiSupport.class, "TXT_BrokenPlatformFmt", key.getDisplayName());
574
                    return delegate.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
572
                } else {
575
                } else {
573
                    name = key.getDisplayName();
576
                    name = key.getDisplayName();
574
                }
577
                }
575
            }
578
            }
576
            return delegate.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
579
            return orig.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
577
        }
580
        }
578
    }
581
    }
579
582
Lines 759-764 Link Here
759
    private static final class SourceLevelListCellRenderer implements ListCellRenderer {
762
    private static final class SourceLevelListCellRenderer implements ListCellRenderer {
760
763
761
        private ListCellRenderer delegate;
764
        private ListCellRenderer delegate;
765
        private final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
762
766
763
        public SourceLevelListCellRenderer() {
767
        public SourceLevelListCellRenderer() {
764
            delegate = HtmlRenderer.createRenderer();
768
            delegate = HtmlRenderer.createRenderer();
Lines 776-786 Link Here
776
                    message = "<html><font color=\"#A40000\">" //NOI18N
780
                    message = "<html><font color=\"#A40000\">" //NOI18N
777
                            + NbBundle.getMessage(
781
                            + NbBundle.getMessage(
778
                                    PlatformUiSupport.class, "TXT_InvalidSourceLevel", key.getDisplayName());
782
                                    PlatformUiSupport.class, "TXT_InvalidSourceLevel", key.getDisplayName());
783
                    return delegate.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
779
                } else {
784
                } else {
780
                    message = key.getDisplayName();
785
                    message = key.getDisplayName();
781
                }
786
                }
782
            }
787
            }
783
            return delegate.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
788
            return orig.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
784
        }
789
        }
785
    }
790
    }
786
791
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java (-26 / +4 lines)
Lines 67-73 Link Here
67
import javax.swing.event.ChangeListener;
67
import javax.swing.event.ChangeListener;
68
import javax.swing.event.DocumentEvent;
68
import javax.swing.event.DocumentEvent;
69
import javax.swing.event.DocumentListener;
69
import javax.swing.event.DocumentListener;
70
import javax.swing.plaf.UIResource;
71
import java.awt.*;
70
import java.awt.*;
72
import java.awt.event.ActionEvent;
71
import java.awt.event.ActionEvent;
73
import java.awt.event.ActionListener;
72
import java.awt.event.ActionListener;
Lines 77-82 Link Here
77
import java.util.*;
76
import java.util.*;
78
import java.util.logging.Level;
77
import java.util.logging.Level;
79
import java.util.logging.Logger;
78
import java.util.logging.Logger;
79
import org.openide.awt.Renderers;
80
80
81
public class CustomizerRun extends JPanel implements HelpCtx.Provider {
81
public class CustomizerRun extends JPanel implements HelpCtx.Provider {
82
    public static final Logger log = Logger.getLogger(CustomizerRun.class.getName());
82
    public static final Logger log = Logger.getLogger(CustomizerRun.class.getName());
Lines 683-698 Link Here
683
        
683
        
684
    }
684
    }
685
    
685
    
686
    private final class ConfigListCellRenderer extends JLabel implements ListCellRenderer, UIResource {
686
    private final class ConfigListCellRenderer implements ListCellRenderer {
687
        
687
        
688
        public ConfigListCellRenderer () {
688
        private final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
689
            setOpaque(true);
690
        }
691
        
689
        
692
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
690
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
693
            // #93658: GTK needs name to render cell renderer "natively"
694
            setName("ComboBox.listRenderer"); // NOI18N
695
            
696
            String config = (String) value;
691
            String config = (String) value;
697
            String label;
692
            String label;
698
            if (config == null) {
693
            if (config == null) {
Lines 707-730 Link Here
707
            } else {
702
            } else {
708
                label = NbBundle.getBundle("org.netbeans.modules.java.j2seproject.Bundle").getString("J2SEConfigurationProvider.default.label"); // NOI18N
703
                label = NbBundle.getBundle("org.netbeans.modules.java.j2seproject.Bundle").getString("J2SEConfigurationProvider.default.label"); // NOI18N
709
            }
704
            }
710
            setText(label);
705
            return orig.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus);
711
            
712
            if ( isSelected ) {
713
                setBackground(list.getSelectionBackground());
714
                setForeground(list.getSelectionForeground());             
715
            }
716
            else {
717
                setBackground(list.getBackground());
718
                setForeground(list.getForeground());
719
            }
720
            
721
            return this;
722
        }
723
        
724
        // #93658: GTK needs name to render cell renderer "natively"
725
        public String getName() {
726
            String name = super.getName();
727
            return name == null ? "ComboBox.renderer" : name;  // NOI18N
728
        }
706
        }
729
        
707
        
730
    }
708
    }
(-)a/openide.awt/src/org/openide/awt/Renderers.java (+115 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
43
package org.openide.awt;
44
45
import java.lang.reflect.Constructor;
46
import java.lang.reflect.Method;
47
import java.util.logging.Level;
48
import java.util.logging.Logger;
49
import javax.swing.ListCellRenderer;
50
import javax.swing.UIManager;
51
import javax.swing.plaf.basic.BasicComboBoxRenderer;
52
import javax.swing.plaf.basic.BasicComboBoxUI;
53
import javax.swing.plaf.synth.SynthLookAndFeel;
54
55
/**
56
 * Utilities for creating L&F-aware cell renderers.
57
 * @since XXX
58
 */
59
public class Renderers {
60
    
61
    private static final Logger LOG = Logger.getLogger(Renderers.class.getName());
62
63
    /**
64
     * Creates a combo box renderer appropriate to the current L&F.
65
     * This will look nicer in some L&Fs than subclassing {@link BasicComboBoxRenderer}.
66
     * <p>Usage:
67
     * <pre>
68
    MyModelType[] data = ...;
69
    JComboBox combo = new JComboBox(data);
70
    combo.setRenderer(new ListCellRenderer() {
71
        <b>final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();</b>
72
        &#64;Override public Component getListCellRendererComponent(
73
                JList l, Object v, int i, boolean sel, boolean foc) {
74
            return <b>orig.getListCellRendererComponent</b>(
75
                l, <b>((MyModelType) v).getDisplayName()</b>, i, sel, foc);
76
        }
77
    });
78
     * </pre>
79
     * @return a renderer
80
     */
81
    public static ListCellRenderer defaultComboBoxRenderer() {
82
        // XXX consider also handling " " as a value specially (workaround for another Swing bug)
83
        Class<?/* extends ComponentUI*/> clazz = UIManager.getDefaults().getUIClass("ComboBoxUI");
84
        if (clazz != null) {
85
            Constructor<?> ctor = null;
86
            if (clazz == SynthLookAndFeel.class) { // #7168287
87
                try { // only public in JDK 7
88
                    clazz = Class.forName("javax.swing.plaf.synth.SynthComboBoxUI");
89
                    ctor = clazz.getDeclaredConstructor();
90
                    ctor.setAccessible(true);
91
                    ctor.newInstance();
92
                } catch (Exception x) {
93
                    LOG.log(Level.WARNING, null, x);
94
                }
95
            }
96
            if (BasicComboBoxUI.class.isAssignableFrom(clazz)) {
97
                try {
98
                    Method createRenderer = BasicComboBoxUI.class.getDeclaredMethod("createRenderer");
99
                    createRenderer.setAccessible(true);
100
                    return (ListCellRenderer) createRenderer.invoke(ctor != null ? ctor.newInstance() : clazz.newInstance());
101
                } catch (Exception x) {
102
                    LOG.log(Level.WARNING, null, x);
103
                }
104
            } else {
105
                LOG.log(Level.WARNING, "unknown UI class: {0}", clazz);
106
            }
107
        } else {
108
            LOG.warning("no UI class");
109
        }
110
        return new BasicComboBoxRenderer.UIResource();
111
    }
112
113
    private Renderers() {}
114
115
}
(-)a/openide.awt/test/unit/src/org/openide/awt/RenderersTest.java (+71 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
43
package org.openide.awt;
44
45
import java.util.logging.Level;
46
import javax.swing.ListCellRenderer;
47
import javax.swing.UIManager;
48
import javax.swing.plaf.synth.SynthLookAndFeel;
49
import junit.framework.Test;
50
import org.netbeans.junit.NbModuleSuite;
51
import org.netbeans.junit.NbTestCase;
52
53
public class RenderersTest extends NbTestCase {
54
55
    public RenderersTest(String name) {
56
        super(name);
57
    }
58
59
    public static Test suite() throws Exception {
60
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
61
        return NbModuleSuite.createConfiguration(RenderersTest.class).failOnException(Level.INFO).failOnMessage(Level.WARNING).gui(false).enableModules("-", "-").suite();
62
    }
63
64
    public void testDefaultComboBoxRenderer() throws Exception {
65
        ListCellRenderer renderer = Renderers.defaultComboBoxRenderer();
66
        if (UIManager.getLookAndFeel() instanceof SynthLookAndFeel) {
67
            assertEquals("SynthComboBoxRenderer", renderer.getClass().getSimpleName());
68
        }
69
    }
70
71
}
(-)a/options.editor/src/org/netbeans/modules/options/indentation/FormattingPanel.java (-6 / +8 lines)
Lines 53-66 Link Here
53
import java.util.Comparator;
53
import java.util.Comparator;
54
import java.util.List;
54
import java.util.List;
55
import javax.swing.DefaultComboBoxModel;
55
import javax.swing.DefaultComboBoxModel;
56
import javax.swing.DefaultListCellRenderer;
57
import javax.swing.JComponent;
56
import javax.swing.JComponent;
58
import javax.swing.JLabel;
57
import javax.swing.JLabel;
59
import javax.swing.JList;
58
import javax.swing.JList;
60
import javax.swing.JPanel;
59
import javax.swing.JPanel;
60
import javax.swing.ListCellRenderer;
61
import javax.swing.SwingConstants;
61
import javax.swing.SwingConstants;
62
import javax.swing.SwingUtilities;
62
import javax.swing.SwingUtilities;
63
import javax.swing.UIManager;
64
import javax.swing.border.EmptyBorder;
63
import javax.swing.border.EmptyBorder;
65
import javax.swing.text.Document;
64
import javax.swing.text.Document;
66
import javax.swing.text.JTextComponent;
65
import javax.swing.text.JTextComponent;
Lines 68-73 Link Here
68
import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
67
import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
69
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
68
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
70
import org.netbeans.modules.options.editor.spi.PreviewProvider;
69
import org.netbeans.modules.options.editor.spi.PreviewProvider;
70
import org.openide.awt.Renderers;
71
import org.openide.util.NbBundle;
71
import org.openide.util.NbBundle;
72
import org.openide.util.WeakListeners;
72
import org.openide.util.WeakListeners;
73
73
Lines 86-92 Link Here
86
//        }
86
//        }
87
87
88
        // Languages combobox renderer
88
        // Languages combobox renderer
89
        languageCombo.setRenderer(new DefaultListCellRenderer() {
89
        languageCombo.setRenderer(new ListCellRenderer() {
90
            final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
90
            @Override
91
            @Override
91
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
92
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
92
                if (value instanceof String) {
93
                if (value instanceof String) {
Lines 94-111 Link Here
94
                            ? EditorSettings.getDefault().getLanguageName((String)value)
95
                            ? EditorSettings.getDefault().getLanguageName((String)value)
95
                            : org.openide.util.NbBundle.getMessage(FormattingPanel.class, "LBL_AllLanguages"); //NOI18N                                
96
                            : org.openide.util.NbBundle.getMessage(FormattingPanel.class, "LBL_AllLanguages"); //NOI18N                                
96
                }
97
                }
97
                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
98
                return orig.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
98
            }            
99
            }            
99
        });
100
        });
100
        
101
        
101
        // Category combobox renderer
102
        // Category combobox renderer
102
        categoryCombo.setRenderer(new DefaultListCellRenderer() {
103
        categoryCombo.setRenderer(new ListCellRenderer() {
104
            final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
103
            @Override
105
            @Override
104
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
106
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
105
                if (value instanceof PreferencesCustomizer) {
107
                if (value instanceof PreferencesCustomizer) {
106
                    value = ((PreferencesCustomizer) value).getDisplayName();
108
                    value = ((PreferencesCustomizer) value).getDisplayName();
107
                }
109
                }
108
                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
110
                return orig.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
109
            }            
111
            }            
110
        });
112
        });
111
113
(-)a/projectuiapi/src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java (-7 / +4 lines)
Lines 67-73 Link Here
67
import java.util.logging.Logger;
67
import java.util.logging.Logger;
68
import javax.swing.ComboBoxModel;
68
import javax.swing.ComboBoxModel;
69
import javax.swing.DefaultComboBoxModel;
69
import javax.swing.DefaultComboBoxModel;
70
import javax.swing.DefaultListCellRenderer;
71
import javax.swing.JComponent;
70
import javax.swing.JComponent;
72
import javax.swing.JDialog;
71
import javax.swing.JDialog;
73
import javax.swing.JList;
72
import javax.swing.JList;
Lines 82-87 Link Here
82
import org.netbeans.modules.project.uiapi.CustomizerPane;
81
import org.netbeans.modules.project.uiapi.CustomizerPane;
83
import org.netbeans.modules.project.uiapi.Utilities;
82
import org.netbeans.modules.project.uiapi.Utilities;
84
import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
83
import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
84
import org.openide.awt.Renderers;
85
import org.openide.cookies.InstanceCookie;
85
import org.openide.cookies.InstanceCookie;
86
import org.openide.filesystems.FileObject;
86
import org.openide.filesystems.FileObject;
87
import org.openide.filesystems.FileStateInvalidException;
87
import org.openide.filesystems.FileStateInvalidException;
Lines 826-836 Link Here
826
        return new EncodingModel(initialCharset);
826
        return new EncodingModel(initialCharset);
827
    }
827
    }
828
828
829
    private static final class EncodingRenderer extends DefaultListCellRenderer {
829
    private static final class EncodingRenderer implements ListCellRenderer {
830
        EncodingRenderer() {
830
        final ListCellRenderer orig = Renderers.defaultComboBoxRenderer();
831
            //Needed for synth?
832
            setName ("ComboBox.listRenderer"); //NOI18N
833
        }
834
831
835
        @Override
832
        @Override
836
        public Component getListCellRendererComponent(JList list, Object value,
833
        public Component getListCellRendererComponent(JList list, Object value,
Lines 838-844 Link Here
838
            if (value instanceof Charset) {
835
            if (value instanceof Charset) {
839
                value = ((Charset) value).displayName();
836
                value = ((Charset) value).displayName();
840
            }
837
            }
841
            return super.getListCellRendererComponent(list, value, index,
838
            return orig.getListCellRendererComponent(list, value, index,
842
                    isSelected, isLeadSelection);
839
                    isSelected, isLeadSelection);
843
        }
840
        }
844
    }
841
    }

Return to bug 212297