Class AbstractDateTimeEditor<C extends org.zkoss.zul.impl.FormatInputElement>
- java.lang.Object
-
- com.hybris.cockpitng.editors.impl.AbstractCockpitEditorRenderer<T>
-
- com.hybris.cockpitng.editors.impl.AbstractTextBasedEditorRenderer<java.util.Date>
-
- com.hybris.cockpitng.editor.defaultdate.AbstractDateTimeEditor<C>
-
- All Implemented Interfaces:
CockpitEditorRenderer<java.util.Date>
- Direct Known Subclasses:
DefaultDateEditor,DefaultTimeEditor
public abstract class AbstractDateTimeEditor<C extends org.zkoss.zul.impl.FormatInputElement> extends AbstractTextBasedEditorRenderer<java.util.Date>
Abstract Editor forDatevalues.Abstraction is made to extract all methods independent from whether a component is used as input for date only (
Datebox), time only (Timebox) or both (Datebox).
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDATE_FORMAT_NONEstatic java.lang.StringSELECTED_TIME_ZONE-
Fields inherited from class com.hybris.cockpitng.editors.impl.AbstractTextBasedEditorRenderer
SETTING_INPUT_INSTANT
-
Fields inherited from class com.hybris.cockpitng.editors.impl.AbstractCockpitEditorRenderer
HEADER_LABEL_TOOLTIP, ON_ADD_EVENT, ON_DELETE_EVENT, YW_EDITOR_AREA_LABEL_CONTAINER
-
Fields inherited from interface com.hybris.cockpitng.editors.CockpitEditorRenderer
INITIAL_EDIT_STRING
-
-
Constructor Summary
Constructors Constructor Description AbstractDateTimeEditor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract CcreateEditorView()Creates a view component.protected abstract java.lang.StringgetDateFormat(int dateStyle)Determines a format string for specified format style (see:DateFormat)protected java.lang.StringgetDateFormat(C datebox, EditorContext<java.util.Date> context)Gets format string from configuration.protected java.lang.StringgetDateFormat(java.lang.String dateFormatInput)Determines the date format for the component.protected java.lang.StringgetDefaultDateFormat(C datebox)Returns default date format.protected java.util.Optional<java.lang.Integer>getDefaultDateFormat(java.lang.String formatInput)protected abstract java.lang.StringgetFormatConfigurationParameter()Defines a name of configuration parameter that stands for a date format.protected java.util.TimeZonegetInitialTimeZoneFromConfig(EditorContext<java.util.Date> context)protected java.util.Optional<java.lang.String>getPatternDateFormat(java.lang.String formatInput)protected java.util.DategetRawValue(org.zkoss.zul.impl.InputElement viewComponent)Extracts value of the given editor component.protected intgetRequiredStyle(int style)Checks if provided style is an actual style or points toDATE_FORMAT_NONE.protected java.util.TimeZonegetSessionTimeZoneAttribute()protected java.util.TimeZonegetZKDefaultTimeZone()protected voidhandleReadOnly(EditorContext<java.util.Date> context, org.zkoss.zul.impl.InputElement editorView)In case of dateTimeEditor we have to override standard implementation of handleReadOnly.voidinitTimeZone(C box, EditorContext<java.util.Date> context)protected voidinitViewComponent(org.zkoss.zul.impl.InputElement editorView, EditorContext<java.util.Date> context, EditorListener<java.util.Date> listener)Adds event listeners to this editor component, parses the parameter for initial value etc.voidrender(org.zkoss.zk.ui.Component parent, EditorContext<java.util.Date> context, EditorListener<java.util.Date> listener)Creates a new editor component and attaches it to the specifiedComponentcomponent.protected voidsetRawValue(org.zkoss.zul.impl.InputElement viewComponent, java.util.Date rawValue)Sets the value to the given editor component.-
Methods inherited from class com.hybris.cockpitng.editors.impl.AbstractTextBasedEditorRenderer
clearInvalidInputAndNotify, coerceFromString, handleChangeEvent, handleChangeEvent, handleChangingEvent, hasInvalidInput, isPrimitive, onCancelEvent, onChangeEvent, onChangingEvent, onFocusEvent, onOkEvent
-
Methods inherited from class com.hybris.cockpitng.editors.impl.AbstractCockpitEditorRenderer
extractEmbeddedEditor, extractEmbeddedType, findAncestorEditor, findEmbeddedEditors, getInitialEditString, getL10nDecorator
-
-
-
-
Field Detail
-
SELECTED_TIME_ZONE
public static final java.lang.String SELECTED_TIME_ZONE
- See Also:
- Constant Field Values
-
DATE_FORMAT_NONE
protected static final int DATE_FORMAT_NONE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDateFormat
protected abstract java.lang.String getDateFormat(int dateStyle)
Determines a format string for specified format style (see:DateFormat)- Parameters:
dateStyle- format style- Returns:
- format string
-
getRequiredStyle
protected int getRequiredStyle(int style)
Checks if provided style is an actual style or points toDATE_FORMAT_NONE.- Parameters:
style- date style to be checked- Returns:
- style provided if not
DATE_FORMAT_NONE, otherwise a default one
-
getDateFormat
protected java.lang.String getDateFormat(java.lang.String dateFormatInput)
Determines the date format for the component.The given date format can be either a custom date format e. g. dd/MM/yyyy (see
SimpleDateFormat) or the following constants for getting a localized date format:- short
- medium
- long
- full
- Parameters:
dateFormatInput- the configured date format- Returns:
- date format string (
DateFormat) for the component ornullif format is invalid
-
getDefaultDateFormat
protected java.util.Optional<java.lang.Integer> getDefaultDateFormat(java.lang.String formatInput)
-
getPatternDateFormat
protected java.util.Optional<java.lang.String> getPatternDateFormat(java.lang.String formatInput)
-
getDefaultDateFormat
protected java.lang.String getDefaultDateFormat(C datebox)
Returns default date format. Called if date format was not resolved bygetDateFormat(String)method.- Parameters:
datebox-- Returns:
-
createEditorView
protected abstract C createEditorView()
Creates a view component.- Returns:
- view component
-
getFormatConfigurationParameter
protected abstract java.lang.String getFormatConfigurationParameter()
Defines a name of configuration parameter that stands for a date format.- Returns:
- name of configuration parameter
-
getDateFormat
protected java.lang.String getDateFormat(C datebox, EditorContext<java.util.Date> context)
Gets format string from configuration.Returned string should be compatible with
SimpleDateFormat- Parameters:
datebox- component for which a format is requestedcontext- the context for the editor creation- Returns:
- format string
-
handleReadOnly
protected void handleReadOnly(EditorContext<java.util.Date> context, org.zkoss.zul.impl.InputElement editorView)
In case of dateTimeEditor we have to override standard implementation of handleReadOnly. readonly='true' allows user to change value by datepicker. Setting disabled='true' fixes this problem.- Overrides:
handleReadOnlyin classAbstractTextBasedEditorRenderer<java.util.Date>- Parameters:
context-editorView-
-
initViewComponent
protected void initViewComponent(org.zkoss.zul.impl.InputElement editorView, EditorContext<java.util.Date> context, EditorListener<java.util.Date> listener)Description copied from class:AbstractTextBasedEditorRendererAdds event listeners to this editor component, parses the parameter for initial value etc.- Overrides:
initViewComponentin classAbstractTextBasedEditorRenderer<java.util.Date>- Parameters:
editorView- the editor component previously created in overridden methodCockpitEditorRenderer.render(org.zkoss.zk.ui.Component, com.hybris.cockpitng.editors.EditorContext, com.hybris.cockpitng.editors.EditorListener)context- the editor context
-
render
public void render(org.zkoss.zk.ui.Component parent, EditorContext<java.util.Date> context, EditorListener<java.util.Date> listener)Description copied from interface:CockpitEditorRendererCreates a new editor component and attaches it to the specifiedComponentcomponent.- Parameters:
parent- parent component the editor should be attached tocontext- the context for the editor creationlistener- the listener to notify the rest of the world about value changes and other events
-
setRawValue
protected void setRawValue(org.zkoss.zul.impl.InputElement viewComponent, java.util.Date rawValue)Description copied from class:AbstractTextBasedEditorRendererSets the value to the given editor component.- Specified by:
setRawValuein classAbstractTextBasedEditorRenderer<java.util.Date>- Parameters:
viewComponent- the underlying editor componentrawValue- the value
-
getRawValue
protected java.util.Date getRawValue(org.zkoss.zul.impl.InputElement viewComponent)
Description copied from class:AbstractTextBasedEditorRendererExtracts value of the given editor component.- Specified by:
getRawValuein classAbstractTextBasedEditorRenderer<java.util.Date>- Parameters:
viewComponent- the underlying editor component- Returns:
- the value
-
initTimeZone
public void initTimeZone(C box, EditorContext<java.util.Date> context)
-
getInitialTimeZoneFromConfig
protected java.util.TimeZone getInitialTimeZoneFromConfig(EditorContext<java.util.Date> context)
-
getSessionTimeZoneAttribute
protected java.util.TimeZone getSessionTimeZoneAttribute()
-
getZKDefaultTimeZone
protected java.util.TimeZone getZKDefaultTimeZone()
-
-