You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/10/10 23:48:54 UTC

svn commit: r462591 - in /incubator/harmony/enhanced/classlib/trunk/modules/swing: build.xml src/main/java/common/javax/swing/JComboBox.java src/test/api/java/common/javax/swing/JComboBoxRTest.java

Author: tellison
Date: Tue Oct 10 14:48:53 2006
New Revision: 462591

URL: http://svn.apache.org/viewvc?view=rev&rev=462591
Log:
Apply patch HARMONY-1533 ([classlib][swing] JCombobox.setSelectedItem() sometimes doesn't fire action event)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComboBoxRTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml?view=diff&rev=462591&r1=462590&r2=462591
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml Tue Oct 10 14:48:53 2006
@@ -198,7 +198,6 @@
                     <exclude name="javax/swing/text/ViewTestHelpers.java"/>
                     <exclude name="javax/swing/text/View_ForwardUpdateRTest.java"/>
 
-                    <exclude name="javax/swing/JComboBoxRTest.java"/>
                     <exclude name="javax/swing/JComboBoxTest.java"/>
                     <exclude name="javax/swing/JComponentTest.java"/>
                     <exclude name="javax/swing/JMenuTest.java"/>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java?view=diff&rev=462591&r1=462590&r2=462591
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComboBox.java Tue Oct 10 14:48:53 2006
@@ -294,8 +294,13 @@
                 dataModel.setSelectedItem(element);
             } else if (isEditable && element != null && !element.equals(getEditor().getItem())) {
                 getEditor().setItem(element);
+            } else {
+                // fire action event even if selection is not changed
+                fireActionEvent();
             }
         }
+
+        
     }
 
     public Object getSelectedItem() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComboBoxRTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComboBoxRTest.java?view=diff&rev=462591&r1=462590&r2=462591
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComboBoxRTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComboBoxRTest.java Tue Oct 10 14:48:53 2006
@@ -20,9 +20,14 @@
  */
 package javax.swing;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
 import junit.framework.TestCase;
 
 public class JComboBoxRTest extends TestCase {
+    private boolean eventFired;
+
     public void testJComboBox() throws Exception {
         new JComboBox();
     }
@@ -41,8 +46,8 @@
     public void testKeyboardActionsEnabled() throws Exception {
         JComboBox cb = new JComboBox(new String[] {"1", "2", "4"});
         checkActionState(cb, "hidePopup", false);
-        checkActionState(cb, "enterPressed", false);
-        checkActionState(cb, "selectPrevious", false);
+        checkActionState(cb, "enterPressed", true);
+        checkActionState(cb, "selectPrevious", true);
 
         checkActionState(cb, "togglePopup", true);
         checkActionState(cb, "spacePopup", true);
@@ -53,5 +58,18 @@
         Action action = cb.getActionMap().get(actionName);
         assertNotNull(action);
         assertEquals(expectedState, action.isEnabled());
+    }
+    
+    public void testSetSelectedItem() {
+        // regression test HARMONY-1533
+        String item = "item";
+        JComboBox jcb = new JComboBox(new String[]{item});
+        jcb.addActionListener(new ActionListener(){
+            public void actionPerformed(ActionEvent ae) {
+                eventFired = true;               
+            }            
+        });
+        jcb.setSelectedItem(item);
+        assertTrue("action performed", eventFired);
     }
 }