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 classDrag and drop event preview handler.protected classThis 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.DebugIdImplEnabledNested classes/interfaces inherited from interface org.opencms.gwt.client.ui.input.I_CmsFormWidget
I_CmsFormWidget.FieldType -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DateDummy value used for invalid dates.protected CmsRadioButtonThe am radio button.protected CmsRadioButtonGroupThe radio button group for am/pm selection.protected I_CmsAutoHiderThe auto hide parent.protected CmsTextBoxThe input field to show the result of picking a date.protected com.google.gwt.user.client.ui.FlowPanelThe panel for the date time picker.protected com.google.gwt.user.datepicker.client.DatePickerThe gwt date picker.protected CmsRadioButtonThe pm radio button.protected com.google.gwt.event.shared.HandlerRegistrationEvent preview handler registration.protected CmsTextBoxThe text box to input the time.protected com.google.gwt.user.client.ui.FlowPanelThe panel for the time selection.static final com.google.gwt.i18n.client.DateTimeFormatFormat used to parse the configured time in fixed-time mode.static final StringThe 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.HandlerRegistrationAdds a new event handler for date box events.com.google.gwt.event.shared.HandlerRegistrationaddKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler) com.google.gwt.event.shared.HandlerRegistrationaddValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Date> handler) booleanReturns true if invalid values should be allowed.protected voidUpdates the updates the close behavior and sets the value of the date box to the value from the picker.protected voidfireChange(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.booleanReturnstrueif the box and the time input fields don't have any errors.protected voidHides the date time popup.static voidInitializes this class.booleanReturnstrueif this widget is enabled.booleanChecks if the String in the date box input field is a valid date format.protected voidIf the am or pm radio button is clicked update the date box from the date time picker.protected voidThe date box on blur action.protected voidThe date box on click action.protected voidonDateBoxKeyPress(com.google.gwt.event.dom.client.KeyUpEvent event) The date box on key down action.protected voidAdds the preview handler.protected voidIf the value of the picker changes, the value of the date time picker should be updated.protected voidIf the time field loses the focus the entered time should be checked.voidUpdates the date box when the user has clicked on the time field.protected voidonTimeKeyPressed(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 voidpreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent event) Blurs the time box if the user clicks outside of it.voidreset()Resets the widget to its default state.voidsetAllowInvalidValue(boolean allowInvalidValue) Enables or disables whether invalid values are allowed.voidsetAutoHideParent(I_CmsAutoHider autoHideParent) Call this when auto hiding parents are shown.voidsetDateOnly(boolean dateOnly) Sets the value if the date only should be shown.voidsetEnabled(boolean enabled) Enables or disables the widget.voidsetErrorMessage(String errorMessage) Sets the error message for this widget.voidsetFixedTime(String time) Sets the time to be used when the widget is in date-only mode.voidsetFormValueAsString(String value) Expects the value as String in form of a long.voidsetInitialDate(Date initialDate) Sets the initial date shown, when the date picker is opened and no date was set before.voidSets the name of the input field.voidvoidprotected voidUpdates 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, setWidgetMethods 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, unsinkEventsMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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_CmsHasDateBoxEventHandlersAdds a new event handler for date box events.- Specified by:
addCmsDateBoxEventHandlerin 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:
addKeyPressHandlerin interfacecom.google.gwt.event.dom.client.HasKeyPressHandlers- See Also:
-
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_CmsFormWidgetReturns the "apparent value", i.e. either the real value if available, or else the ghost value if available, or null otherwise.- Specified by:
getApparentValuein interfaceI_CmsFormWidget- Returns:
- the apparent value
- See Also:
-
getFieldType
Description copied from interface:I_CmsFormWidgetReturns the type of data this widget produces.- Specified by:
getFieldTypein interfaceI_CmsFormWidget- Returns:
- the data type
- See Also:
-
getFormValue
Description copied from interface:I_CmsFormWidgetGets the selected/entered value from the widget.- Specified by:
getFormValuein interfaceI_CmsFormWidget- Returns:
- the value
- See Also:
-
getFormValueAsString
Returns the value of the date box as String in form of a long.- Specified by:
getFormValueAsStringin 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
Returnstrueif the box and the time input fields don't have any errors.- Returns:
trueif the box and the time input fields don't have any errors
-
isEnabled
Description copied from interface:I_CmsFormWidgetReturnstrueif this widget is enabled.- Specified by:
isEnabledin interfaceI_CmsFormWidget- Returns:
trueif this widget is enabled- See Also:
-
isValideDateBox
Checks if the String in the date box input field is a valid date format.- Returns:
trueif 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_CmsFormWidgetResets the widget to its default state.- Specified by:
resetin 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_CmsFormWidgetCall this when auto hiding parents are shown.- Specified by:
setAutoHideParentin 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_CmsFormWidgetEnables or disables the widget.- Specified by:
setEnabledin interfaceI_CmsFormWidget- Parameters:
enabled- if true, the widget will be enabled, else disabled- See Also:
-
setErrorMessage
Description copied from interface:I_CmsFormWidgetSets the error message for this widget.If the error message is null, no error message will be displayed.
- Specified by:
setErrorMessagein 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:
setFormValueAsStringin 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:
setValuein interfacecom.google.gwt.user.client.ui.HasValue<Date>- See Also:
-
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.
-