Class ValueBoxBase<T>

  • Type Parameters:
    T - the value type
    All Implemented Interfaces:
    com.google.gwt.event.dom.client.HasAllDragAndDropHandlers, com.google.gwt.event.dom.client.HasAllFocusHandlers, com.google.gwt.event.dom.client.HasAllGestureHandlers, com.google.gwt.event.dom.client.HasAllKeyHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasAllTouchHandlers, com.google.gwt.event.dom.client.HasBlurHandlers, com.google.gwt.event.dom.client.HasChangeHandlers, com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasDoubleClickHandlers, com.google.gwt.event.dom.client.HasDragEndHandlers, com.google.gwt.event.dom.client.HasDragEnterHandlers, com.google.gwt.event.dom.client.HasDragHandlers, com.google.gwt.event.dom.client.HasDragLeaveHandlers, com.google.gwt.event.dom.client.HasDragOverHandlers, com.google.gwt.event.dom.client.HasDragStartHandlers, com.google.gwt.event.dom.client.HasDropHandlers, com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.dom.client.HasGestureChangeHandlers, com.google.gwt.event.dom.client.HasGestureEndHandlers, com.google.gwt.event.dom.client.HasGestureStartHandlers, com.google.gwt.event.dom.client.HasKeyDownHandlers, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.HasKeyUpHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers, com.google.gwt.event.dom.client.HasMouseMoveHandlers, com.google.gwt.event.dom.client.HasMouseOutHandlers, com.google.gwt.event.dom.client.HasMouseOverHandlers, com.google.gwt.event.dom.client.HasMouseUpHandlers, com.google.gwt.event.dom.client.HasMouseWheelHandlers, com.google.gwt.event.dom.client.HasTouchCancelHandlers, com.google.gwt.event.dom.client.HasTouchEndHandlers, com.google.gwt.event.dom.client.HasTouchMoveHandlers, com.google.gwt.event.dom.client.HasTouchStartHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasValueChangeHandlers<T>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.i18n.client.AutoDirectionHandler.Target, com.google.gwt.i18n.client.HasDirection, com.google.gwt.i18n.shared.HasDirectionEstimator, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.TakesValue<T>, com.google.gwt.user.client.ui.Focusable, com.google.gwt.user.client.ui.HasEnabled, com.google.gwt.user.client.ui.HasFocus, com.google.gwt.user.client.ui.HasName, com.google.gwt.user.client.ui.HasText, com.google.gwt.user.client.ui.HasValue<T>, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsWidget, com.google.gwt.user.client.ui.SourcesClickEvents, com.google.gwt.user.client.ui.SourcesFocusEvents, com.google.gwt.user.client.ui.SourcesKeyboardEvents, com.google.gwt.user.client.ui.SourcesMouseEvents, org.gwtproject.editor.client.IsEditor<ValueBoxEditor<T>>, org.gwtproject.editor.client.TakesValue<T>

    public class ValueBoxBase<T>
    extends com.google.gwt.user.client.ui.FocusWidget
    implements com.google.gwt.event.dom.client.HasChangeHandlers, com.google.gwt.user.client.ui.HasName, com.google.gwt.i18n.shared.HasDirectionEstimator, org.gwtproject.editor.client.TakesValue<T>, com.google.gwt.user.client.ui.HasValue<T>, com.google.gwt.user.client.ui.HasText, com.google.gwt.i18n.client.AutoDirectionHandler.Target, org.gwtproject.editor.client.IsEditor<ValueBoxEditor<T>>
    Abstract base class for all text entry widgets.

    Use in UiBinder Templates

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ValueBoxBase.TextAlignment
      • Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject

        com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
      • Nested classes/interfaces inherited from interface com.google.gwt.i18n.client.HasDirection

        com.google.gwt.i18n.client.HasDirection.Direction
    • Field Summary

      • Fields inherited from class com.google.gwt.user.client.ui.UIObject

        DEBUG_ID_PREFIX
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ValueBoxBase​(com.google.gwt.dom.client.Element elem, com.google.gwt.text.shared.Renderer<T> renderer, com.google.gwt.text.shared.Parser<T> parser)
      Creates a value box that wraps the given browser element handle.
      protected ValueBoxBase​(com.google.gwt.user.client.ui.ValueBoxBase<T> oldBox)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      com.google.gwt.event.shared.HandlerRegistration addChangeHandler​(com.google.gwt.event.dom.client.ChangeHandler handler)  
      com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler​(com.google.gwt.event.logical.shared.ValueChangeHandler<T> handler)  
      ValueBoxEditor<T> asEditor()
      Returns an Editor that is backed by the ValueBoxBase.
      void cancelKey()
      If a keyboard event is currently being handled on this text box, calling this method will suppress it.
      int getCursorPos()
      Gets the current position of the cursor (this also serves as the beginning of the text selection).
      com.google.gwt.i18n.client.HasDirection.Direction getDirection()  
      com.google.gwt.i18n.shared.DirectionEstimator getDirectionEstimator()
      Gets the direction estimation model of the auto-dir handler.
      protected com.google.gwt.user.client.ui.impl.TextBoxImpl getImpl()  
      String getName()  
      String getSelectedText()
      Gets the text currently selected within this text box.
      int getSelectionLength()
      Gets the length of the current text selection.
      String getText()  
      T getValue()
      Return the parsed value, or null if the field is empty or parsing fails.
      T getValueOrThrow()
      Return the parsed value, or null if the field is empty.
      boolean isReadOnly()
      Determines whether or not the widget is read-only.
      static <T> ValueBoxBase<T> oldToNew​(com.google.gwt.user.client.ui.ValueBoxBase<T> oldBox)  
      void onBrowserEvent​(com.google.gwt.user.client.Event event)  
      protected void onLoad()  
      void removeChangeListener​(com.google.gwt.user.client.ui.ChangeListener listener)
      Deprecated.
      Use the HandlerRegistration.removeHandler() method on the object returned by addChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) instead
      void selectAll()
      Selects all of the text in the box.
      void setAlignment​(ValueBoxBase.TextAlignment align)  
      void setCursorPos​(int pos)
      Sets the cursor position.
      void setDirection​(com.google.gwt.i18n.client.HasDirection.Direction direction)  
      void setDirectionEstimator​(boolean enabled)
      Toggles on / off direction estimation.
      void setDirectionEstimator​(com.google.gwt.i18n.shared.DirectionEstimator directionEstimator)
      Sets the direction estimation model of the auto-dir handler.
      void setKey​(char key)
      Deprecated.
      this method only works in IE and should not have been added to the API
      void setName​(String name)  
      void setReadOnly​(boolean readOnly)
      Turns read-only mode on or off.
      void setSelectionRange​(int pos, int length)
      Sets the range of text to be selected.
      void setText​(String text)
      Sets this object's text.
      void setValue​(T value)  
      void setValue​(T value, boolean fireEvents)  
      • Methods inherited from class com.google.gwt.user.client.ui.FocusWidget

        addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, getTabIndex, isEnabled, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setEnabled, setFocus, setTabIndex
      • Methods inherited from class com.google.gwt.user.client.ui.Widget

        addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onDetach, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
      • Methods inherited from class com.google.gwt.user.client.ui.UIObject

        addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
      • Methods inherited from interface com.google.gwt.event.shared.HasHandlers

        fireEvent
      • Methods inherited from interface com.google.gwt.event.dom.client.HasKeyUpHandlers

        addKeyUpHandler
    • Constructor Detail

      • ValueBoxBase

        protected ValueBoxBase​(com.google.gwt.dom.client.Element elem,
                               com.google.gwt.text.shared.Renderer<T> renderer,
                               com.google.gwt.text.shared.Parser<T> parser)
        Creates a value box that wraps the given browser element handle. This is only used by subclasses.
        Parameters:
        elem - the browser element to wrap
      • ValueBoxBase

        protected ValueBoxBase​(com.google.gwt.user.client.ui.ValueBoxBase<T> oldBox)
    • Method Detail

      • oldToNew

        public static <T> ValueBoxBase<T> oldToNew​(com.google.gwt.user.client.ui.ValueBoxBase<T> oldBox)
      • addChangeHandler

        public com.google.gwt.event.shared.HandlerRegistration addChangeHandler​(com.google.gwt.event.dom.client.ChangeHandler handler)
        Specified by:
        addChangeHandler in interface com.google.gwt.event.dom.client.HasChangeHandlers
      • addValueChangeHandler

        public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler​(com.google.gwt.event.logical.shared.ValueChangeHandler<T> handler)
        Specified by:
        addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<T>
      • asEditor

        public ValueBoxEditor<T> asEditor()
        Returns an Editor that is backed by the ValueBoxBase. The default implementation returns ValueBoxEditor.of(ValueBoxBase). Subclasses may override this method to provide custom error-handling when using the Editor framework.
        Specified by:
        asEditor in interface org.gwtproject.editor.client.IsEditor<T>
      • cancelKey

        public void cancelKey()
        If a keyboard event is currently being handled on this text box, calling this method will suppress it. This allows listeners to easily filter keyboard input.
      • getCursorPos

        public int getCursorPos()
        Gets the current position of the cursor (this also serves as the beginning of the text selection).
        Returns:
        the cursor's position
      • getDirection

        public com.google.gwt.i18n.client.HasDirection.Direction getDirection()
        Specified by:
        getDirection in interface com.google.gwt.i18n.client.HasDirection
      • getDirectionEstimator

        public com.google.gwt.i18n.shared.DirectionEstimator getDirectionEstimator()
        Gets the direction estimation model of the auto-dir handler.
        Specified by:
        getDirectionEstimator in interface com.google.gwt.i18n.shared.HasDirectionEstimator
      • getName

        public String getName()
        Specified by:
        getName in interface com.google.gwt.user.client.ui.HasName
      • getSelectedText

        public String getSelectedText()
        Gets the text currently selected within this text box.
        Returns:
        the selected text, or an empty string if none is selected
      • getSelectionLength

        public int getSelectionLength()
        Gets the length of the current text selection.
        Returns:
        the text selection length
      • getText

        public String getText()
        Specified by:
        getText in interface com.google.gwt.i18n.client.AutoDirectionHandler.Target
        Specified by:
        getText in interface com.google.gwt.user.client.ui.HasText
      • getValue

        public T getValue()
        Return the parsed value, or null if the field is empty or parsing fails.
        Specified by:
        getValue in interface com.google.gwt.user.client.ui.HasValue<T>
        Specified by:
        getValue in interface com.google.gwt.user.client.TakesValue<T>
        Specified by:
        getValue in interface org.gwtproject.editor.client.TakesValue<T>
      • getValueOrThrow

        public T getValueOrThrow()
                          throws ParseException
        Return the parsed value, or null if the field is empty.
        Throws:
        ParseException - if the value cannot be parsed
      • isReadOnly

        public boolean isReadOnly()
        Determines whether or not the widget is read-only.
        Returns:
        true if the widget is currently read-only, false if the widget is currently editable
      • onBrowserEvent

        public void onBrowserEvent​(com.google.gwt.user.client.Event event)
        Specified by:
        onBrowserEvent in interface com.google.gwt.user.client.EventListener
        Overrides:
        onBrowserEvent in class com.google.gwt.user.client.ui.Widget
      • selectAll

        public void selectAll()
        Selects all of the text in the box.

        This will only work when the widget is attached to the document and not hidden.

      • setCursorPos

        public void setCursorPos​(int pos)
        Sets the cursor position.

        This will only work when the widget is attached to the document and not hidden.

        Parameters:
        pos - the new cursor position
      • setDirection

        public void setDirection​(com.google.gwt.i18n.client.HasDirection.Direction direction)
        Specified by:
        setDirection in interface com.google.gwt.i18n.client.HasDirection
      • setDirectionEstimator

        public void setDirectionEstimator​(boolean enabled)
        Toggles on / off direction estimation.
        Specified by:
        setDirectionEstimator in interface com.google.gwt.i18n.shared.HasDirectionEstimator
      • setDirectionEstimator

        public void setDirectionEstimator​(com.google.gwt.i18n.shared.DirectionEstimator directionEstimator)
        Sets the direction estimation model of the auto-dir handler.
        Specified by:
        setDirectionEstimator in interface com.google.gwt.i18n.shared.HasDirectionEstimator
      • setKey

        @Deprecated
        public void setKey​(char key)
        Deprecated.
        this method only works in IE and should not have been added to the API
        If a keyboard event is currently being handled by the text box, this method replaces the unicode character or key code associated with it. This allows listeners to easily filter keyboard input.
        Parameters:
        key - the new key value
      • setName

        public void setName​(String name)
        Specified by:
        setName in interface com.google.gwt.user.client.ui.HasName
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
        Turns read-only mode on or off.
        Parameters:
        readOnly - if true, the widget becomes read-only; if false the widget becomes editable
      • setSelectionRange

        public void setSelectionRange​(int pos,
                                      int length)
        Sets the range of text to be selected.

        This will only work when the widget is attached to the document and not hidden.

        Parameters:
        pos - the position of the first character to be selected
        length - the number of characters to be selected
      • setText

        public void setText​(String text)
        Sets this object's text. Note that some browsers will manipulate the text before adding it to the widget. For example, most browsers will strip all \r from the text, except IE which will add a \r before each \n. Use getText() to get the text directly from the widget.
        Specified by:
        setText in interface com.google.gwt.i18n.client.AutoDirectionHandler.Target
        Specified by:
        setText in interface com.google.gwt.user.client.ui.HasText
        Parameters:
        text - the object's new text
      • setValue

        public void setValue​(T value)
        Specified by:
        setValue in interface com.google.gwt.user.client.ui.HasValue<T>
        Specified by:
        setValue in interface com.google.gwt.user.client.TakesValue<T>
        Specified by:
        setValue in interface org.gwtproject.editor.client.TakesValue<T>
      • setValue

        public void setValue​(T value,
                             boolean fireEvents)
        Specified by:
        setValue in interface com.google.gwt.user.client.ui.HasValue<T>
      • getImpl

        protected com.google.gwt.user.client.ui.impl.TextBoxImpl getImpl()
      • onLoad

        protected void onLoad()
        Overrides:
        onLoad in class com.google.gwt.user.client.ui.Widget