harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r606883 - in /harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing: JList.java plaf/basic/BasicListUI.java plaf/metal/MetalFileChooserUI.java
Date Wed, 26 Dec 2007 11:27:52 GMT
Author: apetrenko
Date: Wed Dec 26 03:27:46 2007
New Revision: 606883

URL: http://svn.apache.org/viewvc?rev=606883&view=rev
Log:
Patch for HARMONY-5279 "[classlib][swing][EIOffice] 
JList.getToolTipText(MouseEvent) throws NPE if set ListCellRenderer to 
null"

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JList.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JList.java?rev=606883&r1=606882&r2=606883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JList.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JList.java
Wed Dec 26 03:27:46 2007
@@ -299,6 +299,8 @@
 
 
             private Component getRenderingComponent() {
+                if(list.getCellRenderer()==null)
+                    return null;
                 return list.getCellRenderer().getListCellRendererComponent(list, list.getModel().getElementAt(indexInParent),
indexInParent, false, false);
             }
         }
@@ -585,8 +587,9 @@
             Object oldValue = this.prototypeCellValue;
             this.prototypeCellValue = prototypeCellValue;
             firePropertyChange(PROTOTYPE_CELL_VALUE_CHANGED_PROPERTY, oldValue, prototypeCellValue);
-
-            Dimension prototypePreferredSize = getCellRenderer().getListCellRendererComponent(this,
prototypeCellValue, 0, false, false).getPreferredSize();
+            Dimension prototypePreferredSize = new Dimension(0,0);
+            if (getCellRenderer() != null)
+            prototypePreferredSize = getCellRenderer().getListCellRendererComponent(this,
prototypeCellValue, 0, false, false).getPreferredSize();
             this.fixedCellWidth = prototypePreferredSize.width;
             this.fixedCellHeight = prototypePreferredSize.height;
         }
@@ -985,6 +988,9 @@
         if (index == -1) {
             return super.getToolTipText();
         }
+        if (cellRenderer == null) {
+        return super.getToolTipText();
+        }
         Component renderer = cellRenderer.getListCellRendererComponent(this, model.getElementAt(index),
index, false, false);
         String result = null;
         if (renderer instanceof JComponent) {
@@ -1025,6 +1031,8 @@
 
     private int getMaximumCellWidth() {
         int result = 0;
+        if(cellRenderer==null)
+            return result;
         for (int i = 0; i < model.getSize(); i++) {
             int width = cellRenderer.getListCellRendererComponent(this, model.getElementAt(i),
i, false, false).getPreferredSize().width;
             if (result < width) {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java?rev=606883&r1=606882&r2=606883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java
Wed Dec 26 03:27:46 2007
@@ -640,8 +640,10 @@
     }
 
     protected void paintCell(final Graphics g, final int row, final Rectangle rowBounds,
final ListCellRenderer cellRenderer, final ListModel dataModel, final ListSelectionModel selModel,
final int leadIndex) {
-        Component renderer = list.getCellRenderer().getListCellRendererComponent(list, dataModel.getElementAt(row),
row, selModel.isSelectedIndex(row), list.isFocusOwner() && selModel.getLeadSelectionIndex()
== row);
-        rendererPane.paintComponent(g, renderer, list, rowBounds.x, rowBounds.y, rowBounds.width,
rowBounds.height);
+        if (list.getCellRenderer() != null){
+             Component renderer = list.getCellRenderer().getListCellRendererComponent(list,
dataModel.getElementAt(row), row, selModel.isSelectedIndex(row), list.isFocusOwner() &&
selModel.getLeadSelectionIndex() == row);
+             rendererPane.paintComponent(g, renderer, list, rowBounds.x, rowBounds.y, rowBounds.width,
rowBounds.height);
+      }
     }
 
     protected void selectNextIndex() {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java?rev=606883&r1=606882&r2=606883&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/metal/MetalFileChooserUI.java
Wed Dec 26 03:27:46 2007
@@ -335,18 +335,18 @@
 
             public void configure() {
                 Rectangle editorBounds = list.getCellBounds(editingIndex, editingIndex);
-                JLabel renderer = (JLabel)list.getCellRenderer().getListCellRendererComponent(list,
list.getModel().getElementAt(editingIndex), editingIndex, true, true);
-                String text = renderer.getText();
-                setText(text);
-                Icon icon = renderer.getIcon();
-                if (icon != null) {
-                    int offset = icon.getIconWidth() + renderer.getIconTextGap();
-                    editorBounds.x += offset;
-                    editorBounds.width -= offset;
+                if(list.getCellRenderer()!=null){                
+                    JLabel renderer = (JLabel)list.getCellRenderer().getListCellRendererComponent(list,
list.getModel().getElementAt(editingIndex), editingIndex, true, true);
+                    String text = renderer.getText();
+                    setText(text);
+                    Icon icon = renderer.getIcon();
+                    if (icon != null) {
+                           int offset = icon.getIconWidth() + renderer.getIconTextGap();
+                           editorBounds.x += offset;
+                           editorBounds.width -= offset;
+                    }
                 }
-
                 setBounds(editorBounds);
-
                 requestFocus();
                 selectAll();
             }



Mime
View raw message