You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/09/14 03:48:39 UTC

svn commit: r814461 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: ListButton.java ListView.java Spinner.java

Author: tvolkert
Date: Mon Sep 14 01:48:38 2009
New Revision: 814461

URL: http://svn.apache.org/viewvc?rev=814461&view=rev
Log:
Made setSelectedItem(null) be legal for ListView, ListButton, and Spinner, and made it translate to setSelectedIndex(-1)

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java?rev=814461&r1=814460&r2=814461&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java Mon Sep 14 01:48:38 2009
@@ -260,13 +260,13 @@
 
     @SuppressWarnings("unchecked")
     public void setSelectedItem(Object item) {
-        if (item == null) {
-            throw new IllegalArgumentException("item is null");
-        }
+        int index = -1;
 
-        int index = ((List<Object>)listData).indexOf(item);
-        if (index == -1) {
-            throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
+        if (item != null) {
+            index = ((List<Object>)listData).indexOf(item);
+            if (index == -1) {
+                throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
+            }
         }
 
         setSelectedIndex(index);

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java?rev=814461&r1=814460&r2=814461&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java Mon Sep 14 01:48:38 2009
@@ -852,13 +852,13 @@
 
     @SuppressWarnings("unchecked")
     public void setSelectedItem(Object item) {
-        if (item == null) {
-            throw new IllegalArgumentException("item is null");
-        }
+        int index = -1;
 
-        int index = ((List<Object>)listData).indexOf(item);
-        if (index == -1) {
-            throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
+        if (item != null) {
+            index = ((List<Object>)listData).indexOf(item);
+            if (index == -1) {
+                throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
+            }
         }
 
         setSelectedIndex(index);

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java?rev=814461&r1=814460&r2=814461&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java Mon Sep 14 01:48:38 2009
@@ -373,13 +373,13 @@
 
     @SuppressWarnings("unchecked")
     public void setSelectedItem(Object item) {
-        if (item == null) {
-            throw new IllegalArgumentException("item is null");
-        }
+        int index = -1;
 
-        int index = ((List<Object>)spinnerData).indexOf(item);
-        if (index == -1) {
-            throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
+        if (item != null) {
+            index = ((List<Object>)spinnerData).indexOf(item);
+            if (index == -1) {
+                throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
+            }
         }
 
         setSelectedIndex(index);