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.WrapperNested classes/interfaces inherited from interface io.jmix.ui.component.DateField
DateField.ResolutionNested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEventNested classes/interfaces inherited from interface io.jmix.ui.component.HasValue
HasValue.ValueChangeEvent<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataAwareComponentsToolsprotected JmixDateFieldstatic final Stringprotected Stringprotected DateTimeTransformationsprotected booleanprotected Subscriptionprotected Vprotected Vprotected booleanprotected DateField.Resolutionprotected ThemeConstantsprotected JmixTimeFieldWrapperprotected booleanprotected static final intprotected Subscriptionprotected ZoneIdFields inherited from class io.jmix.ui.component.impl.AbstractViewComponent
internalValue, uiTestIdsSupport, valueBindingFields inherited from class io.jmix.ui.component.impl.AbstractComponent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parentFields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZEFields inherited from interface io.jmix.ui.component.DateField
NAME, TYPE_DATE, TYPE_DATETIME, TYPE_DEFAULT, TYPE_LOCALDATE, TYPE_LOCALDATETIME, TYPE_OFFSETDATETIME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValidator(Validator<? super V> validator) Adds a validator instance to the component.voidprotected booleancheckRange(V value, boolean handleError) voidcommit()Updates all changes since the previous commit to the data source.protected voidcomponentValueChanged(com.vaadin.data.HasValue.ValueChangeEvent<?> e) protected Vprotected ObjectconvertFromLocalDateTime(LocalDateTime localDateTime, ZoneId fromZoneId, Class javaType) protected LocalDateTimeconvertToLocalDateTime(Object date, ZoneId zoneId) protected LocalDateTimeconvertToPresentation(V modelValue) protected JmixCssActionsLayoutprotected JmixDateFieldprotected JmixTimeFieldWrappervoiddiscard()Discards all changes since last commit.protected intfindTimeStartPos(String dateTimeFormat) voidfocus()Sets focus to this componentprotected com.vaadin.server.ErrorMessageReturn end of range for a certain resolution.Return start of range for a certain resolution.intGets the tabulator index of theHasTabIndexcomponent.protected voidhandleDateOutOfRange(V value) protected booleanprotected voidinitDateField(JmixDateField dateField) protected voidinitTimeField(JmixTimeFieldWrapper timeField) booleanbooleanbooleanbooleanTests if the value stored in the object has been modified since it was last updated from the data source.booleanbooleanisValid()protected voidvoidremoveValidator(Validator<V> validator) Removes a validator instance from the component.voidsetAutofill(boolean autofill) Sets whether autofill feature is enabled.voidsetBuffered(boolean buffered) Sets the buffered mode.voidsetDataAwareComponentsTools(DataAwareComponentsTools dataAwareComponentsTools) voidsetDatatype(Datatype<V> datatype) Sets the givendatatypeto the component.voidsetDateFormat(String dateFormat) voidsetDateTimeTransformations(DateTimeTransformations dateTimeTransformations) voidsetDebugId(String id) INTERNAL.voidsetDescription(String description) Sets the component's description.voidsetEditable(boolean editable) protected voidsetEditableToComponent(boolean editable) voidINTERNAL.
ComponentContainer.add(Component)is normally used for adding components to a parent and the used method will call this method implicitly.voidsetRangeEnd(V value) Set end of range.voidsetRangeStart(V value) Set start of range.voidsetRequired(boolean required) Sets whether the component must contain a non-null value.voidsetRequiredMessage(String msg) Sets a message that will be displayed to user if the field is required but has null value.voidsetResolution(DateField.Resolution resolution) protected voidsetResolutionInternal(DateField.Resolution resolution) voidsetTabIndex(int tabIndex) Sets the tabulator index of theFocusablecomponent.voidsetTimeMode(TimeField.TimeMode timeMode) Sets time mode to use (12h AM/PM or 24h).voidsetTimeZone(TimeZone timeZone) protected voidsetupComponentErrorProvider(boolean required, com.vaadin.ui.AbstractComponent component) protected voidsetValidationError(String errorMessage) protected voidvoidprotected voidtriggerValidators(V value) protected voidvoidvalidate()protected voidvalueBindingConnected(ValueSource<V> valueSource) Methods inherited from class io.jmix.ui.component.impl.AbstractViewComponent
addValueChangeListener, fieldValueEquals, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, valueBindingActivatedMethods 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, withUnwrappedCompositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, withUnwrappedCompositionMethods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrameMethods inherited from interface io.jmix.ui.component.Component.Editable
isEditableWithParentMethods inherited from interface io.jmix.ui.component.Component.Focusable
isFocusable, setFocusableMethods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaptionMethods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescriptionMethods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSetMethods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabledMethods inherited from interface io.jmix.ui.component.HasHtmlCaption
isCaptionAsHtml, setCaptionAsHtmlMethods inherited from interface io.jmix.ui.component.HasHtmlDescription
isDescriptionAsHtml, setDescriptionAsHtmlMethods inherited from interface io.jmix.ui.component.HasHtmlSanitizer
isHtmlSanitizerEnabled, setHtmlSanitizerEnabledMethods inherited from interface io.jmix.ui.component.HasValidator
addValidatorsMethods inherited from interface io.jmix.ui.component.HasValue
addValueChangeListener, clear, getEmptyValue, getValue, isEmpty, setValueMethods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSourceMethods 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:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
componentValueChanged
protected void componentValueChanged(com.vaadin.data.HasValue.ValueChangeEvent<?> e) -
getResolution
- Specified by:
getResolutionin interfaceDateField<V extends Comparable<V>>
-
setResolution
- Specified by:
setResolutionin interfaceDateField<V extends Comparable<V>>
-
setResolutionInternal
-
getDatatype
- Specified by:
getDatatypein interfaceHasDatatype<V extends Comparable<V>>- Returns:
- a datatype that is used by this component
-
setDatatype
Description copied from interface:HasDatatypeSets the givendatatypeto the component. Its value will be formatted according to this datatype.- Specified by:
setDatatypein interfaceHasDatatype<V extends Comparable<V>>- Parameters:
datatype-Datatypeinstance
-
setRangeStart
Description copied from interface:HasRangeSet start of range. If the value is set before this date, the component will not validate.- Specified by:
setRangeStartin interfaceHasRange<V extends Comparable<V>>- Parameters:
value- allowed start of range
-
getRangeStart
Description copied from interface:HasRangeReturn start of range for a certain resolution.- Specified by:
getRangeStartin interfaceHasRange<V extends Comparable<V>>- Returns:
- start of allowed range
-
setRangeEnd
Description copied from interface:HasRangeSet end of range. If the value is set after this date, the component will not validate.- Specified by:
setRangeEndin interfaceHasRange<V extends Comparable<V>>- Parameters:
value- end of allowed range
-
getRangeEnd
Description copied from interface:HasRangeReturn end of range for a certain resolution.- Specified by:
getRangeEndin interfaceHasRange<V extends Comparable<V>>- Returns:
- end of allowed range
-
checkRange
-
handleDateOutOfRange
-
getDateFormat
- Specified by:
getDateFormatin interfaceDateField<V extends Comparable<V>>
-
setDateFormat
- Specified by:
setDateFormatin interfaceDateField<V extends Comparable<V>>
-
getTimeZone
Description copied from interface:DateField- Specified by:
getTimeZonein interfaceDateField<V extends Comparable<V>>
-
setTimeZone
Description copied from interface:DateField- Specified by:
setTimeZonein interfaceDateField<V extends Comparable<V>>
-
getZoneId
- Specified by:
getZoneIdin interfaceDateField<V extends Comparable<V>>
-
setAutofill
public void setAutofill(boolean autofill) Description copied from interface:DateFieldSets whether autofill feature is enabled.When enabled uses current month and year.
- Specified by:
setAutofillin interfaceDateField<V extends Comparable<V>>- Parameters:
autofill- whether autofill is enabled
-
isAutofill
public boolean isAutofill()- Specified by:
isAutofillin interfaceDateField<V extends Comparable<V>>- Returns:
- whether autofill is enabled
-
setZoneId
- Specified by:
setZoneIdin interfaceDateField<V extends Comparable<V>>
-
updateLayout
protected void updateLayout() -
findTimeStartPos
-
setValueToPresentation
- Specified by:
setValueToPresentationin classAbstractViewComponent<JmixCssActionsLayout,LocalDateTime, V extends Comparable<V>>
-
constructModelValue
-
convertToPresentation
@Nullable protected LocalDateTime convertToPresentation(@Nullable V modelValue) throws ConversionException - Overrides:
convertToPresentationin 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.HasDescriptionSets the component's description.- Specified by:
setDescriptionin interfaceComponent.HasDescription- Overrides:
setDescriptionin classAbstractComponent<JmixCssActionsLayout>- Parameters:
description- the new description to set
-
commit
public void commit()Description copied from interface:BufferedUpdates all changes since the previous commit to the data source. -
discard
public void discard()Description copied from interface:BufferedDiscards all changes since last commit. The object updates its value from the data source. -
isBuffered
public boolean isBuffered()- Specified by:
isBufferedin interfaceBuffered- Returns:
trueif buffered mode is on,falseotherwise
-
setBuffered
public void setBuffered(boolean buffered) Description copied from interface:BufferedSets 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:
setBufferedin interfaceBuffered- Parameters:
buffered-trueif buffered mode should be turned on,falseotherwise
-
isModified
public boolean isModified()Description copied from interface:BufferedTests if the value stored in the object has been modified since it was last updated from the data source.- Specified by:
isModifiedin interfaceBuffered- Returns:
trueif the value in the object has been modified since the last data source update,falseif not.
-
setDebugId
Description copied from interface:HasDebugIdINTERNAL. Managed by debug Id system.- Specified by:
setDebugIdin interfaceHasDebugId- Overrides:
setDebugIdin classAbstractComponent<JmixCssActionsLayout>
-
valueBindingConnected
- Overrides:
valueBindingConnectedin classAbstractViewComponent<JmixCssActionsLayout,LocalDateTime, V extends Comparable<V>>
-
setParent
Description copied from interface:ComponentINTERNAL.
ComponentContainer.add(Component)is normally used for adding components to a parent and the used method will call this method implicitly.- Specified by:
setParentin interfaceComponent- Overrides:
setParentin classAbstractComponent<JmixCssActionsLayout>- Parameters:
parent- Parent component
-
onParentEditableChange
-
isEditable
public boolean isEditable()- Specified by:
isEditablein interfaceComponent.Editable
-
setEditable
public void setEditable(boolean editable) - Specified by:
setEditablein interfaceComponent.Editable
-
setEditableToComponent
protected void setEditableToComponent(boolean editable) -
focus
public void focus()Description copied from interface:Component.FocusableSets focus to this component- Specified by:
focusin interfaceComponent.Focusable
-
getTabIndex
public int getTabIndex()Description copied from interface:Component.FocusableGets the tabulator index of theHasTabIndexcomponent.- Specified by:
getTabIndexin interfaceComponent.Focusable- Returns:
- tab index set for the
HasTabIndexcomponent
-
setTabIndex
public void setTabIndex(int tabIndex) Description copied from interface:Component.FocusableSets the tabulator index of theFocusablecomponent. 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:
setTabIndexin interfaceComponent.Focusable- Parameters:
tabIndex- tab index
-
isRequired
public boolean isRequired()- Specified by:
isRequiredin interfaceRequirable- Returns:
- whether the component must contain a non-null value
-
setRequired
public void setRequired(boolean required) Description copied from interface:RequirableSets whether the component must contain a non-null value.- Specified by:
setRequiredin 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:
getRequiredMessagein interfaceRequirable- Returns:
- a message that will be displayed to user if the component is required but has null value
-
setRequiredMessage
Description copied from interface:RequirableSets a message that will be displayed to user if the field is required but has null value.- Specified by:
setRequiredMessagein interfaceRequirable- Parameters:
msg- message
-
addValidator
Description copied from interface:HasValidatorAdds a validator instance to the component. TheValidationExceptionmust be thrown by the validator if the value is not valid.- Specified by:
addValidatorin interfaceHasValidator<V extends Comparable<V>>- Parameters:
validator- a validator to add- See Also:
-
removeValidator
Description copied from interface:HasValidatorRemoves a validator instance from the component.- Specified by:
removeValidatorin interfaceHasValidator<V extends Comparable<V>>- Parameters:
validator- a validator to remove
-
getValidators
- Specified by:
getValidatorsin interfaceHasValidator<V extends Comparable<V>>- Returns:
- unmodifiable collection of component validators.
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceValidatable
-
validate
- Specified by:
validatein interfaceValidatable- Throws:
ValidationException
-
triggerValidators
- Throws:
ValidationFailedException
-
hasValidationError
protected boolean hasValidationError()- Overrides:
hasValidationErrorin classAbstractComponent<JmixCssActionsLayout>
-
setValidationError
- Overrides:
setValidationErrorin classAbstractComponent<JmixCssActionsLayout>
-
setTimeMode
Description copied from interface:DateFieldSets time mode to use (12h AM/PM or 24h).By default the 24h mode is used.
- Specified by:
setTimeModein interfaceDateField<V extends Comparable<V>>- Parameters:
timeMode- time mode
-
getTimeMode
- Specified by:
getTimeModein interfaceDateField<V extends Comparable<V>>- Returns:
TimeField.TimeModethat is used by component
-