harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r495989 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/basic/BasicComboBoxEditor.java test/api/java/common/javax/swing/plaf/basic/BasicComboBoxEditorTest.java
Date Sat, 13 Jan 2007 22:39:37 GMT
Author: hindessm
Date: Sat Jan 13 14:39:36 2007
New Revision: 495989

URL: http://svn.apache.org/viewvc?view=rev&rev=495989
Log:
Applying patch from "[#HARMONY-2651] [classlib][swing]
javax.swing.plaf.basic.BasicComboBoxEditor.getItem() is inconsistent with
RI".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxEditor.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxEditorTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxEditor.java?view=diff&rev=495989&r1=495988&r2=495989
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicComboBoxEditor.java
Sat Jan 13 14:39:36 2007
@@ -32,6 +32,8 @@
 
 public class BasicComboBoxEditor implements ComboBoxEditor, FocusListener {
 
+    private Object item = "";
+    
     public static class UIResource extends BasicComboBoxEditor implements javax.swing.plaf.UIResource
{
     }
 
@@ -57,11 +59,16 @@
     }
 
     public Object getItem() {
-        return editor.getText();
+        String text = editor.getText();
+        if (!text.equals(item.toString())) {
+            item = text;
+        }
+        return item;
     }
 
     public void setItem(final Object item) {
-        editor.setText(item != null ? item.toString() : null);
+        this.item = item != null ? item : "";
+        editor.setText(this.item.toString());
     }
 
     public void selectAll() {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxEditorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxEditorTest.java?view=diff&rev=495989&r1=495988&r2=495989
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxEditorTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxEditorTest.java
Sat Jan 13 14:39:36 2007
@@ -24,6 +24,7 @@
 import java.awt.event.ActionListener;
 import javax.swing.JTextField;
 import javax.swing.SwingTestCase;
+import javax.swing.text.JTextComponent;
 
 public class BasicComboBoxEditorTest extends SwingTestCase {
     private BasicComboBoxEditor editor;
@@ -88,4 +89,37 @@
         public void actionPerformed(final ActionEvent e) {
         }
     }
+    
+    /**
+     * Regression test for HARMONY-2651 
+     * */
+    public void testRGetSetItem() {
+        editor.selectAll();
+        assertEquals("", editor.getItem());
+
+        Object obj1 = new java.util.jar.Attributes.Name("AAAAAAAAAAAAAAA");
+        String obj2 = "BBBBBBBBBBBBB";
+        JTextComponent editorComponent = (JTextComponent)editor.getEditorComponent();
+        editorComponent.setText(obj2);
+        editor.setItem(obj1);
+        assertSame(obj1, editor.getItem());
+        assertEquals(obj1.toString(), editorComponent.getText());
+        editor.setItem(null);
+        assertEquals("", editor.getItem());
+    }
+
+    /**
+     * Regression test for HARMONY-2651 
+     * */
+    public void testGetItem() {
+        editor.selectAll();
+        Object obj1 = new java.util.jar.Attributes.Name("AAAAAAAAAAAAAAA");
+        Object obj2 = "BBBBBBBBBBBBBB";
+        editor.setItem(obj1);
+        JTextComponent editorComponent = (JTextComponent)editor.getEditorComponent();
+        editorComponent.setText((String)obj2);
+        assertNotSame(obj2, editor.getItem());
+        assertEquals(obj2, editor.getItem());
+    }
+
 }



Mime
View raw message