Class ValueListBox<T>

Type Parameters:
T - the value type
All Implemented Interfaces:
IsEditor<TakesValueEditor<T>>, HasAttachHandlers, HasValueChangeHandlers<T>, HasHandlers, EventListener, TakesValue<T>, Focusable, HasConstrainedValue<T>, HasEnabled, HasValue<T>, HasVisibility, IsRenderable, IsWidget

public class ValueListBox<T> extends Composite implements Focusable, HasConstrainedValue<T>, HasEnabled, IsEditor<TakesValueEditor<T>>
Implementation of HasConstrainedValue based on a SelectElement.

A Renderer is used to get user-presentable strings to display in the select element.

  • Constructor Details

    • ValueListBox

      public ValueListBox()
    • ValueListBox

      public ValueListBox(Renderer<? super T> renderer)
    • ValueListBox

      public ValueListBox(Renderer<? super T> renderer, ProvidesKey<T> keyProvider)
  • Method Details

    • addValueChangeHandler

      public HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler)
      Description copied from interface: HasValueChangeHandlers
      Adds a ValueChangeEvent handler.
      Specified by:
      addValueChangeHandler in interface HasValueChangeHandlers<T>
      Parameters:
      handler - the handler
      Returns:
      the registration for the event
    • asEditor

      public TakesValueEditor<T> asEditor()
      Returns a TakesValueEditor backed by the ValueListBox.
      Specified by:
      asEditor in interface IsEditor<T>
      Returns:
      an Editor of type E
    • getTabIndex

      public int getTabIndex()
      Description copied from interface: Focusable
      Gets the widget's position in the tab index.
      Specified by:
      getTabIndex in interface Focusable
      Returns:
      the widget's tab index
    • getValue

      public T getValue()
      Description copied from interface: HasValue
      Gets this object's value.
      Specified by:
      getValue in interface HasValue<T>
      Specified by:
      getValue in interface TakesValue<T>
      Returns:
      the object's value
      See Also:
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: HasEnabled
      Returns true if the widget is enabled, false if not.
      Specified by:
      isEnabled in interface HasEnabled
    • setAcceptableValues

      public void setAcceptableValues(Collection<T> newValues)
      Description copied from interface: HasConstrainedValue
      Set the acceptable values.
      Specified by:
      setAcceptableValues in interface HasConstrainedValue<T>
      Parameters:
      newValues - the acceptible values
    • setAccessKey

      public void setAccessKey(char key)
      Description copied from interface: Focusable
      Sets the widget's 'access key'. This key is used (in conjunction with a browser-specific modifier key) to automatically focus the widget.
      Specified by:
      setAccessKey in interface Focusable
      Parameters:
      key - the widget's access key
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: HasEnabled
      Sets whether this widget is enabled.
      Specified by:
      setEnabled in interface HasEnabled
      Parameters:
      enabled - true to enable the widget, false to disable it
    • setFocus

      public void setFocus(boolean focused)
      Description copied from interface: Focusable
      Explicitly focus/unfocus this widget. Only one widget can have focus at a time, and the widget that does will receive all keyboard events. NOTE: Most browsers fire FocusEvents asynchronously. Especially within GWT tests, you'll need to make your test asynchronous to properly do verifications. See GWTTestCase#delayTestFinish for more information on how to do this.
      Specified by:
      setFocus in interface Focusable
      Parameters:
      focused - whether this widget should take focus or release it
    • setTabIndex

      public void setTabIndex(int index)
      Description copied from interface: Focusable
      Sets the widget's position in the tab index. If more than one widget has the same tab index, each such widget will receive focus in an arbitrary order. Setting the tab index to -1 will cause this widget to be removed from the tab order.
      Specified by:
      setTabIndex in interface Focusable
      Parameters:
      index - the widget's tab index
    • setValue

      public void setValue(T value)
      Set the value and display it in the select element. Add the value to the acceptable set if it is not already there.
      Specified by:
      setValue in interface HasValue<T>
      Specified by:
      setValue in interface TakesValue<T>
      Parameters:
      value - the object's new value
      See Also:
    • setValue

      public void setValue(T value, boolean fireEvents)
      Description copied from interface: HasValue
      Sets this object's value. Fires ValueChangeEvent when fireEvents is true and the new value does not equal the existing value.

      It is acceptable to fail assertions or throw (documented) unchecked exceptions in response to bad values.

      Specified by:
      setValue in interface HasValue<T>
      Parameters:
      value - the object's new value
      fireEvents - fire events if true and value is new