Class ValueBoxBase<T>
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.FocusWidget
-
- de.knightsoftnet.validators.client.editor.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 classValueBoxBase.TextAlignmentAlignment values forsetAlignment(de.knightsoftnet.validators.client.editor.ValueBoxBase.TextAlignment).
-
Constructor Summary
Constructors Modifier Constructor Description protectedValueBoxBase(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.protectedValueBoxBase(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.HandlerRegistrationaddChangeHandler(com.google.gwt.event.dom.client.ChangeHandler handler)com.google.gwt.event.shared.HandlerRegistrationaddValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<T> handler)ValueBoxEditor<T>asEditor()Returns an Editor that is backed by the ValueBoxBase.voidcancelKey()If a keyboard event is currently being handled on this text box, calling this method will suppress it.intgetCursorPos()Gets the current position of the cursor (this also serves as the beginning of the text selection).com.google.gwt.i18n.client.HasDirection.DirectiongetDirection()com.google.gwt.i18n.shared.DirectionEstimatorgetDirectionEstimator()Gets the direction estimation model of the auto-dir handler.protected com.google.gwt.user.client.ui.impl.TextBoxImplgetImpl()StringgetName()StringgetSelectedText()Gets the text currently selected within this text box.intgetSelectionLength()Gets the length of the current text selection.StringgetText()TgetValue()Return the parsed value, or null if the field is empty or parsing fails.TgetValueOrThrow()Return the parsed value, or null if the field is empty.booleanisReadOnly()Determines whether or not the widget is read-only.static <T> ValueBoxBase<T>oldToNew(com.google.gwt.user.client.ui.ValueBoxBase<T> oldBox)voidonBrowserEvent(com.google.gwt.user.client.Event event)protected voidonLoad()voidremoveChangeListener(com.google.gwt.user.client.ui.ChangeListener listener)Deprecated.Use theHandlerRegistration.removeHandler()method on the object returned byaddChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)insteadvoidselectAll()Selects all of the text in the box.voidsetAlignment(ValueBoxBase.TextAlignment align)voidsetCursorPos(int pos)Sets the cursor position.voidsetDirection(com.google.gwt.i18n.client.HasDirection.Direction direction)voidsetDirectionEstimator(boolean enabled)Toggles on / off direction estimation.voidsetDirectionEstimator(com.google.gwt.i18n.shared.DirectionEstimator directionEstimator)Sets the direction estimation model of the auto-dir handler.voidsetKey(char key)Deprecated.this method only works in IE and should not have been added to the APIvoidsetName(String name)voidsetReadOnly(boolean readOnly)Turns read-only mode on or off.voidsetSelectionRange(int pos, int length)Sets the range of text to be selected.voidsetText(String text)Sets this object's text.voidsetValue(T value)voidsetValue(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
-
-
-
-
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:
addChangeHandlerin interfacecom.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:
addValueChangeHandlerin interfacecom.google.gwt.event.logical.shared.HasValueChangeHandlers<T>
-
asEditor
public ValueBoxEditor<T> asEditor()
Returns an Editor that is backed by the ValueBoxBase. The default implementation returnsValueBoxEditor.of(ValueBoxBase). Subclasses may override this method to provide custom error-handling when using the Editor framework.- Specified by:
asEditorin interfaceorg.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:
getDirectionin interfacecom.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:
getDirectionEstimatorin interfacecom.google.gwt.i18n.shared.HasDirectionEstimator
-
getName
public String getName()
- Specified by:
getNamein interfacecom.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:
getTextin interfacecom.google.gwt.i18n.client.AutoDirectionHandler.Target- Specified by:
getTextin interfacecom.google.gwt.user.client.ui.HasText
-
getValue
public T getValue()
Return the parsed value, or null if the field is empty or parsing fails.
-
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:
trueif the widget is currently read-only,falseif the widget is currently editable
-
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event event)
- Specified by:
onBrowserEventin interfacecom.google.gwt.user.client.EventListener- Overrides:
onBrowserEventin classcom.google.gwt.user.client.ui.Widget
-
removeChangeListener
@Deprecated public void removeChangeListener(com.google.gwt.user.client.ui.ChangeListener listener)
Deprecated.Use theHandlerRegistration.removeHandler()method on the object returned byaddChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)insteadremove change listener.
-
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.
-
setAlignment
public void setAlignment(ValueBoxBase.TextAlignment align)
-
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:
setDirectionin interfacecom.google.gwt.i18n.client.HasDirection
-
setDirectionEstimator
public void setDirectionEstimator(boolean enabled)
Toggles on / off direction estimation.- Specified by:
setDirectionEstimatorin interfacecom.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:
setDirectionEstimatorin interfacecom.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 APIIf 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:
setNamein interfacecom.google.gwt.user.client.ui.HasName
-
setReadOnly
public void setReadOnly(boolean readOnly)
Turns read-only mode on or off.- Parameters:
readOnly- iftrue, the widget becomes read-only; iffalsethe 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 selectedlength- 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\rfrom the text, except IE which will add a\rbefore each\n. UsegetText()to get the text directly from the widget.- Specified by:
setTextin interfacecom.google.gwt.i18n.client.AutoDirectionHandler.Target- Specified by:
setTextin interfacecom.google.gwt.user.client.ui.HasText- Parameters:
text- the object's new text
-
setValue
public void setValue(T value)
-
setValue
public void setValue(T value, boolean fireEvents)
- Specified by:
setValuein interfacecom.google.gwt.user.client.ui.HasValue<T>
-
getImpl
protected com.google.gwt.user.client.ui.impl.TextBoxImpl getImpl()
-
onLoad
protected void onLoad()
- Overrides:
onLoadin classcom.google.gwt.user.client.ui.Widget
-
-