# HG changeset patch # User Vladimir Kvashin # Date 1454402967 -10800 # Branch release81 # Node ID c1a94c3f392dc0cc6299fab430557c85bf7bab4a # Parent 50f6c2df5ea49f37a6face92ecffbef10ba58204 better fix for #257811 - Strange configuration text in project properties dialog diff -r 50f6c2df5ea4 -r c1a94c3f392d cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configuration.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configuration.java Mon Feb 01 22:56:01 2016 +0300 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configuration.java Tue Feb 02 11:49:27 2016 +0300 @@ -155,11 +155,16 @@ @Override public String toString() { + StringBuilder sb = new StringBuilder(getDisplayNameExt()); + sb.append(isValid() ? " [valid] @" : " [invalid] @").append(System.identityHashCode(this)); // NOI18N + return sb.toString(); + } + + public String getDisplayNameExt() { StringBuilder sb = new StringBuilder(getDisplayName()); if (isDefault()) { sb.append(' ').append(getString("ActiveTxt")); } - sb.append(isValid() ? " [valid] @" : " [invalid] @").append(System.identityHashCode(this)); // NOI18N return sb.toString(); } diff -r 50f6c2df5ea4 -r c1a94c3f392d cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configurations.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configurations.java Mon Feb 01 22:56:01 2016 +0300 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configurations.java Tue Feb 02 11:49:27 2016 +0300 @@ -192,7 +192,7 @@ String[] names = new String[size()]; for (int i = 0; i < size(); i++) { Configuration configuration = configurations.get(i); - names[i] = configuration.toString(); + names[i] = configuration.getDisplayNameExt(); } return names; } finally { diff -r 50f6c2df5ea4 -r c1a94c3f392d cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/customizer/ConfigurationCellRenderer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/customizer/ConfigurationCellRenderer.java Tue Feb 02 11:49:27 2016 +0300 @@ -0,0 +1,78 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2016 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2016 Sun Microsystems, Inc. + */ +package org.netbeans.modules.cnd.makeproject.ui.customizer; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import org.netbeans.modules.cnd.makeproject.api.configurations.Configuration; + +/** + * + * @author vkvashin + */ +public class ConfigurationCellRenderer extends DefaultListCellRenderer { + + private final ListCellRenderer delegateRenderer; + + public ConfigurationCellRenderer(JComboBox comboBox) { + this.delegateRenderer = comboBox.getRenderer(); + } + + ConfigurationCellRenderer(JList list) { + this.delegateRenderer = list.getCellRenderer(); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + Component c = delegateRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (c instanceof JLabel) { + if (value instanceof Configuration) { + ((JLabel) c).setText(((Configuration) value).getDisplayNameExt()); + } + } + return c; + } +} diff -r 50f6c2df5ea4 -r c1a94c3f392d cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/customizer/MakeCustomizer.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/customizer/MakeCustomizer.java Mon Feb 01 22:56:01 2016 +0300 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/customizer/MakeCustomizer.java Tue Feb 02 11:49:27 2016 +0300 @@ -56,7 +56,9 @@ import java.util.List; import java.util.Map; import javax.swing.JComponent; +import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.ListCellRenderer; import javax.swing.tree.TreeSelectionModel; import org.netbeans.api.project.Project; import org.netbeans.modules.cnd.makeproject.api.MakeProjectCustomizer; @@ -117,6 +119,10 @@ /** Creates new form MakeCustomizer */ public MakeCustomizer(Project project, String preselectedNodeName, ConfigurationDescriptor projectDescriptor, List items, List folders, Collection controls) { initComponents(); + ListCellRenderer renderer = this.configurationComboBox.getRenderer(); + if (true) { + this.configurationComboBox.setRenderer(new ConfigurationCellRenderer(configurationComboBox)); + } this.projectDescriptor = projectDescriptor; this.controls = new ArrayList<>(controls); this.project = project; @@ -695,6 +701,11 @@ setAllowedToRemoveAll(false); } + @Override + protected void adjustListCellRenderer(JList targetList) { + targetList.setCellRenderer(new ConfigurationCellRenderer(targetList)); + } + private Folder getTestsRootFolder(MakeConfigurationDescriptor projectDescriptor) { Folder root = projectDescriptor.getLogicalFolders(); for (Folder folder : root.getFolders()) { diff -r 50f6c2df5ea4 -r c1a94c3f392d cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/utils/ConfSelectorPanel.form --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/utils/ConfSelectorPanel.form Mon Feb 01 22:56:01 2016 +0300 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/utils/ConfSelectorPanel.form Tue Feb 02 11:49:27 2016 +0300 @@ -1,4 +1,4 @@ - +
diff -r 50f6c2df5ea4 -r c1a94c3f392d cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/utils/ConfSelectorPanel.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/utils/ConfSelectorPanel.java Mon Feb 01 22:56:01 2016 +0300 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/ui/utils/ConfSelectorPanel.java Tue Feb 02 11:49:27 2016 +0300 @@ -78,7 +78,7 @@ JCheckBox checkBox = new JCheckBox(); checkBox.addActionListener(checkBoxActionListener); checkBox.setBackground(new java.awt.Color(255, 255, 255)); - checkBox.setText(configurationItems[i].toString()); + checkBox.setText(configurationItems[i].getDisplayNameExt()); checkBox.setSelected(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; diff -r 50f6c2df5ea4 -r c1a94c3f392d cnd.utils/src/org/netbeans/modules/cnd/utils/ui/ListEditorPanel.java --- a/cnd.utils/src/org/netbeans/modules/cnd/utils/ui/ListEditorPanel.java Mon Feb 01 22:56:01 2016 +0300 +++ b/cnd.utils/src/org/netbeans/modules/cnd/utils/ui/ListEditorPanel.java Tue Feb 02 11:49:27 2016 +0300 @@ -115,6 +115,7 @@ targetList = new JList(); targetList.setVisibleRowCount(6); targetList.setModel(new MyModel(listData)); + adjustListCellRenderer(targetList); targetList.addListSelectionListener(new TargetSelectionListener()); // VK: NoIZ: keyboard navigation does not work in Predefined Macros and Include Search Path components // targetList.addKeyListener(new java.awt.event.KeyAdapter() { @@ -838,6 +839,9 @@ } } + protected void adjustListCellRenderer(JList targetList) { + } + private class TargetSelectionListener implements ListSelectionListener { @Override