Allow a SuggestBox to be created with a ValueBoxBase<String> instead of a
TextBox.

Deprecates the getTextBox() method in favor of getValueBox().

Contributed by: seanross
Fixes issue 7571
Review at https://codereview.appspot.com/6492092/


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11260 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/SuggestBox.java b/user/src/com/google/gwt/user/client/ui/SuggestBox.java
index 58f7d9f..650372a 100644
--- a/user/src/com/google/gwt/user/client/ui/SuggestBox.java
+++ b/user/src/com/google/gwt/user/client/ui/SuggestBox.java
@@ -97,11 +97,9 @@
  * <dd>the suggest box itself</dd>
  * </dl>
  *
- * TODO(pdr): Add SafeHtml support to this and implementing classes.
- *
  * @see SuggestOracle
  * @see MultiWordSuggestOracle
- * @see TextBoxBase
+ * @see ValueBoxBase
  */
 @SuppressWarnings("deprecation")
 public class SuggestBox extends Composite implements HasText, HasFocus,
@@ -666,7 +664,7 @@
   private String currentText;
   private LeafValueEditor<String> editor;
   private final SuggestionDisplay display;
-  private final TextBoxBase box;
+  private final ValueBoxBase<String> box;
   private final Callback callback = new Callback() {
     public void onSuggestionsReady(Request request, Response response) {
       // If disabled while request was in-flight, drop it
@@ -713,7 +711,7 @@
    *          text widget
    * @param box the text widget
    */
-  public SuggestBox(SuggestOracle oracle, TextBoxBase box) {
+  public SuggestBox(SuggestOracle oracle, ValueBoxBase<String> box) {
     this(oracle, box, new DefaultSuggestionDisplay());
   }
 
@@ -726,7 +724,7 @@
    * @param box the text widget
    * @param suggestDisplay the class used to display suggestions
    */
-  public SuggestBox(SuggestOracle oracle, TextBoxBase box,
+  public SuggestBox(SuggestOracle oracle, ValueBoxBase<String> box,
       SuggestionDisplay suggestDisplay) {
     this.box = box;
     this.display = suggestDisplay;
@@ -873,9 +871,13 @@
    * Get the text box associated with this suggest box.
    *
    * @return this suggest box's text box
+   * @throws ClassCastException if this suggest box's value box is not an
+   *     instance of TextBoxBase
+   * @deprecated in favour of getValueBox
    */
+  @Deprecated
   public TextBoxBase getTextBox() {
-    return box;
+    return (TextBoxBase) box;
   }
 
   public String getValue() {
@@ -883,6 +885,15 @@
   }
 
   /**
+   * Get the ValueBoxBase associated with this suggest box.
+   *
+   * @return this suggest box's value box
+   */
+  public ValueBoxBase<String> getValueBox() {
+    return box;
+  }
+
+  /**
    * Hide current suggestions in the {@link DefaultSuggestionDisplay}. Note that
    * this method is a no-op unless the {@link DefaultSuggestionDisplay} is used.
    *