Makes TextBoxBase follow the set(null)-to-clear convention.  Punches
up CheckBox docs to make it clear it doesn't do so, and why, and adds
test to keep it that way.

reviewer: ajr
submitter: rjrjr



git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4263 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/CheckBox.java b/user/src/com/google/gwt/user/client/ui/CheckBox.java
index a9eba4f..a40700b 100644
--- a/user/src/com/google/gwt/user/client/ui/CheckBox.java
+++ b/user/src/com/google/gwt/user/client/ui/CheckBox.java
@@ -135,6 +135,11 @@
     return DOM.getInnerText(labelElem);
   }
 
+  /**
+   * Determines whether this check box is currently checked.
+   * 
+   * @return <code>true</code> if the check box is checked
+   */
   public Boolean getValue() {
     return isChecked();
   }
@@ -163,7 +168,7 @@
    * Checks or unchecks this check box. Does not fire {@link ValueChangeEvent}.
    * (If you want the event to fire, use {@link #setValue(boolean, boolean)})
    * 
-   * @param checked <code>true</code> to check the check box
+   * @param checked <code>true</code> to check the check box.
    */
   public void setChecked(boolean checked) {
     DOM.setElementPropertyBoolean(inputElem, "checked", checked);
@@ -214,12 +219,29 @@
     DOM.setInnerText(labelElem, text);
   }
 
+  /**
+   * Checks or unchecks the text box. 
+   * @param value true to check, false to uncheck. Must not be null.
+   * @thows IllegalArgumentException if value is null
+   */
   public void setValue(Boolean value) {
     setValue(value, false);
   }
 
+  /**
+   * Checks or unchecks the text box, firing {@link ValueChangeEvent}
+   * if appropriate.
+   *
+   * @param value true to check, false to uncheck. Must not be null.
+   * @param fireEvents If true, and value has changed, fire a
+   * {@link ValueChangeEvent}
+   * @thows IllegalArgumentException if value is null
+   */
   public void setValue(Boolean value, boolean fireEvents) {
-    assert null != value : "Value must not be null";
+    if (value == null) {
+      throw new IllegalArgumentException("value must not be null");
+    }
+
     if (isChecked() == value) {
       return;
     }
diff --git a/user/src/com/google/gwt/user/client/ui/TextBoxBase.java b/user/src/com/google/gwt/user/client/ui/TextBoxBase.java
index 3f7660a..3a8554e 100644
--- a/user/src/com/google/gwt/user/client/ui/TextBoxBase.java
+++ b/user/src/com/google/gwt/user/client/ui/TextBoxBase.java
@@ -301,7 +301,6 @@
   }
 
   public void setValue(String value, boolean fireEvents) {
-    assert null != value : "Value must not be null";
     String oldValue = getText();
     setText(value);
     if (fireEvents) {
diff --git a/user/test/com/google/gwt/user/client/ui/CheckBoxTest.java b/user/test/com/google/gwt/user/client/ui/CheckBoxTest.java
index 5bb0f60..4421754 100644
--- a/user/test/com/google/gwt/user/client/ui/CheckBoxTest.java
+++ b/user/test/com/google/gwt/user/client/ui/CheckBoxTest.java
@@ -108,6 +108,13 @@
 
     cb.setValue(true, true);
     assertTrue(h.received);
+    
+    try {
+      cb.setValue(null);
+      fail("Should throw IllegalArgumentException");
+    } catch (IllegalArgumentException e) {
+      /* pass */
+    }
   }
   
   private static class Handler implements ValueChangeHandler<Boolean> {