Class AbstractDateTimeEditor<C extends org.zkoss.zul.impl.FormatInputElement>

  • 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 for Date values.

    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).

    • Constructor Detail

      • AbstractDateTimeEditor

        public AbstractDateTimeEditor()
    • 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 to DATE_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 or null if 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 by getDateFormat(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 requested
        context - 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:
        handleReadOnly in class AbstractTextBasedEditorRenderer<java.util.Date>
        Parameters:
        context -
        editorView -
      • render

        public void render​(org.zkoss.zk.ui.Component parent,
                           EditorContext<java.util.Date> context,
                           EditorListener<java.util.Date> listener)
        Description copied from interface: CockpitEditorRenderer
        Creates a new editor component and attaches it to the specified Component component.
        Parameters:
        parent - parent component the editor should be attached to
        context - the context for the editor creation
        listener - 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: AbstractTextBasedEditorRenderer
        Sets the value to the given editor component.
        Specified by:
        setRawValue in class AbstractTextBasedEditorRenderer<java.util.Date>
        Parameters:
        viewComponent - the underlying editor component
        rawValue - the value
      • getRawValue

        protected java.util.Date getRawValue​(org.zkoss.zul.impl.InputElement viewComponent)
        Description copied from class: AbstractTextBasedEditorRenderer
        Extracts value of the given editor component.
        Specified by:
        getRawValue in class AbstractTextBasedEditorRenderer<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()