T - Type of number supported by the field.@CssImport(value="./styles/form-layout-number-field-styles.css") public abstract class AbstractSuperNumberField<T extends Number,SELF extends AbstractSuperNumberField<T,SELF>> extends com.vaadin.flow.component.customfield.CustomField<T> implements CanSelectText, CanReceiveSelectionEventsFromClient, WithReceivingSelectionEventsFromClientMixin<SELF>, TextSelectionNotifier<SELF>, com.vaadin.flow.component.textfield.HasPrefixAndSuffix, com.vaadin.flow.data.value.HasValueChangeMode, com.vaadin.flow.component.HasStyle, WithLocaleMixin<SELF>, WithLabelMixin<SELF>, WithPlaceholderMixin<SELF>, WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T,SELF>, WithIdMixin<SELF>, WithNullValueOptionallyAllowedMixin<SELF,com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>,T>, WithHelperMixin<SELF>, WithHelperPositionableMixin<SELF>, WithClearButtonMixin<SELF>, WithRequiredMixin<SELF>, WithLabelPositionableMixin<SELF>, WithTooltipMixin<SELF>
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V>com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>DEFAULT_CHANGE_TIMEOUTHELPER_ABOVE_THEME_VARIANTLABEL_POSITION_ATTRIBUTE, LABEL_POSITION_DETAILS_ATTRIBUTE| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSuperNumberField(T defaultValue,
com.vaadin.flow.function.SerializablePredicate<T> negativityPredicate,
com.vaadin.flow.function.SerializableFunction<T,T> turnToPositiveOperator,
String label,
Locale locale,
int maxFractionDigits)
Creates the field.
|
| Modifier and Type | Method and Description |
|---|---|
com.vaadin.flow.shared.Registration |
addTextSelectionListener(TextSelectionListener<SELF> listener)
Adds the listener.
|
void |
addThemeVariants(com.vaadin.flow.component.textfield.TextFieldVariant... variants)
Allows adding theme variants to the underlying text field.
|
void |
blur() |
protected StringBuilder |
buildRegularExpression(StringBuilder builder,
DecimalFormat format)
Builds regular expression that allows neat typing of the number already formatted.
|
protected static String |
escapeDot(char character)
Escapes the
DOT for regular expression, if needed. |
void |
focus() |
protected T |
generateModelValue() |
String |
getErrorMessage() |
com.vaadin.flow.component.Component |
getHelperComponent() |
String |
getHelperText() |
String |
getLabel() |
LabelPosition |
getLabelPosition()
Returns current label position, if it has been set.
|
Locale |
getLocale()
Returns locale associated with this object.
|
String |
getPlaceholder()
Returns current placeholder text for this object.
|
com.vaadin.flow.component.Component |
getPrefixComponent() |
String |
getRawValue()
Returns the raw value, as currently displayed in the underlying text field.
|
String |
getRegexp()
Returns the regular expression that matches the numbers as they are typed.
|
com.vaadin.flow.component.Component |
getSuffixComponent() |
String |
getTooltipText()
Returns the current tooltip text of the object.
|
com.vaadin.flow.data.value.ValueChangeMode |
getValueChangeMode() |
int |
getValueChangeTimeout() |
boolean |
isAutoselect()
Whether or not the component is auto-selecting upon focus.
|
boolean |
isClearButtonVisible()
Checks if the clear button is currently visible.
|
protected boolean |
isFocused()
Checks if the field is currently focused (underlying field received a focus event).
|
boolean |
isGroupingSeparatorHiddenOnFocus()
Whether or not grouping separator (used typically for thousands) should be hidden when the component gets focused.
|
boolean |
isHelperAbove()
Checks if the helper is positioned above.
|
protected boolean |
isIntegerPartOptional()
Checks whether the integer part of a floating-point number is optional.
|
boolean |
isInvalid() |
boolean |
isNegativeValueAllowed()
Whether or not negative values are allowed.
|
boolean |
isNullValueAllowed()
Checks whether
null is allowed as a value of the component. |
boolean |
isReadOnly() |
boolean |
isReceivingSelectionEventsFromClient()
Check if client will inform server on selection change.
|
boolean |
isRequired()
Checks if this object is required.
|
boolean |
isRequiredIndicatorVisible() |
protected abstract T |
parseRawValue(String rawValue,
DecimalFormat format)
Parses (somewhat) raw value from the text field into a proper typed value.
|
void |
removeThemeVariants(com.vaadin.flow.component.textfield.TextFieldVariant... variants)
Allows removing theme variants from the underlying text field.
|
void |
select(int from,
int to)
Selects text starting from index
from (inclusive) and ending at index to (exclusive). |
void |
selectAll()
Selects entire text in the component.
|
void |
selectNone()
Removes the current selection and selects no text.
|
void |
setAutoselect(boolean autoselect)
Changes whether or not the component will be auto-selecting upon focus.
|
void |
setClearButtonVisible(boolean state)
Sets the visibility of the clear button.
|
void |
setDecimalFormat(DecimalFormat format)
Sets the format definition used to displaying the value.
|
void |
setErrorMessage(String errorMessage) |
void |
setGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus)
Changes whether or not grouping separator (used typically for thousands) should be hidden when the component gets focused.
|
void |
setHelperAbove()
Positions the helper above the component.
|
void |
setHelperAbove(boolean above)
Positions the helper above or below the component.
|
void |
setHelperBelow()
Positions the helper below the component.
|
void |
setHelperComponent(com.vaadin.flow.component.Component component) |
void |
setHelperText(String helperText) |
void |
setId(String id)
Sets this object's id.
|
protected void |
setIntegerPartOptional(boolean optional)
Sets whether the integer part of a floating-point number is optional.
|
void |
setInvalid(boolean invalid) |
void |
setLabel(String label) |
void |
setLabelPosition(LabelPosition position)
Sets the label position to a new one.
|
void |
setLocale(Locale locale)
Sets the locale of the component.
|
protected void |
setMaximumFractionDigits(int digits)
Sets the maximum number of fraction digits displayed and allowed.
|
void |
setMaximumIntegerDigits(int digits)
Sets the maximum number of integer digits (before decimal point) displayed and allowed.
|
protected void |
setMinimumFractionDigits(int digits)
Sets the minimum number of fraction digits displayed.
|
void |
setNegativeValueAllowed(boolean negativeValueAllowed)
Changes whether or not negative values are allowed.
|
void |
setNullValueAllowed(boolean allowingNullValue)
Sets allowance of
null as this component's value. |
void |
setPlaceholder(String placeholder)
Sets the placeholder text for this object.
|
void |
setPrefixComponent(com.vaadin.flow.component.Component component) |
protected void |
setPresentationValue(T number) |
void |
setReadOnly(boolean readOnly) |
void |
setReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient)
Configures sending events by the client-side component.
|
void |
setRequired(boolean required)
Sets the new required state.
|
void |
setRequiredIndicatorVisible(boolean requiredIndicatorVisible) |
void |
setSuffixComponent(com.vaadin.flow.component.Component component) |
void |
setTooltipText(String text)
Sets new tooltip text of the object.
|
void |
setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode) |
void |
setValueChangeTimeout(int valueChangeTimeout) |
protected void |
updateFieldValue()
This method is called when the field loses its focus.
|
protected void |
updateRegularExpression()
Builds the regular expression for matching the input.
|
protected void |
updateRegularExpression(boolean ignoreValueChangeFromField)
Builds the regular expression and optionally ignores value change events from the underlying field.
|
SELF |
withAutoselect(boolean autoselect)
Chains
setAutoselect(boolean) and returns itself. |
SELF |
withGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus)
Chains
setGroupingSeparatorHiddenOnFocus(boolean) and returns itself. |
SELF |
withMaximumIntegerDigits(int digits)
Chains
setMaximumIntegerDigits(int) and returns itself. |
SELF |
withNegativeValueAllowed(boolean negativeValueAllowed)
Chains
setNegativeValueAllowed(boolean) and returns itself. |
SELF |
withReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient)
Chains
CanReceiveSelectionEventsFromClient.setReceivingSelectionEventsFromClient(boolean) and returns itself. |
add, remove, updateValueaddValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNamewithLocalewithLabelwithPlaceholderwithValuewithIdwithNullValueAllowedaddValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValuewithHelperComponent, withHelperTextwithHelperAbove, withHelperAbove, withHelperBelowwithClearButtonVisiblewithoutRequired, withRequired, withRequiredwithLabelPositionwithTooltipTextgetCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullprotected AbstractSuperNumberField(T defaultValue, com.vaadin.flow.function.SerializablePredicate<T> negativityPredicate, com.vaadin.flow.function.SerializableFunction<T,T> turnToPositiveOperator, String label, Locale locale, int maxFractionDigits)
defaultValue - Default value to use on startup and when there are errors.negativityPredicate - Check for whether or not given value is negative.turnToPositiveOperator - Operation to turn number into a positive one.label - Label of the field.locale - Locale to use.maxFractionDigits - Max number of fraction digits. Overwrites the settings in format obtained based on locale. Negative value means leaving whatever is supported by the format.protected static String escapeDot(char character)
DOT for regular expression, if needed.character - Character to escape.public void setLocale(Locale locale)
NumberFormat) is used to format how the number is displayed.
Contrary to setDecimalFormat(DecimalFormat) this method preserves the precision of the number.setLocale in interface HasLocalelocale - Locale to use. When null, Locale.getDefault() will be used.setDecimalFormat(DecimalFormat)public Locale getLocale()
HasLocalepublic void setDecimalFormat(DecimalFormat format)
format - DecimalFormat to use. When null, NumberFormat.getNumberInstance() will be used.protected boolean isIntegerPartOptional()
false by default - integer part is required).protected void setIntegerPartOptional(boolean optional)
optional - Whether the integer part is optional.protected void setMinimumFractionDigits(int digits)
DecimalFormat.
Will be overwritten by calls to setDecimalFormat(DecimalFormat). Calls to setLocale(Locale) will preserve this value.
Note: this is non-destructive, the underlying value of the field will not change (even though the representation will).digits - Number of digits to use.protected void setMaximumFractionDigits(int digits)
DecimalFormat.
Will be overwritten by calls to setDecimalFormat(DecimalFormat). Calls to setLocale(Locale) will preserve this value.
Note: this is non-destructive, the underlying value of the field will not change (even though the representation will).digits - Number of digits to use.public void setMaximumIntegerDigits(int digits)
DecimalFormat.
Will be overwritten by calls to setDecimalFormat(DecimalFormat). Calls to setLocale(Locale) will preserve this value.
Note: this is non-destructive, the underlying value of the field will not change (even though the representation will).digits - Number of digits to use.public final SELF withMaximumIntegerDigits(int digits)
setMaximumIntegerDigits(int) and returns itself.digits - Maximum number of integer digits allowed.setMaximumIntegerDigits(int)protected final void updateRegularExpression(boolean ignoreValueChangeFromField)
ignoreValueChangeFromField - Whether to ignore value change events coming from the underlying field.protected final void updateRegularExpression()
protected StringBuilder buildRegularExpression(StringBuilder builder, DecimalFormat format)
builder - Builder, initially empty.format - Information about the format.protected void updateFieldValue()
public String getRegexp()
protected final void setPresentationValue(T number)
protected abstract T parseRawValue(String rawValue, DecimalFormat format) throws ParseException
rawValue - Value from text field.format - Format to use.ParseException - When parsing goes wrong.NullPointerException - This will also be caught by the calling function, so beware.protected T generateModelValue()
public boolean isAutoselect()
false.true when the component will automatically select its text upon receiving focus, false otherwise.public void setAutoselect(boolean autoselect)
autoselect - true when the component should automatically select its text upon receiving focus, false otherwise.public final SELF withAutoselect(boolean autoselect)
setAutoselect(boolean) and returns itself.autoselect - Autoselection value.setAutoselect(boolean)public boolean isGroupingSeparatorHiddenOnFocus()
false.true when the value is shown without grouping separator upon focusing, false otherwise.public void setGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus)
groupingSeparatorHiddenOnFocus - true when the value should be shown without grouping separator upon focusing, false otherwise.public final SELF withGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus)
setGroupingSeparatorHiddenOnFocus(boolean) and returns itself.groupingSeparatorHiddenOnFocus - Whether or not to hide grouping separator on component focus.setGroupingSeparatorHiddenOnFocus(boolean)public boolean isNegativeValueAllowed()
true.true when negative values are allowed, false when not.public void setNegativeValueAllowed(boolean negativeValueAllowed)
negativeValueAllowed - true when negative values should be allowed, false when not.public final SELF withNegativeValueAllowed(boolean negativeValueAllowed)
setNegativeValueAllowed(boolean) and returns itself.negativeValueAllowed - Whether or not to allow negative values.setNegativeValueAllowed(boolean)public void setPrefixComponent(com.vaadin.flow.component.Component component)
setPrefixComponent in interface com.vaadin.flow.component.textfield.HasPrefixAndSuffixpublic com.vaadin.flow.component.Component getPrefixComponent()
getPrefixComponent in interface com.vaadin.flow.component.textfield.HasPrefixAndSuffixpublic void setSuffixComponent(com.vaadin.flow.component.Component component)
setSuffixComponent in interface com.vaadin.flow.component.textfield.HasPrefixAndSuffixpublic com.vaadin.flow.component.Component getSuffixComponent()
getSuffixComponent in interface com.vaadin.flow.component.textfield.HasPrefixAndSuffixpublic void setLabel(String label)
public String getLabel()
public void setPlaceholder(String placeholder)
HasPlaceholdersetPlaceholder in interface HasPlaceholderplaceholder - Placeholder text. Can be null, meaning no placeholder.public String getPlaceholder()
HasPlaceholdergetPlaceholder in interface HasPlaceholdernull, meaning no placeholder.public String getRawValue()
public void addThemeVariants(com.vaadin.flow.component.textfield.TextFieldVariant... variants)
variants - Theme variants to add.GeneratedVaadinTextField.addThemeVariants(TextFieldVariant...)public void removeThemeVariants(com.vaadin.flow.component.textfield.TextFieldVariant... variants)
variants - Theme variants to remove.GeneratedVaadinTextField.removeThemeVariants(TextFieldVariant...)public void setReadOnly(boolean readOnly)
setReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>setReadOnly in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>public boolean isReadOnly()
isReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>isReadOnly in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>public boolean isRequiredIndicatorVisible()
isRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>isRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>public void setErrorMessage(String errorMessage)
public String getErrorMessage()
public void setInvalid(boolean invalid)
public boolean isInvalid()
public void select(int from,
int to)
CanSelectTextfrom (inclusive) and ending at index to (exclusive).select in interface CanSelectTextfrom - Starting index (inclusive).to - Ending index (exclusive).public void selectAll()
CanSelectTextselectAll in interface CanSelectTextpublic void selectNone()
CanSelectTextselectNone in interface CanSelectTextpublic void setReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient)
CanReceiveSelectionEventsFromClientsetReceivingSelectionEventsFromClient in interface CanReceiveSelectionEventsFromClientreceivingSelectionEventsFromClient - When false, selecting text in client-side component will not send an event to server-side component. When true, it will.public boolean isReceivingSelectionEventsFromClient()
CanReceiveSelectionEventsFromClientisReceivingSelectionEventsFromClient in interface CanReceiveSelectionEventsFromClienttrue, each selection change in the client-side component will result in this component broadcasting a TextSelectionEvent.public com.vaadin.flow.shared.Registration addTextSelectionListener(TextSelectionListener<SELF> listener)
TextSelectionNotifieraddTextSelectionListener in interface TextSelectionNotifier<SELF extends AbstractSuperNumberField<T,SELF>>listener - A listener to add.Registration that can be used to stop listening to the event.public SELF withReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient)
WithReceivingSelectionEventsFromClientMixinCanReceiveSelectionEventsFromClient.setReceivingSelectionEventsFromClient(boolean) and returns itself.
Note: this feature is by default turned off.withReceivingSelectionEventsFromClient in interface WithReceivingSelectionEventsFromClientMixin<SELF extends AbstractSuperNumberField<T,SELF>>receivingSelectionEventsFromClient - Whether the client should send events about text selection changes.CanReceiveSelectionEventsFromClient.setReceivingSelectionEventsFromClient(boolean)public final void setNullValueAllowed(boolean allowingNullValue)
HasNullValueOptionallyAllowednull as this component's value.setNullValueAllowed in interface HasNullValueOptionallyAllowed<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>allowingNullValue - Whether to allow null as a value.public boolean isNullValueAllowed()
HasNullValueOptionallyAllowednull is allowed as a value of the component.isNullValueAllowed in interface HasNullValueOptionallyAllowed<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T extends Number>,T extends Number>,T extends Number>null is allowed as a value. Should default to false.public void setHelperComponent(com.vaadin.flow.component.Component component)
setHelperComponent in interface com.vaadin.flow.component.HasHelperpublic void setHelperText(String helperText)
setHelperText in interface com.vaadin.flow.component.HasHelperpublic com.vaadin.flow.component.Component getHelperComponent()
getHelperComponent in interface com.vaadin.flow.component.HasHelperpublic String getHelperText()
getHelperText in interface com.vaadin.flow.component.HasHelperpublic void setHelperAbove()
HasHelperPositionablesetHelperAbove in interface HasHelperPositionablepublic void setHelperBelow()
HasHelperPositionablesetHelperBelow in interface HasHelperPositionablepublic void setHelperAbove(boolean above)
HasHelperPositionablesetHelperAbove in interface HasHelperPositionableabove - When true, helper should be positioned above.HasHelperPositionable.setHelperAbove(),
HasHelperPositionable.setHelperBelow()public boolean isHelperAbove()
HasHelperPositionableisHelperAbove in interface HasHelperPositionabletrue, helper should be positioned above.public void setTooltipText(String text)
HasTooltipsetTooltipText in interface HasTooltiptext - New tooltip text.public String getTooltipText()
HasTooltipgetTooltipText in interface HasTooltippublic void setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
setValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeModepublic com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()
getValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeModepublic void setValueChangeTimeout(int valueChangeTimeout)
setValueChangeTimeout in interface com.vaadin.flow.data.value.HasValueChangeModepublic int getValueChangeTimeout()
getValueChangeTimeout in interface com.vaadin.flow.data.value.HasValueChangeModeprotected final boolean isFocused()
true when the field has focus.public void focus()
focus in interface com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField>public void blur()
blur in interface com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField>public void setClearButtonVisible(boolean state)
HasClearButtonsetClearButtonVisible in interface HasClearButtonstate - New state.public boolean isClearButtonVisible()
HasClearButtonisClearButtonVisible in interface HasClearButtonpublic void setRequired(boolean required)
HasRequiredsetRequired in interface HasRequiredrequired - Whether this component should be required.public boolean isRequired()
HasRequiredisRequired in interface HasRequiredpublic void setLabelPosition(LabelPosition position)
HasLabelPositionablesetLabelPosition in interface HasLabelPositionableposition - A position to use. Setting null will reset it to the default setting.public LabelPosition getLabelPosition()
HasLabelPositionablegetLabelPosition in interface HasLabelPositionableLabelPosition.Copyright © 2023 Miki. All rights reserved.