Re: [cp-patches] FYI: JComboBox fixes
Hi Roman, On Sat, 2007-01-06 at 16:44 +0100, Roman Kennke wrote: This fixes one weird NPE (see associated bug report) and I also cleaned up some inconsistencies that I came over and some warnings that Eclipse came over :-) 2007-01-06 Roman Kennke [EMAIL PROTECTED] PR 30337 * javax/swing/plaf/basic/BasicComboBoxUI.java (installUI): Install popup and list here. Don't configure the arrow button and editor here. (installComponents): Don't install popup and list here. (Moved to installUI). Configure arrow button here and check for null. (addEditor): Configure editor here. (configureArrowButton): Directly fetch listeners from popup. (paintCurrentValue): Removed unused local variables. (layoutContainer): Removed unused local variables. (PropertyChangeHandler.propertyChange): Don't invalidate minimumSize on each property change. Avoid calling getPropertyName() repeatedly. Clean up. Call addEditor() when editor changes. Configure and unconfigure editor when editable changes. Use 'model' instead of non-existing 'dataModel' property. * javax/swing/plaf/basic/BasicComboPopup.java (uninstallingUI): Remove property change listener and item listener here. Uninstall list listeners. Set model to null to prevent leakage. (configureList): Don't sync list selection there. (uninstallComboBoxListeners): Moved to uninstallingUI. (uninstallListeners): Moved to uninstallingUI. * javax/swing/plaf/metal/MetalComboBoxUI.java (createPopup): Call super. (getMinimumSize): Removed unused statement. Could you take a look at the following Mauve regressions caused by this patch? FAIL: javax.swing.JComboBox.setEditor FAIL: javax.swing.plaf.basic.BasicComboBoxUI.general FAIL: javax.swing.plaf.basic.BasicComboBoxUI.getDefaultSize FAIL: javax.swing.plaf.basic.BasicComboBoxUI.getMaximumSize FAIL: javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize FAIL: javax.swing.plaf.metal.MetalComboBoxUI.createArrowButton Thanks, Mark
Re: [cp-patches] FYI: JComboBox fixes
Hi Mark, On Sat, 2007-01-06 at 16:44 +0100, Roman Kennke wrote: This fixes one weird NPE (see associated bug report) and I also cleaned up some inconsistencies that I came over and some warnings that Eclipse came over :-) 2007-01-06 Roman Kennke [EMAIL PROTECTED] PR 30337 * javax/swing/plaf/basic/BasicComboBoxUI.java (installUI): Install popup and list here. Don't configure the arrow button and editor here. (installComponents): Don't install popup and list here. (Moved to installUI). Configure arrow button here and check for null. (addEditor): Configure editor here. (configureArrowButton): Directly fetch listeners from popup. (paintCurrentValue): Removed unused local variables. (layoutContainer): Removed unused local variables. (PropertyChangeHandler.propertyChange): Don't invalidate minimumSize on each property change. Avoid calling getPropertyName() repeatedly. Clean up. Call addEditor() when editor changes. Configure and unconfigure editor when editable changes. Use 'model' instead of non-existing 'dataModel' property. * javax/swing/plaf/basic/BasicComboPopup.java (uninstallingUI): Remove property change listener and item listener here. Uninstall list listeners. Set model to null to prevent leakage. (configureList): Don't sync list selection there. (uninstallComboBoxListeners): Moved to uninstallingUI. (uninstallListeners): Moved to uninstallingUI. * javax/swing/plaf/metal/MetalComboBoxUI.java (createPopup): Call super. (getMinimumSize): Removed unused statement. Could you take a look at the following Mauve regressions caused by this patch? FAIL: javax.swing.JComboBox.setEditor FAIL: javax.swing.plaf.basic.BasicComboBoxUI.general FAIL: javax.swing.plaf.basic.BasicComboBoxUI.getDefaultSize FAIL: javax.swing.plaf.basic.BasicComboBoxUI.getMaximumSize FAIL: javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize FAIL: javax.swing.plaf.metal.MetalComboBoxUI.createArrowButton Thanks for checking. I believe that some of these failures are caused by an earlier patch (Component.getFont() should _not_ return a default font as checked by another Mauve test). Anyway, I fixed all these regressions. I also added a Mauve test for the original bug report. We are passing them all now and the combo boxes still seem to work. 2007-01-07 Roman Kennke [EMAIL PROTECTED] PR 30337 * java/awt/Component.java (getFontImpl): Return null when the component has no font set and also has no parent yet. * javax/swing/plaf/basic/BasicComboBoxUI.java (PropertyChangeHandler.propertyChange): Only add editor when combo box is editable. Avoid fetching the property name repeatedly. Invalidate when renderer or prototypeDisplayValue change. (uninstallComponents): Unconfigure everything and then remove all components. * javax/swing/plaf/basic/BasicComboPopup.java (uninstallingUI): Don't nullify list model. * javax/swing/plaf/metal/MetalComboBoxUI.java (createArrowButton): Pass currentValuePane to the MetalComboBoxButton constructor rather than a new (unconnected) CellRendererPane. /Roman Index: java/awt/Component.java === RCS file: /cvsroot/classpath/classpath/java/awt/Component.java,v retrieving revision 1.154 diff -u -1 -5 -r1.154 Component.java --- java/awt/Component.java 5 Jan 2007 22:55:59 - 1.154 +++ java/awt/Component.java 7 Jan 2007 21:12:01 - @@ -1186,31 +1186,36 @@ /** * Implementation of getFont(). This is pulled out of getFont() to prevent * client programs from overriding this. * * @return the font of this component */ private final Font getFontImpl() { Font f = font; if (f == null) { Component p = parent; if (p != null) f = p.getFontImpl(); else - f = new Font(Dialog, Font.PLAIN, 12); + { +// It is important to return null here and not some kind of default +// font, otherwise the Swing UI would not install its fonts because +// it keeps non-UIResource fonts. +f = null; + } } return f; } /** * Sets the font for this component to the specified font. This is a bound * property. * * @param f the new font for this component * * @see #getFont() */ public void setFont(Font f) { Font oldFont; Index: javax/swing/plaf/basic/BasicComboBoxUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,v retrieving revision 1.41 diff -u -1 -5 -r1.41 BasicComboBoxUI.java --- javax/swing/plaf/basic/BasicComboBoxUI.java 6 Jan 2007 15:43:21 - 1.41 +++
[cp-patches] FYI: JComboBox fixes
This fixes one weird NPE (see associated bug report) and I also cleaned up some inconsistencies that I came over and some warnings that Eclipse came over :-) 2007-01-06 Roman Kennke [EMAIL PROTECTED] PR 30337 * javax/swing/plaf/basic/BasicComboBoxUI.java (installUI): Install popup and list here. Don't configure the arrow button and editor here. (installComponents): Don't install popup and list here. (Moved to installUI). Configure arrow button here and check for null. (addEditor): Configure editor here. (configureArrowButton): Directly fetch listeners from popup. (paintCurrentValue): Removed unused local variables. (layoutContainer): Removed unused local variables. (PropertyChangeHandler.propertyChange): Don't invalidate minimumSize on each property change. Avoid calling getPropertyName() repeatedly. Clean up. Call addEditor() when editor changes. Configure and unconfigure editor when editable changes. Use 'model' instead of non-existing 'dataModel' property. * javax/swing/plaf/basic/BasicComboPopup.java (uninstallingUI): Remove property change listener and item listener here. Uninstall list listeners. Set model to null to prevent leakage. (configureList): Don't sync list selection there. (uninstallComboBoxListeners): Moved to uninstallingUI. (uninstallListeners): Moved to uninstallingUI. * javax/swing/plaf/metal/MetalComboBoxUI.java (createPopup): Call super. (getMinimumSize): Removed unused statement. /Roman Index: javax/swing/plaf/basic/BasicComboBoxUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,v retrieving revision 1.40 diff -u -1 -5 -r1.40 BasicComboBoxUI.java --- javax/swing/plaf/basic/BasicComboBoxUI.java 24 Jul 2006 15:04:05 - 1.40 +++ javax/swing/plaf/basic/BasicComboBoxUI.java 6 Jan 2007 15:38:45 - @@ -203,52 +203,49 @@ * Installs the UI for the given [EMAIL PROTECTED] JComponent}. * * @param c the JComponent to install a UI for. * * @see #uninstallUI(JComponent) */ public void installUI(JComponent c) { super.installUI(c); if (c instanceof JComboBox) { isMinimumSizeDirty = true; comboBox = (JComboBox) c; installDefaults(); +popup = createPopup(); +listBox = popup.getList(); // Set editor and renderer for the combo box. Editor is used // only if combo box becomes editable, otherwise renderer is used // to paint the selected item; combobox is not editable by default. ListCellRenderer renderer = comboBox.getRenderer(); if (renderer == null || renderer instanceof UIResource) comboBox.setRenderer(createRenderer()); ComboBoxEditor currentEditor = comboBox.getEditor(); if (currentEditor == null || currentEditor instanceof UIResource) { currentEditor = createEditor(); comboBox.setEditor(currentEditor); } -editor = currentEditor.getEditorComponent(); installComponents(); installListeners(); -if (arrowButton != null) - configureArrowButton(); -if (editor != null) - configureEditor(); comboBox.setLayout(createLayoutManager()); comboBox.setFocusable(true); installKeyboardActions(); comboBox.putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP, Boolean.TRUE); } } /** * Uninstalls the UI for the given [EMAIL PROTECTED] JComponent}. * * @param c The JComponent that is having this UI removed. * * @see #installUI(JComponent) */ @@ -461,37 +458,35 @@ * @return A new component that will be responsible for displaying/editing * the selected item in the combo box. */ protected ComboBoxEditor createEditor() { return new BasicComboBoxEditor.UIResource(); } /** * Installs the components for this JComboBox. ArrowButton, main * part of combo box (upper part) and popup list of items are created and * configured here. */ protected void installComponents() { -// create drop down list of items -popup = createPopup(); -listBox = popup.getList(); - // create and install arrow button arrowButton = createArrowButton(); comboBox.add(arrowButton); +if (arrowButton != null) + configureArrowButton(); if (comboBox.isEditable()) addEditor(); comboBox.add(currentValuePane); } /** * Uninstalls components from this [EMAIL PROTECTED] JComboBox}. * * @see #installComponents() */ protected void uninstallComponents() { // uninstall arrow button @@ -509,31 +504,35 @@ ComboBoxEditor
[cp-patches] FYI: JComboBox fixes
This patch fixes some failing Mauve tests: 2005-10-18 David Gilbert [EMAIL PROTECTED] * javax/swing/JComboBox.java (setModel): update the selectedItemReminder field, (selectedItemChanged): only send ItemEvent.SELECTED event if the new selection is non-null. Regards, Dave Index: javax/swing/JComboBox.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComboBox.java,v retrieving revision 1.21 diff -u -r1.21 JComboBox.java --- javax/swing/JComboBox.java 12 Oct 2005 12:38:20 - 1.21 +++ javax/swing/JComboBox.java 18 Oct 2005 16:36:35 - @@ -311,7 +311,8 @@ // Stores old data model for event notification. ComboBoxModel oldDataModel = dataModel; dataModel = newDataModel; - +selectedItemReminder = newDataModel.getSelectedItem(); + // Notifies the listeners of the model change. firePropertyChange(model, oldDataModel, dataModel); } @@ -901,8 +902,9 @@ // Fire ItemEvent to indicate that new item is selected Object newSelection = getSelectedItem(); -fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, - newSelection, ItemEvent.SELECTED)); +if (newSelection != null) + fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, + newSelection, ItemEvent.SELECTED)); // Fire Action Event to JComboBox's registered listeners fireActionEvent(); ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches