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<java.lang.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<java.lang.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
Fields Modifier and Type Field Description static I_CmsInputCss
CSS
The CSS bundle used for this widget.protected java.lang.String
m_ghostValue
The ghost value.protected com.google.gwt.user.client.ui.TextBox
m_textbox
The text box used internally by this widget.protected static int[]
NAVIGATION_CODES
Key codes for functional keys.static java.lang.String
WIDGET_TYPE
The widget type identifier for this widget.
-
Constructor Summary
Constructors Constructor Description CmsTextBox()
Constructs 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.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<java.lang.String> handler)
void
blur()
Makes the widget lose focus.CmsTextBox
colorWhite()
Sets the background color to white.protected void
fireValueChangedEvent()
Fires a value change event.protected void
fireValueChangedEvent(boolean inhibitValidation)
Helper method for firing a 'value changed' event.java.lang.String
getApparentValue()
Returns the "apparent value", i.e.I_CmsFormWidget.FieldType
getFieldType()
Returns the type of data this widget produces.java.lang.Object
getFormValue()
Gets the selected/entered value from the widget.java.lang.String
getFormValueAsString()
Gets the current value of the widget as a string.java.lang.String
getId()
Returns the HTML id of the internal textbox used by this widget.java.lang.String
getText()
Returns the text in the text box.com.google.gwt.user.client.ui.TextBox
getTextBox()
Returns the Textbox of this widget.com.google.gwt.user.client.ui.FlowPanel
getTextBoxContainer()
Returns the Panel of this widget.boolean
hasError()
Returnstrue
if this textbox has an error set.protected void
hideError()
Hides the error for this textbox.static void
initClass()
Initializes this class.boolean
isEnabled()
Gets whether this widget is enabled.protected boolean
isNavigationKey(int keyCode)
Checks if the given key code represents a functional key.boolean
isPreventShowError()
Returns the preventShowError.boolean
isReadOnly()
Returns the read only flag.boolean
isTriggerChangeOnKeyPress()
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
selectAll()
Selects text in the text box.void
setAutoHideParent(I_CmsAutoHider autoHideParent)
Call this when auto hiding parents are shown.void
setChangedStyle()
Sets the changed style on the text box.void
setEnabled(boolean enabled)
Enables or disables the widget.void
setErrorMessage(java.lang.String errorMessage)
Sets the error message for this widget.void
setErrorMessageWidth(java.lang.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(java.lang.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(java.lang.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
setName(java.lang.String name)
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
showError()
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
-
-
-
-
Field Detail
-
CSS
public static final I_CmsInputCss CSS
The CSS bundle used for this widget.
-
WIDGET_TYPE
public static final java.lang.String WIDGET_TYPE
The widget type identifier for this widget.- See Also:
- Constant Field Values
-
NAVIGATION_CODES
protected static final int[] NAVIGATION_CODES
Key codes for functional keys.
-
m_ghostValue
protected java.lang.String m_ghostValue
The ghost value.
-
m_textbox
protected com.google.gwt.user.client.ui.TextBox m_textbox
The text box used internally by this widget.
-
-
Constructor Detail
-
CmsTextBox
public CmsTextBox()
Constructs a new instance of this widget.
-
CmsTextBox
public CmsTextBox(com.google.gwt.user.client.ui.TextBox textbox)
Creates a new text box based on an underlying GWT text box instance.- Parameters:
textbox
- the GWT text box instance to wrap
-
-
Method Detail
-
initClass
public static void 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
-
addValueChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<java.lang.String> handler)
- Specified by:
addValueChangeHandler
in interfacecom.google.gwt.event.logical.shared.HasValueChangeHandlers<java.lang.String>
- See Also:
HasValueChangeHandlers.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
-
blur
public void blur()
Description copied from interface:I_CmsHasBlur
Makes the widget lose focus.- Specified by:
blur
in interfaceI_CmsHasBlur
- See Also:
I_CmsHasBlur.blur()
-
colorWhite
public CmsTextBox colorWhite()
Sets the background color to white.- Returns:
- this widget
-
getApparentValue
public java.lang.String 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:
I_CmsFormWidget.getApparentValue()
-
getFieldType
public I_CmsFormWidget.FieldType 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:
I_CmsFormWidget.getFieldType()
-
getFormValue
public java.lang.Object 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:
I_CmsFormWidget.getFormValue()
-
getFormValueAsString
public java.lang.String 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:
I_CmsFormWidget.getFormValueAsString()
-
getId
public java.lang.String 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
public java.lang.String getText()
Returns the text in the text box.- Returns:
- the text
-
getTextBox
public com.google.gwt.user.client.ui.TextBox getTextBox()
Returns the Textbox of this widget.- Returns:
- the CmsTextBox
-
getTextBoxContainer
public com.google.gwt.user.client.ui.FlowPanel getTextBoxContainer()
Returns the Panel of this widget.- Returns:
- the Panel
-
hasError
public boolean hasError()
Returnstrue
if this textbox has an error set.- Returns:
true
if this textbox has an error set
-
isEnabled
public boolean isEnabled()
Gets whether this widget is enabled.- Specified by:
isEnabled
in interfaceI_CmsFormWidget
- Returns:
true
if the widget is enabled
-
isPreventShowError
public boolean isPreventShowError()
Returns the preventShowError.- Returns:
- the preventShowError
-
isReadOnly
public boolean isReadOnly()
Returns the read only flag.- Returns:
true
if this text box is only readable
-
isTriggerChangeOnKeyPress
public boolean 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
public void onBrowserEvent(com.google.gwt.user.client.Event event)
- 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
public void reset()
Description copied from interface:I_CmsFormWidget
Resets the widget to its default state.- Specified by:
reset
in interfaceI_CmsFormWidget
- See Also:
I_CmsFormWidget.reset()
-
selectAll
public void selectAll()
Selects text in the text box.
-
setAutoHideParent
public void setAutoHideParent(I_CmsAutoHider autoHideParent)
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:
I_CmsFormWidget.setAutoHideParent(org.opencms.gwt.client.ui.I_CmsAutoHider)
-
setChangedStyle
public void setChangedStyle()
Sets the changed style on the text box.
-
setEnabled
public void setEnabled(boolean enabled)
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:
I_CmsFormWidget.setEnabled(boolean)
-
setErrorMessage
public void setErrorMessage(java.lang.String errorMessage)
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:
I_CmsFormWidget.setErrorMessage(java.lang.String)
-
setErrorMessageWidth
public void setErrorMessageWidth(java.lang.String width)
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
public void setFocus(boolean focused)
Sets the focus on the text box.- Parameters:
focused
- signals if the focus should be set
-
setFormValueAsString
public void setFormValueAsString(java.lang.String newValue)
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:
I_CmsFormWidget.setFormValueAsString(java.lang.String)
-
setGhostMode
public void setGhostMode(boolean ghostMode)
Enables or disables ghost mode.- Specified by:
setGhostMode
in interfaceI_CmsHasGhostValue
- Parameters:
ghostMode
- if true, enables ghost mode, else disables it
-
setGhostModeClear
public void setGhostModeClear(boolean clearOnChangeMode)
Sets if the input field should be cleared when leaving the ghost mode.- Parameters:
clearOnChangeMode
-true
to clear on leaving the ghost mode
-
setGhostStyleEnabled
public void setGhostStyleEnabled(boolean enabled)
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
public void setGhostValue(java.lang.String value, boolean ghostMode)
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:
I_CmsHasGhostValue.setGhostValue(java.lang.String, boolean)
-
setInhibitValidationForKeypresses
public void setInhibitValidationForKeypresses(boolean inhibitValidationForKeypresses)
Sets the 'inhibitValidationForKeypresses' flag.- Parameters:
inhibitValidationForKeypresses
- the new flag value
-
setName
public void setName(java.lang.String name)
Sets the name of the input box.- Parameters:
name
- of the input box
-
setPreventShowError
public void setPreventShowError(boolean preventShowError)
Sets the preventShowError.- Parameters:
preventShowError
- the preventShowError to set
-
setReadOnly
public void setReadOnly(boolean readOnly)
Enables or disables read-only mode.- Parameters:
readOnly
- if true, enables read-only mode, else disables it
-
setTriggerChangeOnKeyPress
public void setTriggerChangeOnKeyPress(boolean triggerOnKeyPress)
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
protected void fireValueChangedEvent()
Fires a value change event.
-
fireValueChangedEvent
protected void fireValueChangedEvent(boolean inhibitValidation)
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
protected void hideError()
Hides the error for this textbox.
-
isNavigationKey
protected boolean isNavigationKey(int keyCode)
Checks if the given key code represents a functional key.- Parameters:
keyCode
- the key code to check- Returns:
true
if the given key code represents a functional key
-
showError
protected void showError()
Shows the error for this textbox.
-
-