Class CmsDateBox
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.datebox.CmsDateBox
- All Implemented Interfaces:
com.google.gwt.event.dom.client.HasKeyPressHandlers
,com.google.gwt.event.logical.shared.HasAttachHandlers
,com.google.gwt.event.logical.shared.HasValueChangeHandlers<Date>
,com.google.gwt.event.shared.HasHandlers
,com.google.gwt.user.client.EventListener
,com.google.gwt.user.client.TakesValue<Date>
,com.google.gwt.user.client.ui.HasValue<Date>
,com.google.gwt.user.client.ui.HasVisibility
,com.google.gwt.user.client.ui.IsRenderable
,com.google.gwt.user.client.ui.IsWidget
,I_CmsHasInit
,I_CmsHasDateBoxEventHandlers
,I_CmsFormWidget
public class CmsDateBox
extends com.google.gwt.user.client.ui.Composite
implements com.google.gwt.user.client.ui.HasValue<Date>, I_CmsFormWidget, I_CmsHasInit, com.google.gwt.event.dom.client.HasKeyPressHandlers, I_CmsHasDateBoxEventHandlers
A text box that shows a date time picker widget when the user clicks on it.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Drag and drop event preview handler.protected class
This inner class implements the handler for the date box widget.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 Date
Dummy value used for invalid dates.protected CmsRadioButton
The am radio button.protected CmsRadioButtonGroup
The radio button group for am/pm selection.protected I_CmsAutoHider
The auto hide parent.protected CmsTextBox
The input field to show the result of picking a date.protected com.google.gwt.user.client.ui.FlowPanel
The panel for the date time picker.protected com.google.gwt.user.datepicker.client.DatePicker
The gwt date picker.protected CmsRadioButton
The pm radio button.protected com.google.gwt.event.shared.HandlerRegistration
Event preview handler registration.protected CmsTextBox
The text box to input the time.protected com.google.gwt.user.client.ui.FlowPanel
The panel for the time selection.static final com.google.gwt.i18n.client.DateTimeFormat
Format used to parse the configured time in fixed-time mode.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
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gwt.event.shared.HandlerRegistration
Adds a new event handler for date box events.com.google.gwt.event.shared.HandlerRegistration
addKeyPressHandler
(com.google.gwt.event.dom.client.KeyPressHandler handler) com.google.gwt.event.shared.HandlerRegistration
addValueChangeHandler
(com.google.gwt.event.logical.shared.ValueChangeHandler<Date> handler) boolean
Returns true if invalid values should be allowed.protected void
Updates the updates the close behavior and sets the value of the date box to the value from the picker.protected void
fireChange
(Date newValue, boolean isTyping) Fires the value change event if needed.Returns the "apparent value", i.e.Returns the type of data this widget produces.Gets the selected/entered value from the widget.Returns the value of the date box as String in form of a long.Returns the text box of this widget.getValue()
Returns the date value as formated String or an empty String if the date value is null.boolean
Returnstrue
if the box and the time input fields don't have any errors.protected void
Hides the date time popup.static void
Initializes this class.boolean
Returnstrue
if this widget is enabled.boolean
Checks if the String in the date box input field is a valid date format.protected void
If the am or pm radio button is clicked update the date box from the date time picker.protected void
The date box on blur action.protected void
The date box on click action.protected void
onDateBoxKeyPress
(com.google.gwt.event.dom.client.KeyUpEvent event) The date box on key down action.protected void
Adds the preview handler.protected void
If the value of the picker changes, the value of the date time picker should be updated.protected void
If the time field loses the focus the entered time should be checked.void
Updates the date box when the user has clicked on the time field.protected void
onTimeKeyPressed
(com.google.gwt.event.dom.client.KeyUpEvent event) If the user presses enter in the time field the value of the picker should be updated and the the popup should be closed.protected void
previewNativeEvent
(com.google.gwt.user.client.Event.NativePreviewEvent event) Blurs the time box if the user clicks outside of it.void
reset()
Resets the widget to its default state.void
setAllowInvalidValue
(boolean allowInvalidValue) Enables or disables whether invalid values are allowed.void
setAutoHideParent
(I_CmsAutoHider autoHideParent) Call this when auto hiding parents are shown.void
setDateOnly
(boolean dateOnly) Sets the value if the date only should be shown.void
setEnabled
(boolean enabled) Enables or disables the widget.void
setErrorMessage
(String errorMessage) Sets the error message for this widget.void
setFixedTime
(String time) Sets the time to be used when the widget is in date-only mode.void
setFormValueAsString
(String value) Expects the value as String in form of a long.void
setInitialDate
(Date initialDate) Sets the initial date shown, when the date picker is opened and no date was set before.void
Sets the name of the input field.void
void
protected void
Updates the auto hide partner from the parent widget.Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, 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
-
INVALID_DATE
Dummy value used for invalid dates. -
TIME_FORMAT_24H
Format used to parse the configured time in fixed-time mode. -
WIDGET_TYPE
The widget type identifier for this widget.- See Also:
-
m_am
The am radio button. -
m_ampmGroup
The radio button group for am/pm selection. -
m_autoHideParent
The auto hide parent. -
m_box
The input field to show the result of picking a date. -
m_dateTimePanel
The panel for the date time picker. -
m_picker
The gwt date picker. -
m_pm
The pm radio button. -
m_previewHandlerRegistration
Event preview handler registration. -
m_time
The text box to input the time. -
m_timeField
The panel for the time selection.
-
-
Constructor Details
-
CmsDateBox
public CmsDateBox()Create a new date box widget with the date time picker.
-
-
Method Details
-
initClass
Initializes this class. -
addCmsDateBoxEventHandler
public com.google.gwt.event.shared.HandlerRegistration addCmsDateBoxEventHandler(I_CmsDateBoxEventHandler handler) Description copied from interface:I_CmsHasDateBoxEventHandlers
Adds a new event handler for date box events.- Specified by:
addCmsDateBoxEventHandler
in interfaceI_CmsHasDateBoxEventHandlers
- Parameters:
handler
- the event handler- Returns:
- the handler registration
- See Also:
-
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)
-
allowInvalidValue
Returns true if invalid values should be allowed.If invalid values are allowed, methods returning a Date will return a special dummy date in case the date is invalid.
- Returns:
- true if invalid values should be allowed
-
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
Returns the value of the date box as String in form of a long.- Specified by:
getFormValueAsString
in interfaceI_CmsFormWidget
- Returns:
- the current value of the widget
- See Also:
-
getTextField
Returns the text box of this widget.- Returns:
- the CmsText Box
-
getValue
-
getValueAsFormatedString
Returns the date value as formated String or an empty String if the date value is null.- Returns:
- the date value as formated String
-
hasErrors
Returnstrue
if the box and the time input fields don't have any errors.- Returns:
true
if the box and the time input fields don't have any errors
-
isEnabled
Description copied from interface:I_CmsFormWidget
Returnstrue
if this widget is enabled.- Specified by:
isEnabled
in interfaceI_CmsFormWidget
- Returns:
true
if this widget is enabled- See Also:
-
isValideDateBox
Checks if the String in the date box input field is a valid date format.- Returns:
true
if the String in the date box input field is a valid date format
-
onTimeClick
Updates the date box when the user has clicked on the time field. -
reset
Description copied from interface:I_CmsFormWidget
Resets the widget to its default state.- Specified by:
reset
in interfaceI_CmsFormWidget
- See Also:
-
setAllowInvalidValue
Enables or disables whether invalid values are allowed.If invalid values are allowed, they will be returned as a special dummy date (INVALID_DATE).
- Parameters:
allowInvalidValue
- true if invalid values should be allowed
-
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:
-
setDateOnly
Sets the value if the date only should be shown.- Parameters:
dateOnly
- if the date only should be shown
-
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:
-
setFixedTime
Sets the time to be used when the widget is in date-only mode.- Parameters:
time
- the time to use when the widget is in date-only mode
-
setFormValueAsString
Expects the value as String in form of a long.- Specified by:
setFormValueAsString
in interfaceI_CmsFormWidget
- Parameters:
value
- the new value of the widget- See Also:
-
setInitialDate
Sets the initial date shown, when the date picker is opened and no date was set before.- Parameters:
initialDate
- the initial date
-
setName
Sets the name of the input field.- Parameters:
name
- of the input field
-
setValue
-
setValue
- Specified by:
setValue
in interfacecom.google.gwt.user.client.ui.HasValue<Date>
- See Also:
-
HasValue.setValue(java.lang.Object, boolean)
-
executeTimeAction
Updates the updates the close behavior and sets the value of the date box to the value from the picker. -
fireChange
Fires the value change event if needed.- Parameters:
newValue
- the new valueisTyping
- true if the user is currently typing
-
hidePopup
Hides the date time popup. -
onAmPmClick
If the am or pm radio button is clicked update the date box from the date time picker. -
onDateBoxBlur
The date box on blur action.If the date box loses the focus the date time picker should be updated from the date box value.
-
onDateBoxClick
The date box on click action.If the date box is clicked the time date picker should be shown.
-
onDateBoxKeyPress
The date box on key down action.- If enter or tab is pressed in the date box the date time picker should be updated with the value from the date box.
- If the escape key is pressed the picker should be hided.
- If the up key is pressed the value should be taken from the date box.
- If the down key is pressed the picker should be hided.
- Parameters:
event
- the key down event
-
onFocusTimeBox
Adds the preview handler. -
onPickerValueChanged
If the value of the picker changes, the value of the date time picker should be updated. -
onTimeBlur
If the time field loses the focus the entered time should be checked. -
onTimeKeyPressed
If the user presses enter in the time field the value of the picker should be updated and the the popup should be closed.In any other case the popup should be prevented to being closed.
- Parameters:
event
- the key pressed event
-
previewNativeEvent
Blurs the time box if the user clicks outside of it.- Parameters:
event
- the native preview event
-
updateCloseBehavior
Updates the auto hide partner from the parent widget.If there is any invalid user input the parent widget should not be closed automatically.
-