@JavaScript(value="frontend://timepickerConnector.js") public class TimePicker extends GeneratedVaadinTimePicker<TimePicker,LocalTime> implements HasSize, HasValidation, HasEnabled
vaadin-time-picker
web component.GeneratedVaadinTimePicker.InvalidChangeEvent<R extends GeneratedVaadinTimePicker<R,?>>
AbstractField.ComponentValueChangeEvent<C extends Component,V>
BlurNotifier.BlurEvent<C extends Component>
FocusNotifier.FocusEvent<C extends Component>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
Constructor and Description |
---|
TimePicker()
Default constructor.
|
TimePicker(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>> listener)
Convenience constructor to create a time picker with a
ValueChangeListener . |
TimePicker(LocalTime time)
Convenience constructor to create a time picker with a pre-selected time.
|
TimePicker(String label)
Convenience constructor to create a time picker with a label.
|
TimePicker(String label,
LocalTime time)
Convenience constructor to create a time picker with a pre-selected time
and a label.
|
Modifier and Type | Method and Description |
---|---|
Registration |
addInvalidChangeListener(ComponentEventListener<GeneratedVaadinTimePicker.InvalidChangeEvent<TimePicker>> listener)
Adds a listener for
invalid-changed events fired by the
webcomponent. |
String |
getErrorMessage()
Gets the current error message from the time picker.
|
String |
getLabel()
Gets the label of the time picker.
|
Locale |
getLocale()
Gets the Locale for this time picker.
|
String |
getPlaceholder()
Gets the placeholder of the time picker.
|
Duration |
getStep()
Gets the step of the time picker.
|
static Stream<Locale> |
getSupportedAvailableLocales()
Returns a stream of all the available locales that are supported by the
time picker component.
|
boolean |
isInvalid()
Gets the validity of the time picker output.
|
boolean |
isRequired()
Determines whether the time picker is marked as input required.
|
protected void |
onAttach(AttachEvent attachEvent)
Called when the component is attached to a UI.
|
void |
setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
|
void |
setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
|
void |
setLabel(String label)
Description copied from corresponding location in WebComponent:
|
void |
setLocale(Locale locale)
Set the Locale for the Time Picker.
|
void |
setMax(String max)
Set the minimum values for the date picker.
|
void |
setMin(String min)
Set the minimum values for the date picker.
|
void |
setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
|
void |
setRequired(boolean required)
Description copied from corresponding location in WebComponent:
|
void |
setStep(Duration step)
Sets the
step property of the time picker using duration. |
void |
setValue(LocalTime value)
Sets the value of this object.
|
checkValidity, getErrorMessageString, getI18nJsonObject, getLabelString, getNameString, getPatternString, getPlaceholderString, getStepDouble, isAutofocusBoolean, isDisabledBoolean, isInvalidBoolean, isPreventInvalidInputBoolean, isReadonlyBoolean, isRequiredBoolean, setAutofocus, setDisabled, setI18n, setName, setPattern, setPreventInvalidInput, setReadonly, setStep, validate
hasValidValue, setPresentationValue, setSynchronizedEvent
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, setHeight, setHeightFull, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFull
isEnabled, setEnabled
getElement
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
addBlurListener
addFocusListener
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
clear, getOptionalValue
addAttachListener
addDetachListener
public TimePicker()
public TimePicker(LocalTime time)
time
- the pre-selected time in the pickerpublic TimePicker(String label)
label
- the label describing the time pickersetLabel(String)
public TimePicker(String label, LocalTime time)
label
- the label describing the time pickertime
- the pre-selected time in the pickerpublic TimePicker(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>> listener)
ValueChangeListener
.listener
- the listener to receive value change eventsAbstractField.addValueChangeListener(HasValue.ValueChangeListener)
public void setLabel(String label)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
The label for this element.
setLabel
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
label
- the String value to setpublic void setValue(LocalTime value)
HasValue
getValue()
, fires a value change event. May throw
IllegalArgumentException
if the value is not acceptable.
Implementation note: the implementing class should document
whether null values are accepted or not, and override
HasValue.getEmptyValue()
if the empty value is not null
.
setValue
in interface HasValue<AbstractField.ComponentValueChangeEvent<TimePicker,LocalTime>,LocalTime>
setValue
in class AbstractField<TimePicker,LocalTime>
value
- the new valuepublic String getLabel()
label
property of the time pickerpublic void setErrorMessage(String errorMessage)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
The error message to display when the input is invalid.
setErrorMessage
in interface HasValidation
setErrorMessage
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
errorMessage
- the String value to setpublic String getErrorMessage()
getErrorMessage
in interface HasValidation
public void setInvalid(boolean invalid)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
Set to true if the value is invalid.
setInvalid
in interface HasValidation
setInvalid
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
invalid
- the boolean value to setpublic boolean isInvalid()
return true, if the value is invalid.
isInvalid
in interface HasValidation
validity
property from the time pickerpublic void setPlaceholder(String placeholder)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
A placeholder string in addition to the label.
setPlaceholder
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
placeholder
- the String value to setpublic String getPlaceholder()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
placeholder
property of the time pickerpublic void setRequired(boolean required)
GeneratedVaadinTimePicker
Description copied from corresponding location in WebComponent:
Set to true to mark the input as required.
setRequired
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
required
- the boolean value to setpublic boolean isRequired()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
true
if the input is required, false
otherwisepublic void setStep(Duration step)
step
property of the time picker using duration. It
specifies the intervals for the displayed items in the time picker
dropdown and also the displayed time format.
The set step needs to evenly divide a day or an hour and has to be larger
than 0 milliseconds. By default, the format is hh:mm
(same as *
Duration.ofHours(1)
If the step is less than 60 seconds, the format will be changed to
hh:mm:ss
and it can be in hh:mm:ss.fff
format, when the
step is less than 1 second.
NOTE: If the step is less than 900 seconds, the dropdown is hidden.
NOTE: changing the step to a larger duration can cause a new
HasValue.ValueChangeEvent
to be fired
if some parts (eg. seconds) is discarded from the value.
step
- the step to set, not null
and should divide a day or
an hour evenlypublic Duration getStep()
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
step
property from the picker, unit secondspublic Registration addInvalidChangeListener(ComponentEventListener<GeneratedVaadinTimePicker.InvalidChangeEvent<TimePicker>> listener)
GeneratedVaadinTimePicker
invalid-changed
events fired by the
webcomponent.addInvalidChangeListener
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
listener
- the listenerRegistration
for removing the event listenerprotected void onAttach(AttachEvent attachEvent)
Component
The default implementation does nothing.
This method is invoked before the AttachEvent
is fired for the
component.
public void setLocale(Locale locale)
By default, the locale is null
until the component is attached to
an UI, and then locale is set to UI.getLocale()
, unless a locale
has been explicitly set before that.
The time formatting is done in the browser using the Date.toLocaleTimeString() function.
If for some reason the browser doesn't support the given locale, the en-US locale is used.
NOTE: only the language + country/region codes are used. This
means that the script and variant information is not used and supported.
NOTE: timezone related data is not supported. NOTE: changing
the locale does not cause a new
HasValue.ValueChangeEvent
to be
fired.
locale
- the locale set to the time picker, cannot be [@code null}public Locale getLocale()
By default, the locale is null
until the component is attached to
an UI, and then locale is set to UI.getLocale()
, unless
setLocale(Locale)
has been explicitly called before that.
public void setMin(String min)
setMin
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
min
- the String value to setpublic void setMax(String max)
setMax
in class GeneratedVaadinTimePicker<TimePicker,LocalTime>
max
- the String value to setpublic static Stream<Locale> getSupportedAvailableLocales()
This is a shorthand for Locale.getAvailableLocales()
where all
locales without the Locale.getLanguage()
have been filtered out,
as the browser cannot localize the time for those.
setLocale(Locale)
,
Locale.getAvailableLocales()
,
Locale.getLanguage()
Copyright © 2019. All rights reserved.