Package org.opencms.gwt.client.ui.input
Class CmsTextBox
java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Composite
org.opencms.gwt.client.ui.input.CmsTextBox
- All Implemented Interfaces:
com.google.gwt.event.dom.client.HasBlurHandlers
,com.google.gwt.event.dom.client.HasClickHandlers
,com.google.gwt.event.dom.client.HasFocusHandlers
,com.google.gwt.event.dom.client.HasKeyPressHandlers
,com.google.gwt.event.logical.shared.HasAttachHandlers
,com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>
,com.google.gwt.event.shared.HasHandlers
,com.google.gwt.user.client.EventListener
,com.google.gwt.user.client.ui.HasVisibility
,com.google.gwt.user.client.ui.IsRenderable
,com.google.gwt.user.client.ui.IsWidget
,I_CmsHasInit
,I_CmsFormWidget
,I_CmsHasBlur
,I_CmsHasGhostValue
- Direct Known Subclasses:
CmsFocusAwareTextBox
public class CmsTextBox
extends com.google.gwt.user.client.ui.Composite
implements I_CmsFormWidget, I_CmsHasInit, com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.dom.client.HasBlurHandlers, com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.HasClickHandlers, I_CmsHasBlur, I_CmsHasGhostValue
Basic text box class for forms.
- Since:
- 8.0.0
-
Nested Class Summary
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 org.opencms.gwt.client.ui.input.I_CmsFormWidget
I_CmsFormWidget.FieldType
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final I_CmsInputCss
The CSS bundle used for this widget.protected String
The ghost value.protected com.google.gwt.user.client.ui.TextBox
The text box used internally by this widget.protected static final int[]
Key codes for functional keys.static final String
The widget type identifier for this widget.Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of this widget.CmsTextBox
(com.google.gwt.user.client.ui.TextBox textbox) Creates a new text box based on an underlying GWT text box instance. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gwt.event.shared.HandlerRegistration
addBlurHandler
(com.google.gwt.event.dom.client.BlurHandler handler) com.google.gwt.event.shared.HandlerRegistration
addClickHandler
(com.google.gwt.event.dom.client.ClickHandler handler) com.google.gwt.event.shared.HandlerRegistration
addFocusHandler
(com.google.gwt.event.dom.client.FocusHandler handler) com.google.gwt.event.shared.HandlerRegistration
addKeyPressHandler
(com.google.gwt.event.dom.client.KeyPressHandler handler) com.google.gwt.event.shared.HandlerRegistration
addKeyUpHandler
(com.google.gwt.event.dom.client.KeyUpHandler handler) Adds a handler for the keyup event.com.google.gwt.event.shared.HandlerRegistration
addValueChangeHandler
(com.google.gwt.event.logical.shared.ValueChangeHandler<String> handler) void
blur()
Makes the widget lose focus.Sets the background color to white.protected void
Fires a value change event.protected void
fireValueChangedEvent
(boolean inhibitValidation) Helper method for firing a 'value changed' event.Returns the "apparent value", i.e.Returns the type of data this widget produces.Gets the selected/entered value from the widget.Gets the current value of the widget as a string.getId()
Returns the HTML id of the internal textbox used by this widget.getText()
Returns the text in the text box.com.google.gwt.user.client.ui.TextBox
Returns the Textbox of this widget.com.google.gwt.user.client.ui.FlowPanel
Returns the Panel of this widget.boolean
hasError()
Returnstrue
if this textbox has an error set.protected void
Hides the error for this textbox.static void
Initializes this class.boolean
Gets whether this widget is enabled.protected boolean
isNavigationKey
(int keyCode) Checks if the given key code represents a functional key.boolean
Returns the preventShowError.boolean
Returns the read only flag.boolean
Returns if the text box is set to trigger the value changed event on key press and not on blur only.void
onBrowserEvent
(com.google.gwt.user.client.Event event) void
reset()
Resets the widget to its default state.void
Selects text in the text box.void
setAutoHideParent
(I_CmsAutoHider autoHideParent) Call this when auto hiding parents are shown.void
Sets the changed style on the text box.void
setEnabled
(boolean enabled) Enables or disables the widget.void
setErrorMessage
(String errorMessage) Sets the error message for this widget.void
setErrorMessageWidth
(String width) Sets the width of the error message for this textbox.void
setFocus
(boolean focused) Sets the focus on the text box.void
setFormValueAsString
(String newValue) Sets the current value of the widget as a string.void
setGhostMode
(boolean ghostMode) Enables or disables ghost mode.void
setGhostModeClear
(boolean clearOnChangeMode) Sets if the input field should be cleared when leaving the ghost mode.void
setGhostStyleEnabled
(boolean enabled) Enables or disables the "ghost mode" style.void
setGhostValue
(String value, boolean ghostMode) Sets the "ghost value" of the widget and optionally sets it to "ghost mode".void
setInhibitValidationForKeypresses
(boolean inhibitValidationForKeypresses) Sets the 'inhibitValidationForKeypresses' flag.void
Sets the name of the input box.void
setPreventShowError
(boolean preventShowError) Sets the preventShowError.void
setReadOnly
(boolean readOnly) Enables or disables read-only mode.void
setTriggerChangeOnKeyPress
(boolean triggerOnKeyPress) Sets if the value changed event should be triggered on key press and not on blur only.protected void
Shows the error for this textbox.Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onDetach, render, render, resolvePotentialElement, setWidget
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, isOrWasAttached, onLoad, 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, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Field Details
-
CSS
The CSS bundle used for this widget. -
WIDGET_TYPE
The widget type identifier for this widget.- See Also:
-
NAVIGATION_CODES
Key codes for functional keys. -
m_ghostValue
The ghost value. -
m_textbox
The text box used internally by this widget.
-
-
Constructor Details
-
CmsTextBox
public CmsTextBox()Constructs a new instance of this widget. -
CmsTextBox
Creates a new text box based on an underlying GWT text box instance.- Parameters:
textbox
- the GWT text box instance to wrap
-
-
Method Details
-
initClass
Initializes this class. -
addBlurHandler
public com.google.gwt.event.shared.HandlerRegistration addBlurHandler(com.google.gwt.event.dom.client.BlurHandler handler) - Specified by:
addBlurHandler
in interfacecom.google.gwt.event.dom.client.HasBlurHandlers
- See Also:
-
HasBlurHandlers.addBlurHandler(com.google.gwt.event.dom.client.BlurHandler)
-
addClickHandler
public com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler) - Specified by:
addClickHandler
in interfacecom.google.gwt.event.dom.client.HasClickHandlers
- See Also:
-
HasClickHandlers.addClickHandler(com.google.gwt.event.dom.client.ClickHandler)
-
addFocusHandler
public com.google.gwt.event.shared.HandlerRegistration addFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler) - Specified by:
addFocusHandler
in interfacecom.google.gwt.event.dom.client.HasFocusHandlers
- See Also:
-
HasFocusHandlers.addFocusHandler(com.google.gwt.event.dom.client.FocusHandler)
-
addKeyPressHandler
public com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler) - Specified by:
addKeyPressHandler
in interfacecom.google.gwt.event.dom.client.HasKeyPressHandlers
- See Also:
-
HasKeyPressHandlers.addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler)
-
addKeyUpHandler
public com.google.gwt.event.shared.HandlerRegistration addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler) Adds a handler for the keyup event.- Parameters:
handler
- the handler- Returns:
- the handler registration
-
blur
Description copied from interface:I_CmsHasBlur
Makes the widget lose focus.- Specified by:
blur
in interfaceI_CmsHasBlur
- See Also:
-
colorWhite
Sets the background color to white.- Returns:
- this widget
-
getApparentValue
Description copied from interface:I_CmsFormWidget
Returns the "apparent value", i.e. either the real value if available, or else the ghost value if available, or null otherwise.- Specified by:
getApparentValue
in interfaceI_CmsFormWidget
- Returns:
- the apparent value
- See Also:
-
getFieldType
Description copied from interface:I_CmsFormWidget
Returns the type of data this widget produces.- Specified by:
getFieldType
in interfaceI_CmsFormWidget
- Returns:
- the data type
- See Also:
-
getFormValue
Description copied from interface:I_CmsFormWidget
Gets the selected/entered value from the widget.- Specified by:
getFormValue
in interfaceI_CmsFormWidget
- Returns:
- the value
- See Also:
-
getFormValueAsString
Description copied from interface:I_CmsFormWidget
Gets the current value of the widget as a string.- Specified by:
getFormValueAsString
in interfaceI_CmsFormWidget
- Returns:
- the current value of the widget
- See Also:
-
getId
Returns the HTML id of the internal textbox used by this widget.- Returns:
- the HTML id of the internal textbox used by this widget
-
getText
Returns the text in the text box.- Returns:
- the text
-
getTextBox
Returns the Textbox of this widget.- Returns:
- the CmsTextBox
-
getTextBoxContainer
Returns the Panel of this widget.- Returns:
- the Panel
-
hasError
Returnstrue
if this textbox has an error set.- Returns:
true
if this textbox has an error set
-
isEnabled
Gets whether this widget is enabled.- Specified by:
isEnabled
in interfaceI_CmsFormWidget
- Returns:
true
if the widget is enabled
-
isPreventShowError
Returns the preventShowError.- Returns:
- the preventShowError
-
isReadOnly
Returns the read only flag.- Returns:
true
if this text box is only readable
-
isTriggerChangeOnKeyPress
Returns if the text box is set to trigger the value changed event on key press and not on blur only.- Returns:
true
if the text box is set to trigger the value changed event on key press
-
onBrowserEvent
- Specified by:
onBrowserEvent
in interfacecom.google.gwt.user.client.EventListener
- Overrides:
onBrowserEvent
in classcom.google.gwt.user.client.ui.Composite
- See Also:
-
Composite.onBrowserEvent(com.google.gwt.user.client.Event)
-
reset
Description copied from interface:I_CmsFormWidget
Resets the widget to its default state.- Specified by:
reset
in interfaceI_CmsFormWidget
- See Also:
-
selectAll
Selects text in the text box. -
setAutoHideParent
Description copied from interface:I_CmsFormWidget
Call this when auto hiding parents are shown.- Specified by:
setAutoHideParent
in interfaceI_CmsFormWidget
- Parameters:
autoHideParent
- the auto hide parent- See Also:
-
setChangedStyle
Sets the changed style on the text box. -
setEnabled
Description copied from interface:I_CmsFormWidget
Enables or disables the widget.- Specified by:
setEnabled
in interfaceI_CmsFormWidget
- Parameters:
enabled
- if true, the widget will be enabled, else disabled- See Also:
-
setErrorMessage
Description copied from interface:I_CmsFormWidget
Sets the error message for this widget.If the error message is null, no error message will be displayed.
- Specified by:
setErrorMessage
in interfaceI_CmsFormWidget
- Parameters:
errorMessage
- an error message or null- See Also:
-
setErrorMessageWidth
Sets the width of the error message for this textbox.- Parameters:
width
- the object's new width, in CSS units (e.g. "10px", "1em")
-
setFocus
Sets the focus on the text box.- Parameters:
focused
- signals if the focus should be set
-
setFormValueAsString
Description copied from interface:I_CmsFormWidget
Sets the current value of the widget as a string.- Specified by:
setFormValueAsString
in interfaceI_CmsFormWidget
- Parameters:
newValue
- the new value of the widget- See Also:
-
setGhostMode
Enables or disables ghost mode.- Specified by:
setGhostMode
in interfaceI_CmsHasGhostValue
- Parameters:
ghostMode
- if true, enables ghost mode, else disables it
-
setGhostModeClear
Sets if the input field should be cleared when leaving the ghost mode.- Parameters:
clearOnChangeMode
-true
to clear on leaving the ghost mode
-
setGhostStyleEnabled
Enables or disables the "ghost mode" style.This *only* changes the style, not the actual mode.
- Parameters:
enabled
-true
if the ghost mode style should be enabled, false if it should be disabled
-
setGhostValue
Description copied from interface:I_CmsHasGhostValue
Sets the "ghost value" of the widget and optionally sets it to "ghost mode"."Ghost mode" can be used to show the user the value (called "ghost value") which will be used if he either doesn't choose an option in the widget, or explicitly chooses an "empty" or "default" option.
- Specified by:
setGhostValue
in interfaceI_CmsHasGhostValue
- Parameters:
value
- the ghost valueghostMode
- if true, sets the widget to ghost mode- See Also:
-
setInhibitValidationForKeypresses
Sets the 'inhibitValidationForKeypresses' flag.- Parameters:
inhibitValidationForKeypresses
- the new flag value
-
setName
Sets the name of the input box.- Parameters:
name
- of the input box
-
setPreventShowError
Sets the preventShowError.- Parameters:
preventShowError
- the preventShowError to set
-
setReadOnly
Enables or disables read-only mode.- Parameters:
readOnly
- if true, enables read-only mode, else disables it
-
setTriggerChangeOnKeyPress
Sets if the value changed event should be triggered on key press and not on blur only.- Parameters:
triggerOnKeyPress
-true
if the value changed event should be triggered on key press
-
fireValueChangedEvent
Fires a value change event. -
fireValueChangedEvent
Helper method for firing a 'value changed' event.- Parameters:
inhibitValidation
- if true, some additional information will be added to the event to ask event handlers to not perform any validation directly
-
hideError
Hides the error for this textbox. -
showError
Shows the error for this textbox.
-