Package io.jmix.ui.component.impl
Class DateFieldImpl<V extends Comparable<V>>
java.lang.Object
io.jmix.ui.component.impl.AbstractComponent<T>
io.jmix.ui.component.impl.AbstractViewComponent<JmixCssActionsLayout,LocalDateTime,V>
io.jmix.ui.component.impl.DateFieldImpl<V>
- All Implemented Interfaces:
AttachNotifier
,Buffered
,Component
,Component.BelongToFrame
,Component.Editable
,Component.Focusable
,Component.HasCaption
,Component.HasDescription
,Component.HasIcon
,Component.HasXmlDescriptor
,Component.Wrapper
,HasValueSource<V>
,DateField<V>
,Field<V>
,HasContextHelp
,HasDatatype<V>
,HasDebugId
,HasHtmlCaption
,HasHtmlDescription
,HasHtmlSanitizer
,HasRange<V>
,HasValidator<V>
,HasValue<V>
,Requirable
,Validatable
,org.springframework.beans.factory.InitializingBean
public class DateFieldImpl<V extends Comparable<V>>
extends AbstractViewComponent<JmixCssActionsLayout,LocalDateTime,V>
implements DateField<V>, org.springframework.beans.factory.InitializingBean
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.ui.component.Component
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
Nested classes/interfaces inherited from interface io.jmix.ui.component.DateField
DateField.Resolution
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasValue
HasValue.ValueChangeEvent<V>
-
Field Summary
Modifier and TypeFieldDescriptionprotected DataAwareComponentsTools
protected JmixDateField
static final String
protected String
protected DateTimeTransformations
protected boolean
protected Subscription
protected V
protected V
protected boolean
protected DateField.Resolution
protected ThemeConstants
protected JmixTimeFieldWrapper
protected boolean
protected static final int
protected Subscription
protected ZoneId
Fields inherited from class io.jmix.ui.component.impl.AbstractViewComponent
internalValue, uiTestIdsSupport, valueBinding
Fields inherited from class io.jmix.ui.component.impl.AbstractComponent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parent
Fields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Fields inherited from interface io.jmix.ui.component.DateField
NAME, TYPE_DATE, TYPE_DATETIME, TYPE_DEFAULT, TYPE_LOCALDATE, TYPE_LOCALDATETIME, TYPE_OFFSETDATETIME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addValidator
(Validator<? super V> validator) Adds a validator instance to the component.void
protected boolean
checkRange
(V value, boolean handleError) void
commit()
Updates all changes since the previous commit to the data source.protected void
componentValueChanged
(com.vaadin.data.HasValue.ValueChangeEvent<?> e) protected V
protected Object
convertFromLocalDateTime
(LocalDateTime localDateTime, ZoneId fromZoneId, Class javaType) protected LocalDateTime
convertToLocalDateTime
(Object date, ZoneId zoneId) protected LocalDateTime
convertToPresentation
(V modelValue) protected JmixCssActionsLayout
protected JmixDateField
protected JmixTimeFieldWrapper
void
discard()
Discards all changes since last commit.protected int
findTimeStartPos
(String dateTimeFormat) void
focus()
Sets focus to this componentprotected com.vaadin.server.ErrorMessage
Return end of range for a certain resolution.Return start of range for a certain resolution.int
Gets the tabulator index of theHasTabIndex
component.protected void
handleDateOutOfRange
(V value) protected boolean
protected void
initDateField
(JmixDateField dateField) protected void
initTimeField
(JmixTimeFieldWrapper timeField) boolean
boolean
boolean
boolean
Tests if the value stored in the object has been modified since it was last updated from the data source.boolean
boolean
isValid()
protected void
void
removeValidator
(Validator<V> validator) Removes a validator instance from the component.void
setAutofill
(boolean autofill) Sets whether autofill feature is enabled.void
setBuffered
(boolean buffered) Sets the buffered mode.void
setDataAwareComponentsTools
(DataAwareComponentsTools dataAwareComponentsTools) void
setDatatype
(Datatype<V> datatype) Sets the givendatatype
to the component.void
setDateFormat
(String dateFormat) void
setDateTimeTransformations
(DateTimeTransformations dateTimeTransformations) void
setDebugId
(String id) INTERNAL.void
setDescription
(String description) Sets the component's description.void
setEditable
(boolean editable) protected void
setEditableToComponent
(boolean editable) void
INTERNAL.
ComponentContainer.add(Component)
is normally used for adding components to a parent and the used method will call this method implicitly.void
setRangeEnd
(V value) Set end of range.void
setRangeStart
(V value) Set start of range.void
setRequired
(boolean required) Sets whether the component must contain a non-null value.void
setRequiredMessage
(String msg) Sets a message that will be displayed to user if the field is required but has null value.void
setResolution
(DateField.Resolution resolution) protected void
setResolutionInternal
(DateField.Resolution resolution) void
setTabIndex
(int tabIndex) Sets the tabulator index of theFocusable
component.void
setTimeMode
(TimeField.TimeMode timeMode) Sets time mode to use (12h AM/PM or 24h).void
setTimeZone
(TimeZone timeZone) protected void
setupComponentErrorProvider
(boolean required, com.vaadin.ui.AbstractComponent component) protected void
setValidationError
(String errorMessage) protected void
void
protected void
triggerValidators
(V value) protected void
void
validate()
protected void
valueBindingConnected
(ValueSource<V> valueSource) Methods inherited from class io.jmix.ui.component.impl.AbstractViewComponent
addValueChangeListener, fieldValueEquals, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, valueBindingActivated
Methods inherited from class io.jmix.ui.component.impl.AbstractComponent
addAttachListener, addDetachListener, addStyleName, assignDebugId, attached, detached, getAlignment, getCaption, getComponent, getComposition, getContextHelpIconClickHandler, getContextHelpText, getDebugId, getDescription, getEventHub, getFrame, getHeight, getHeightSizeUnit, getHtmlSanitizer, getIcon, getIconName, getIconResource, getId, getParent, getStyleName, getUiComponentProperties, getUiProperties, getWidth, getWidthSizeUnit, getXmlDescriptor, hasSubscriptions, isAttached, isCaptionAsHtml, isContextHelpTextHtmlEnabled, isDescriptionAsHtml, isEnabled, isEnabledRecursive, isHtmlSanitizerEnabled, isResponsive, isVisible, isVisibleRecursive, onContextHelpIconClick, publish, removeStyleName, sanitize, setAlignment, setApplicationContext, setCaption, setCaptionAsHtml, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled, setDescriptionAsHtml, setEnabled, setFrame, setHeight, setHtmlSanitizerEnabled, setIcon, setIconFromSet, setId, setResponsive, setStyleName, setVisible, setWidth, setXmlDescriptor, unsubscribe, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jmix.ui.component.Component
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, removeStyleName, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
Methods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrame
Methods inherited from interface io.jmix.ui.component.Component.Editable
isEditableWithParent
Methods inherited from interface io.jmix.ui.component.Component.Focusable
isFocusable, setFocusable
Methods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaption
Methods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription
Methods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSet
Methods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
Methods inherited from interface io.jmix.ui.component.HasHtmlCaption
isCaptionAsHtml, setCaptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlDescription
isDescriptionAsHtml, setDescriptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlSanitizer
isHtmlSanitizerEnabled, setHtmlSanitizerEnabled
Methods inherited from interface io.jmix.ui.component.HasValidator
addValidators
Methods inherited from interface io.jmix.ui.component.HasValue
addValueChangeListener, clear, getEmptyValue, getValue, isEmpty, setValue
Methods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSource
Methods inherited from interface io.jmix.ui.component.Validatable
isValidateOnCommit
-
Field Details
-
DATEFIELD_WITH_TIME_STYLENAME
- See Also:
-
VALIDATORS_LIST_INITIAL_CAPACITY
protected static final int VALIDATORS_LIST_INITIAL_CAPACITY- See Also:
-
dateTimeTransformations
-
validators
-
resolution
-
zoneId
-
datatype
-
rangeStart
-
rangeEnd
-
updatingInstance
protected boolean updatingInstance -
dateField
-
timeField
-
dateTimeFormat
-
editable
protected boolean editable -
required
protected boolean required -
theme
-
parentEditableChangeSubscription
-
valueSourceStateChangeSubscription
-
dataAwareComponentsTools
-
-
Constructor Details
-
DateFieldImpl
public DateFieldImpl()
-
-
Method Details
-
createComponent
-
createDateField
-
initDateField
-
createTimeField
-
initTimeField
-
setDataAwareComponentsTools
@Autowired public void setDataAwareComponentsTools(DataAwareComponentsTools dataAwareComponentsTools) -
setDateTimeTransformations
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
componentValueChanged
protected void componentValueChanged(com.vaadin.data.HasValue.ValueChangeEvent<?> e) -
getResolution
- Specified by:
getResolution
in interfaceDateField<V extends Comparable<V>>
-
setResolution
- Specified by:
setResolution
in interfaceDateField<V extends Comparable<V>>
-
setResolutionInternal
-
getDatatype
- Specified by:
getDatatype
in interfaceHasDatatype<V extends Comparable<V>>
- Returns:
- a datatype that is used by this component
-
setDatatype
Description copied from interface:HasDatatype
Sets the givendatatype
to the component. Its value will be formatted according to this datatype.- Specified by:
setDatatype
in interfaceHasDatatype<V extends Comparable<V>>
- Parameters:
datatype
-Datatype
instance
-
setRangeStart
Description copied from interface:HasRange
Set start of range. If the value is set before this date, the component will not validate.- Specified by:
setRangeStart
in interfaceHasRange<V extends Comparable<V>>
- Parameters:
value
- allowed start of range
-
getRangeStart
Description copied from interface:HasRange
Return start of range for a certain resolution.- Specified by:
getRangeStart
in interfaceHasRange<V extends Comparable<V>>
- Returns:
- start of allowed range
-
setRangeEnd
Description copied from interface:HasRange
Set end of range. If the value is set after this date, the component will not validate.- Specified by:
setRangeEnd
in interfaceHasRange<V extends Comparable<V>>
- Parameters:
value
- end of allowed range
-
getRangeEnd
Description copied from interface:HasRange
Return end of range for a certain resolution.- Specified by:
getRangeEnd
in interfaceHasRange<V extends Comparable<V>>
- Returns:
- end of allowed range
-
checkRange
-
handleDateOutOfRange
-
getDateFormat
- Specified by:
getDateFormat
in interfaceDateField<V extends Comparable<V>>
-
setDateFormat
- Specified by:
setDateFormat
in interfaceDateField<V extends Comparable<V>>
-
getTimeZone
Description copied from interface:DateField
- Specified by:
getTimeZone
in interfaceDateField<V extends Comparable<V>>
-
setTimeZone
Description copied from interface:DateField
- Specified by:
setTimeZone
in interfaceDateField<V extends Comparable<V>>
-
getZoneId
- Specified by:
getZoneId
in interfaceDateField<V extends Comparable<V>>
-
setAutofill
public void setAutofill(boolean autofill) Description copied from interface:DateField
Sets whether autofill feature is enabled.When enabled uses current month and year.
- Specified by:
setAutofill
in interfaceDateField<V extends Comparable<V>>
- Parameters:
autofill
- whether autofill is enabled
-
isAutofill
public boolean isAutofill()- Specified by:
isAutofill
in interfaceDateField<V extends Comparable<V>>
- Returns:
- whether autofill is enabled
-
setZoneId
- Specified by:
setZoneId
in interfaceDateField<V extends Comparable<V>>
-
updateLayout
protected void updateLayout() -
findTimeStartPos
-
setValueToPresentation
- Specified by:
setValueToPresentation
in classAbstractViewComponent<JmixCssActionsLayout,
LocalDateTime, V extends Comparable<V>>
-
constructModelValue
-
convertToPresentation
@Nullable protected LocalDateTime convertToPresentation(@Nullable V modelValue) throws ConversionException - Overrides:
convertToPresentation
in classAbstractViewComponent<JmixCssActionsLayout,
LocalDateTime, V extends Comparable<V>> - Throws:
ConversionException
-
convertToLocalDateTime
-
convertFromLocalDateTime
protected Object convertFromLocalDateTime(LocalDateTime localDateTime, @Nullable ZoneId fromZoneId, Class javaType) -
setDescription
Description copied from interface:Component.HasDescription
Sets the component's description.- Specified by:
setDescription
in interfaceComponent.HasDescription
- Overrides:
setDescription
in classAbstractComponent<JmixCssActionsLayout>
- Parameters:
description
- the new description to set
-
commit
public void commit()Description copied from interface:Buffered
Updates all changes since the previous commit to the data source. -
discard
public void discard()Description copied from interface:Buffered
Discards all changes since last commit. The object updates its value from the data source. -
isBuffered
public boolean isBuffered()- Specified by:
isBuffered
in interfaceBuffered
- Returns:
true
if buffered mode is on,false
otherwise
-
setBuffered
public void setBuffered(boolean buffered) Description copied from interface:Buffered
Sets the buffered mode.When in buffered mode, an internal buffer will be used to store changes until
Buffered.commit()
is called. CallingBuffered.discard()
will revert the internal buffer to the value of the data source.When in non-buffered mode both read and write operations will be done directly on the data source. In this mode the
Buffered.commit()
andBuffered.discard()
methods serve no purpose.- Specified by:
setBuffered
in interfaceBuffered
- Parameters:
buffered
-true
if buffered mode should be turned on,false
otherwise
-
isModified
public boolean isModified()Description copied from interface:Buffered
Tests if the value stored in the object has been modified since it was last updated from the data source.- Specified by:
isModified
in interfaceBuffered
- Returns:
true
if the value in the object has been modified since the last data source update,false
if not.
-
setDebugId
Description copied from interface:HasDebugId
INTERNAL. Managed by debug Id system.- Specified by:
setDebugId
in interfaceHasDebugId
- Overrides:
setDebugId
in classAbstractComponent<JmixCssActionsLayout>
-
valueBindingConnected
- Overrides:
valueBindingConnected
in classAbstractViewComponent<JmixCssActionsLayout,
LocalDateTime, V extends Comparable<V>>
-
setParent
Description copied from interface:Component
INTERNAL.
ComponentContainer.add(Component)
is normally used for adding components to a parent and the used method will call this method implicitly.- Specified by:
setParent
in interfaceComponent
- Overrides:
setParent
in classAbstractComponent<JmixCssActionsLayout>
- Parameters:
parent
- Parent component
-
onParentEditableChange
-
isEditable
public boolean isEditable()- Specified by:
isEditable
in interfaceComponent.Editable
-
setEditable
public void setEditable(boolean editable) - Specified by:
setEditable
in interfaceComponent.Editable
-
setEditableToComponent
protected void setEditableToComponent(boolean editable) -
focus
public void focus()Description copied from interface:Component.Focusable
Sets focus to this component- Specified by:
focus
in interfaceComponent.Focusable
-
getTabIndex
public int getTabIndex()Description copied from interface:Component.Focusable
Gets the tabulator index of theHasTabIndex
component.- Specified by:
getTabIndex
in interfaceComponent.Focusable
- Returns:
- tab index set for the
HasTabIndex
component
-
setTabIndex
public void setTabIndex(int tabIndex) Description copied from interface:Component.Focusable
Sets the tabulator index of theFocusable
component. The tab index property is used to specify the order in which the fields are focused when the user presses the Tab key. Components with a defined tab index are focused sequentially first, and then the components with no tab index.- Specified by:
setTabIndex
in interfaceComponent.Focusable
- Parameters:
tabIndex
- tab index
-
isRequired
public boolean isRequired()- Specified by:
isRequired
in interfaceRequirable
- Returns:
- whether the component must contain a non-null value
-
setRequired
public void setRequired(boolean required) Description copied from interface:Requirable
Sets whether the component must contain a non-null value.- Specified by:
setRequired
in interfaceRequirable
- Parameters:
required
- required
-
setupComponentErrorProvider
protected void setupComponentErrorProvider(boolean required, com.vaadin.ui.AbstractComponent component) -
getErrorMessage
@Nullable protected com.vaadin.server.ErrorMessage getErrorMessage() -
getRequiredMessage
- Specified by:
getRequiredMessage
in interfaceRequirable
- Returns:
- a message that will be displayed to user if the component is required but has null value
-
setRequiredMessage
Description copied from interface:Requirable
Sets a message that will be displayed to user if the field is required but has null value.- Specified by:
setRequiredMessage
in interfaceRequirable
- Parameters:
msg
- message
-
addValidator
Description copied from interface:HasValidator
Adds a validator instance to the component. TheValidationException
must be thrown by the validator if the value is not valid.- Specified by:
addValidator
in interfaceHasValidator<V extends Comparable<V>>
- Parameters:
validator
- a validator to add- See Also:
-
removeValidator
Description copied from interface:HasValidator
Removes a validator instance from the component.- Specified by:
removeValidator
in interfaceHasValidator<V extends Comparable<V>>
- Parameters:
validator
- a validator to remove
-
getValidators
- Specified by:
getValidators
in interfaceHasValidator<V extends Comparable<V>>
- Returns:
- unmodifiable collection of component validators.
-
isValid
public boolean isValid()- Specified by:
isValid
in interfaceValidatable
-
validate
- Specified by:
validate
in interfaceValidatable
- Throws:
ValidationException
-
triggerValidators
- Throws:
ValidationFailedException
-
hasValidationError
protected boolean hasValidationError()- Overrides:
hasValidationError
in classAbstractComponent<JmixCssActionsLayout>
-
setValidationError
- Overrides:
setValidationError
in classAbstractComponent<JmixCssActionsLayout>
-
setTimeMode
Description copied from interface:DateField
Sets time mode to use (12h AM/PM or 24h).By default the 24h mode is used.
- Specified by:
setTimeMode
in interfaceDateField<V extends Comparable<V>>
- Parameters:
timeMode
- time mode
-
getTimeMode
- Specified by:
getTimeMode
in interfaceDateField<V extends Comparable<V>>
- Returns:
TimeField.TimeMode
that is used by component
-