public class DateFieldImpl<V extends java.lang.Comparable<V>> extends AbstractViewComponent<JmixCssActionsLayout,java.time.LocalDateTime,V> implements DateField<V>, org.springframework.beans.factory.InitializingBean
DateField.Resolution
HasValue.ValueChangeEvent<V>
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
HasContextHelp.ContextHelpIconClickEvent
Modifier and Type | Field and Description |
---|---|
protected DataAwareComponentsTools |
dataAwareComponentsTools |
protected io.jmix.core.metamodel.datatype.Datatype<V> |
datatype |
protected JmixDateField |
dateField |
static java.lang.String |
DATEFIELD_WITH_TIME_STYLENAME |
protected java.lang.String |
dateTimeFormat |
protected io.jmix.core.DateTimeTransformations |
dateTimeTransformations |
protected boolean |
editable |
protected io.jmix.core.common.event.Subscription |
parentEditableChangeSubscription |
protected V |
rangeEnd |
protected V |
rangeStart |
protected DateField.Resolution |
resolution |
protected ThemeConstants |
theme |
protected JmixTimeFieldWrapper |
timeField |
protected boolean |
updatingInstance |
protected java.util.List<Validator<V>> |
validators |
protected static int |
VALIDATORS_LIST_INITIAL_CAPACITY |
protected io.jmix.core.common.event.Subscription |
valueSourceStateChangeSubscription |
protected java.time.ZoneId |
zoneId |
internalValue, uiTestIdsSupport, valueBinding
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parent
NAME, TYPE_DATE, TYPE_DATETIME, TYPE_DEFAULT, TYPE_LOCALDATE, TYPE_LOCALDATETIME, TYPE_OFFSETDATETIME
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Constructor and Description |
---|
DateFieldImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addValidator(Validator<? super V> validator)
Adds a validator instance to the component.
|
void |
afterPropertiesSet() |
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 |
constructModelValue() |
protected java.lang.Object |
convertFromLocalDateTime(java.time.LocalDateTime localDateTime,
java.time.ZoneId fromZoneId,
java.lang.Class javaType) |
protected java.time.LocalDateTime |
convertToLocalDateTime(java.lang.Object date,
java.time.ZoneId zoneId) |
protected java.time.LocalDateTime |
convertToPresentation(V modelValue) |
protected JmixCssActionsLayout |
createComponent() |
protected JmixDateField |
createDateField() |
protected JmixTimeFieldWrapper |
createTimeField() |
void |
discard()
Discards all changes since last commit.
|
protected int |
findTimeStartPos(java.lang.String dateTimeFormat) |
void |
focus()
Sets focus to this component
|
io.jmix.core.metamodel.datatype.Datatype<V> |
getDatatype() |
java.lang.String |
getDateFormat() |
protected com.vaadin.server.ErrorMessage |
getErrorMessage() |
V |
getRangeEnd()
Return end of range for a certain resolution.
|
V |
getRangeStart()
Return start of range for a certain resolution.
|
java.lang.String |
getRequiredMessage() |
DateField.Resolution |
getResolution() |
int |
getTabIndex()
Gets the tabulator index of the
HasTabIndex component. |
TimeField.TimeMode |
getTimeMode() |
java.util.TimeZone |
getTimeZone()
|
java.util.Collection<Validator<V>> |
getValidators() |
java.time.ZoneId |
getZoneId() |
protected void |
handleDateOutOfRange(V value) |
protected boolean |
hasValidationError() |
protected void |
initDateField(JmixDateField dateField) |
protected void |
initTimeField(JmixTimeFieldWrapper timeField) |
boolean |
isAutofill() |
boolean |
isBuffered() |
boolean |
isEditable() |
boolean |
isModified()
Tests if the value stored in the object has been modified since it was
last updated from the data source.
|
boolean |
isRequired() |
boolean |
isValid() |
protected void |
onParentEditableChange(EditableChangeNotifier.EditableChangeEvent event) |
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(io.jmix.core.metamodel.datatype.Datatype<V> datatype)
Sets the given
datatype to the component. |
void |
setDateFormat(java.lang.String dateFormat) |
void |
setDateTimeTransformations(io.jmix.core.DateTimeTransformations dateTimeTransformations) |
void |
setDebugId(java.lang.String id)
INTERNAL.
|
void |
setDescription(java.lang.String description)
Sets the component's description.
|
void |
setEditable(boolean editable) |
protected void |
setEditableToComponent(boolean editable) |
void |
setParent(Component parent)
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(java.lang.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 the
Focusable component. |
void |
setTimeMode(TimeField.TimeMode timeMode)
Sets time mode to use (12h AM/PM or 24h).
|
void |
setTimeZone(java.util.TimeZone timeZone)
|
protected void |
setupComponentErrorProvider(boolean required,
com.vaadin.ui.AbstractComponent component) |
protected void |
setValidationError(java.lang.String errorMessage) |
protected void |
setValueToPresentation(java.time.LocalDateTime value) |
void |
setZoneId(java.time.ZoneId zoneId) |
protected void |
triggerValidators(V value) |
protected void |
updateLayout() |
void |
validate() |
protected void |
valueBindingConnected(ValueSource<V> valueSource) |
addValueChangeListener, fieldValueEquals, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, valueBindingActivated
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getValueSource, setValueSource
addValueChangeListener, clear, getEmptyValue, getValue, isEmpty, setValue
isEditableWithParent
getFrame, setFrame
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
isValidateOnCommit
getIcon, setIcon, setIconFromSet
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
isCaptionAsHtml, setCaptionAsHtml
getCaption, setCaption
getDescription
isDescriptionAsHtml, setDescriptionAsHtml
isHtmlSanitizerEnabled, setHtmlSanitizerEnabled
addValidators
isFocusable, setFocusable
public static final java.lang.String DATEFIELD_WITH_TIME_STYLENAME
protected static final int VALIDATORS_LIST_INITIAL_CAPACITY
protected io.jmix.core.DateTimeTransformations dateTimeTransformations
protected DateField.Resolution resolution
protected java.time.ZoneId zoneId
protected io.jmix.core.metamodel.datatype.Datatype<V extends java.lang.Comparable<V>> datatype
protected boolean updatingInstance
protected JmixDateField dateField
protected JmixTimeFieldWrapper timeField
protected java.lang.String dateTimeFormat
protected boolean editable
protected ThemeConstants theme
protected io.jmix.core.common.event.Subscription parentEditableChangeSubscription
protected io.jmix.core.common.event.Subscription valueSourceStateChangeSubscription
protected DataAwareComponentsTools dataAwareComponentsTools
protected JmixCssActionsLayout createComponent()
protected JmixDateField createDateField()
protected void initDateField(JmixDateField dateField)
protected JmixTimeFieldWrapper createTimeField()
protected void initTimeField(JmixTimeFieldWrapper timeField)
@Autowired public void setDataAwareComponentsTools(DataAwareComponentsTools dataAwareComponentsTools)
@Autowired public void setDateTimeTransformations(io.jmix.core.DateTimeTransformations dateTimeTransformations)
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
protected void componentValueChanged(com.vaadin.data.HasValue.ValueChangeEvent<?> e)
@Nullable public DateField.Resolution getResolution()
getResolution
in interface DateField<V extends java.lang.Comparable<V>>
public void setResolution(DateField.Resolution resolution)
setResolution
in interface DateField<V extends java.lang.Comparable<V>>
protected void setResolutionInternal(DateField.Resolution resolution)
@Nullable public io.jmix.core.metamodel.datatype.Datatype<V> getDatatype()
getDatatype
in interface HasDatatype<V extends java.lang.Comparable<V>>
public void setDatatype(io.jmix.core.metamodel.datatype.Datatype<V> datatype)
HasDatatype
datatype
to the component. Its value will be formatted according to this
datatype.setDatatype
in interface HasDatatype<V extends java.lang.Comparable<V>>
datatype
- Datatype
instancepublic void setRangeStart(@Nullable V value)
HasRange
setRangeStart
in interface HasRange<V extends java.lang.Comparable<V>>
value
- allowed start of range@Nullable public V getRangeStart()
HasRange
getRangeStart
in interface HasRange<V extends java.lang.Comparable<V>>
public void setRangeEnd(@Nullable V value)
HasRange
setRangeEnd
in interface HasRange<V extends java.lang.Comparable<V>>
value
- end of allowed range@Nullable public V getRangeEnd()
HasRange
getRangeEnd
in interface HasRange<V extends java.lang.Comparable<V>>
protected boolean checkRange(@Nullable V value, boolean handleError)
protected void handleDateOutOfRange(V value)
@Nullable public java.lang.String getDateFormat()
getDateFormat
in interface DateField<V extends java.lang.Comparable<V>>
public void setDateFormat(java.lang.String dateFormat)
setDateFormat
in interface DateField<V extends java.lang.Comparable<V>>
@Nullable public java.util.TimeZone getTimeZone()
DateField
getTimeZone
in interface DateField<V extends java.lang.Comparable<V>>
public void setTimeZone(@Nullable java.util.TimeZone timeZone)
DateField
setTimeZone
in interface DateField<V extends java.lang.Comparable<V>>
@Nullable public java.time.ZoneId getZoneId()
public void setAutofill(boolean autofill)
DateField
When enabled uses current month and year.
setAutofill
in interface DateField<V extends java.lang.Comparable<V>>
autofill
- whether autofill is enabledpublic boolean isAutofill()
isAutofill
in interface DateField<V extends java.lang.Comparable<V>>
public void setZoneId(@Nullable java.time.ZoneId zoneId)
protected void updateLayout()
protected int findTimeStartPos(java.lang.String dateTimeFormat)
protected void setValueToPresentation(@Nullable java.time.LocalDateTime value)
setValueToPresentation
in class AbstractViewComponent<JmixCssActionsLayout,java.time.LocalDateTime,V extends java.lang.Comparable<V>>
@Nullable protected V constructModelValue()
@Nullable protected java.time.LocalDateTime convertToPresentation(@Nullable V modelValue) throws ConversionException
convertToPresentation
in class AbstractViewComponent<JmixCssActionsLayout,java.time.LocalDateTime,V extends java.lang.Comparable<V>>
ConversionException
protected java.time.LocalDateTime convertToLocalDateTime(java.lang.Object date, @Nullable java.time.ZoneId zoneId)
protected java.lang.Object convertFromLocalDateTime(java.time.LocalDateTime localDateTime, @Nullable java.time.ZoneId fromZoneId, java.lang.Class javaType)
public void setDescription(@Nullable java.lang.String description)
Component.HasDescription
setDescription
in interface Component.HasDescription
setDescription
in class AbstractComponent<JmixCssActionsLayout>
description
- the new description to setpublic void commit()
Buffered
public void discard()
Buffered
public boolean isBuffered()
isBuffered
in interface Buffered
true
if buffered mode is on, false
otherwisepublic void setBuffered(boolean buffered)
Buffered
When in buffered mode, an internal buffer will be used to store changes
until Buffered.commit()
is called. Calling Buffered.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()
and
Buffered.discard()
methods serve no purpose.
setBuffered
in interface Buffered
buffered
- true
if buffered mode should be turned on, false
otherwisepublic boolean isModified()
Buffered
isModified
in interface Buffered
true
if the value in the object has been modified
since the last data source update, false
if not.public void setDebugId(@Nullable java.lang.String id)
HasDebugId
setDebugId
in interface HasDebugId
setDebugId
in class AbstractComponent<JmixCssActionsLayout>
protected void valueBindingConnected(ValueSource<V> valueSource)
valueBindingConnected
in class AbstractViewComponent<JmixCssActionsLayout,java.time.LocalDateTime,V extends java.lang.Comparable<V>>
public void setParent(@Nullable Component parent)
Component
ComponentContainer.add(Component)
is normally used for adding components
to a parent and the used method will call this method implicitly.setParent
in interface Component
setParent
in class AbstractComponent<JmixCssActionsLayout>
parent
- Parent componentprotected void onParentEditableChange(EditableChangeNotifier.EditableChangeEvent event)
public boolean isEditable()
isEditable
in interface Component.Editable
public void setEditable(boolean editable)
setEditable
in interface Component.Editable
protected void setEditableToComponent(boolean editable)
public void focus()
Component.Focusable
focus
in interface Component.Focusable
public int getTabIndex()
Component.Focusable
HasTabIndex
component.getTabIndex
in interface Component.Focusable
HasTabIndex
componentpublic void setTabIndex(int tabIndex)
Component.Focusable
Focusable
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.setTabIndex
in interface Component.Focusable
tabIndex
- tab indexpublic boolean isRequired()
isRequired
in interface Requirable
public void setRequired(boolean required)
Requirable
setRequired
in interface Requirable
required
- requiredprotected void setupComponentErrorProvider(boolean required, com.vaadin.ui.AbstractComponent component)
@Nullable protected com.vaadin.server.ErrorMessage getErrorMessage()
@Nullable public java.lang.String getRequiredMessage()
getRequiredMessage
in interface Requirable
public void setRequiredMessage(@Nullable java.lang.String msg)
Requirable
setRequiredMessage
in interface Requirable
msg
- messagepublic void addValidator(Validator<? super V> validator)
HasValidator
ValidationException
must be thrown by the validator
if the value is not valid.addValidator
in interface HasValidator<V extends java.lang.Comparable<V>>
validator
- a validator to addValidationException
public void removeValidator(Validator<V> validator)
HasValidator
removeValidator
in interface HasValidator<V extends java.lang.Comparable<V>>
validator
- a validator to removepublic java.util.Collection<Validator<V>> getValidators()
getValidators
in interface HasValidator<V extends java.lang.Comparable<V>>
public boolean isValid()
isValid
in interface Validatable
public void validate() throws ValidationException
validate
in interface Validatable
ValidationException
protected void triggerValidators(V value) throws ValidationFailedException
ValidationFailedException
protected boolean hasValidationError()
hasValidationError
in class AbstractComponent<JmixCssActionsLayout>
protected void setValidationError(@Nullable java.lang.String errorMessage)
setValidationError
in class AbstractComponent<JmixCssActionsLayout>
public void setTimeMode(TimeField.TimeMode timeMode)
DateField
By default the 24h mode is used.
setTimeMode
in interface DateField<V extends java.lang.Comparable<V>>
timeMode
- time mode@Nullable public TimeField.TimeMode getTimeMode()
getTimeMode
in interface DateField<V extends java.lang.Comparable<V>>
TimeField.TimeMode
that is used by component