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<java.util.Date>
,com.google.gwt.event.shared.HasHandlers
,com.google.gwt.user.client.EventListener
,com.google.gwt.user.client.TakesValue<java.util.Date>
,com.google.gwt.user.client.ui.HasValue<java.util.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<java.util.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 Classes Modifier and Type Class Description protected class
CmsDateBox.CloseEventPreviewHandler
Drag and drop event preview handler.protected class
CmsDateBox.CmsDateBoxHandler
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
Fields Modifier and Type Field Description static java.util.Date
INVALID_DATE
Dummy value used for invalid dates.protected CmsRadioButton
m_am
The am radio button.protected CmsRadioButtonGroup
m_ampmGroup
The radio button group for am/pm selection.protected I_CmsAutoHider
m_autoHideParent
The auto hide parent.protected CmsTextBox
m_box
The input field to show the result of picking a date.protected com.google.gwt.user.client.ui.FlowPanel
m_dateTimePanel
The panel for the date time picker.protected com.google.gwt.user.datepicker.client.DatePicker
m_picker
The gwt date picker.protected CmsRadioButton
m_pm
The pm radio button.protected com.google.gwt.event.shared.HandlerRegistration
m_previewHandlerRegistration
Event preview handler registration.protected CmsTextBox
m_time
The text box to input the time.protected com.google.gwt.user.client.ui.FlowPanel
m_timeField
The panel for the time selection.static com.google.gwt.i18n.client.DateTimeFormat
TIME_FORMAT_24H
Format used to parse the configured time in fixed-time mode.static java.lang.String
WIDGET_TYPE
The widget type identifier for this widget.
-
Constructor Summary
Constructors Constructor Description CmsDateBox()
Create a new date box widget with the date time picker.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.gwt.event.shared.HandlerRegistration
addCmsDateBoxEventHandler(I_CmsDateBoxEventHandler handler)
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<java.util.Date> handler)
boolean
allowInvalidValue()
Returns true if invalid values should be allowed.protected void
executeTimeAction()
Updates the updates the close behavior and sets the value of the date box to the value from the picker.protected void
fireChange(java.util.Date newValue, boolean isTyping)
Fires the value change event if needed.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()
Returns the value of the date box as String in form of a long.CmsTextBox
getTextField()
Returns the text box of this widget.java.util.Date
getValue()
java.lang.String
getValueAsFormatedString()
Returns the date value as formated String or an empty String if the date value is null.boolean
hasErrors()
Returnstrue
if the box and the time input fields don't have any errors.protected void
hidePopup()
Hides the date time popup.static void
initClass()
Initializes this class.boolean
isEnabled()
Returnstrue
if this widget is enabled.boolean
isValideDateBox()
Checks if the String in the date box input field is a valid date format.protected void
onAmPmClick()
If the am or pm radio button is clicked update the date box from the date time picker.protected void
onDateBoxBlur()
The date box on blur action.protected void
onDateBoxClick()
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
onFocusTimeBox()
Adds the preview handler.protected void
onPickerValueChanged()
If the value of the picker changes, the value of the date time picker should be updated.protected void
onTimeBlur()
If the time field loses the focus the entered time should be checked.void
onTimeClick()
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(java.lang.String errorMessage)
Sets the error message for this widget.void
setFixedTime(java.lang.String time)
Sets the time to be used when the widget is in date-only mode.void
setFormValueAsString(java.lang.String value)
Expects the value as String in form of a long.void
setInitialDate(java.util.Date initialDate)
Sets the initial date shown, when the date picker is opened and no date was set before.void
setName(java.lang.String name)
Sets the name of the input field.void
setValue(java.util.Date value)
void
setValue(java.util.Date value, boolean fireEvents)
protected void
updateCloseBehavior()
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
-
-
-
-
Field Detail
-
INVALID_DATE
public static final java.util.Date INVALID_DATE
Dummy value used for invalid dates.
-
TIME_FORMAT_24H
public static final com.google.gwt.i18n.client.DateTimeFormat TIME_FORMAT_24H
Format used to parse the configured time in fixed-time mode.
-
WIDGET_TYPE
public static final java.lang.String WIDGET_TYPE
The widget type identifier for this widget.- See Also:
- Constant Field Values
-
m_am
@UiField protected CmsRadioButton m_am
The am radio button.
-
m_ampmGroup
protected CmsRadioButtonGroup m_ampmGroup
The radio button group for am/pm selection.
-
m_autoHideParent
protected I_CmsAutoHider m_autoHideParent
The auto hide parent.
-
m_box
@UiField protected CmsTextBox m_box
The input field to show the result of picking a date.
-
m_dateTimePanel
@UiField protected com.google.gwt.user.client.ui.FlowPanel m_dateTimePanel
The panel for the date time picker.
-
m_picker
@UiField protected com.google.gwt.user.datepicker.client.DatePicker m_picker
The gwt date picker.
-
m_pm
@UiField protected CmsRadioButton m_pm
The pm radio button.
-
m_previewHandlerRegistration
protected com.google.gwt.event.shared.HandlerRegistration m_previewHandlerRegistration
Event preview handler registration.
-
m_time
@UiField protected CmsTextBox m_time
The text box to input the time.
-
m_timeField
@UiField protected com.google.gwt.user.client.ui.FlowPanel m_timeField
The panel for the time selection.
-
-
Constructor Detail
-
CmsDateBox
public CmsDateBox()
Create a new date box widget with the date time picker.
-
-
Method Detail
-
initClass
public static void 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:
I_CmsHasDateBoxEventHandlers.addCmsDateBoxEventHandler(org.opencms.gwt.client.ui.input.datebox.I_CmsDateBoxEventHandler)
-
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)
-
addValueChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<java.util.Date> handler)
- Specified by:
addValueChangeHandler
in interfacecom.google.gwt.event.logical.shared.HasValueChangeHandlers<java.util.Date>
- See Also:
HasValueChangeHandlers.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
-
allowInvalidValue
public boolean 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
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()
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:
I_CmsFormWidget.getFormValueAsString()
-
getTextField
public CmsTextBox getTextField()
Returns the text box of this widget.- Returns:
- the CmsText Box
-
getValue
public java.util.Date getValue()
- Specified by:
getValue
in interfacecom.google.gwt.user.client.ui.HasValue<java.util.Date>
- Specified by:
getValue
in interfacecom.google.gwt.user.client.TakesValue<java.util.Date>
- See Also:
HasValue.getValue()
-
getValueAsFormatedString
public java.lang.String 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
public boolean 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
public boolean 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:
I_CmsFormWidget.isEnabled()
-
isValideDateBox
public boolean 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
public void onTimeClick()
Updates the date box when the user has clicked on the time field.
-
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()
-
setAllowInvalidValue
public void setAllowInvalidValue(boolean allowInvalidValue)
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
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)
-
setDateOnly
public void setDateOnly(boolean dateOnly)
Sets the value if the date only should be shown.- Parameters:
dateOnly
- if the date only should be shown
-
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)
-
setFixedTime
public void setFixedTime(java.lang.String time)
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
public void setFormValueAsString(java.lang.String value)
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:
I_CmsFormWidget.setFormValueAsString(java.lang.String)
-
setInitialDate
public void setInitialDate(java.util.Date initialDate)
Sets the initial date shown, when the date picker is opened and no date was set before.- Parameters:
initialDate
- the initial date
-
setName
public void setName(java.lang.String name)
Sets the name of the input field.- Parameters:
name
- of the input field
-
setValue
public void setValue(java.util.Date value)
- Specified by:
setValue
in interfacecom.google.gwt.user.client.ui.HasValue<java.util.Date>
- Specified by:
setValue
in interfacecom.google.gwt.user.client.TakesValue<java.util.Date>
- See Also:
HasValue.setValue(java.lang.Object)
-
setValue
public void setValue(java.util.Date value, boolean fireEvents)
- Specified by:
setValue
in interfacecom.google.gwt.user.client.ui.HasValue<java.util.Date>
- See Also:
HasValue.setValue(java.lang.Object, boolean)
-
executeTimeAction
protected void executeTimeAction()
Updates the updates the close behavior and sets the value of the date box to the value from the picker.
-
fireChange
protected void fireChange(java.util.Date newValue, boolean isTyping)
Fires the value change event if needed.- Parameters:
newValue
- the new valueisTyping
- true if the user is currently typing
-
hidePopup
protected void hidePopup()
Hides the date time popup.
-
onAmPmClick
protected void onAmPmClick()
If the am or pm radio button is clicked update the date box from the date time picker.
-
onDateBoxBlur
protected void 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
protected void onDateBoxClick()
The date box on click action.If the date box is clicked the time date picker should be shown.
-
onDateBoxKeyPress
protected void onDateBoxKeyPress(com.google.gwt.event.dom.client.KeyUpEvent event)
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
protected void onFocusTimeBox()
Adds the preview handler.
-
onPickerValueChanged
protected void onPickerValueChanged()
If the value of the picker changes, the value of the date time picker should be updated.
-
onTimeBlur
protected void onTimeBlur()
If the time field loses the focus the entered time should be checked.
-
onTimeKeyPressed
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.In any other case the popup should be prevented to being closed.
- Parameters:
event
- the key pressed event
-
previewNativeEvent
protected void previewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent event)
Blurs the time box if the user clicks outside of it.- Parameters:
event
- the native preview event
-
updateCloseBehavior
protected void 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.
-
-