Class AbstractSuperNumberField<T extends Number,SELF extends AbstractSuperNumberField<T,SELF>>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.customfield.CustomField<T>,T>
com.vaadin.flow.component.customfield.CustomField<T>
org.vaadin.miki.superfields.numbers.AbstractSuperNumberField<T,SELF>
- Type Parameters:
T- Type of number supported by the field.
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.customfield.CustomField<T>>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,,T>, T> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,,T>, T> com.vaadin.flow.component.shared.HasClearButton,com.vaadin.flow.component.shared.HasPrefix,com.vaadin.flow.component.shared.HasSuffix,com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.component.shared.HasValidationProperties,com.vaadin.flow.data.value.HasValueChangeMode,Serializable,TextSelectionNotifier<SELF>,CanReceiveSelectionEventsFromClient,CanSelectText,HasHelperPositionable,HasId,HasLabelPositionable,HasLocale,HasNullValueOptionallyAllowed<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,,T>, T> HasPlaceholder,HasRequired,HasTextInputMode,WithClearButtonMixin<SELF>,WithHelperMixin<SELF>,WithHelperPositionableMixin<SELF>,WithIdMixin<SELF>,WithLabelMixin<SELF>,WithLabelPositionableMixin<SELF>,WithLocaleMixin<SELF>,WithNullValueOptionallyAllowedMixin<SELF,,com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>, T>, T> WithPlaceholderMixin<SELF>,WithReceivingSelectionEventsFromClientMixin<SELF>,WithRequiredMixin<SELF>,WithTextInputModeMixin<SELF>,WithTooltipMixin<SELF>,WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<T>,T>, T, SELF>
- Direct Known Subclasses:
AbstractSuperFloatingPointField,SuperIntegerField,SuperLongField
@CssImport("./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.shared.HasPrefix, com.vaadin.flow.component.shared.HasSuffix, com.vaadin.flow.data.value.HasValueChangeMode, 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>, WithTextInputModeMixin<SELF>
Base class for super number fields.
- Since:
- 2020-04-07
- Author:
- miki
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Field Summary
Fields inherited from interface org.vaadin.miki.markers.HasHelperPositionable
HELPER_ABOVE_THEME_VARIANTFields inherited from interface org.vaadin.miki.markers.HasLabelPositionable
LABEL_POSITION_ATTRIBUTE, LABEL_POSITION_DETAILS_ATTRIBUTEFields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSuperNumberField(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. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddTextSelectionListener(TextSelectionListener<SELF> listener) Adds the listener.voidaddThemeVariants(com.vaadin.flow.component.textfield.TextFieldVariant... variants) Allows adding theme variants to the underlying text field.voidblur()protected StringBuilderbuildAllowedCharPattern(StringBuilder builder) Specifies the allowed characters and prevents invalid input.protected StringBuilderbuildRegularExpression(StringBuilder builder, DecimalFormat format) Builds regular expression that allows neat typing of the number already formatted.voidfocus()protected TReturns the currently accepted alternatives to the decimal separator.Returns the currently accepted alternatives to the grouping (thousand) separator.com.vaadin.flow.component.ComponentReturns the set of characters that are prevented from being typed in.getLabel()Returns current label position, if it has been set.Returns locale associated with this object.Returns the currently accepted alternatives to the negative (minus) sign.Returns current placeholder text for this object.com.vaadin.flow.component.ComponentReturns the raw value, as currently displayed in the underlying text field.Returns the regular expression that matches the numbers as they are typed.com.vaadin.flow.component.ComponentReturns the current text input mode of this object.com.vaadin.flow.component.shared.Tooltipcom.vaadin.flow.data.value.ValueChangeModeintbooleanWhether or not the component is auto-selecting upon focus.booleanprotected final booleanChecks if the field is currently focused (underlying field received a focus event).booleanWhether or not grouping separator (used typically for thousands) should be hidden when the component gets focused.booleanChecks if the helper is positioned above.protected booleanChecks whether the integer part of a floating-point number is optional.booleanbooleanWhether or not negative values are allowed.booleanChecks whethernullis allowed as a value of the component.booleanChecks if alternative symbols are allowed to overlap with one another and the default locale's symbols.booleanbooleanCheck if client will inform server on selection change.booleanChecks if this object is required.booleanprotected abstract TparseRawValue(String rawValue, DecimalFormat format) Parses (somewhat) raw value from the text field into a proper typed value.voidremoveThemeVariants(com.vaadin.flow.component.textfield.TextFieldVariant... variants) Allows removing theme variants from the underlying text field.voidselect(int from, int to) Selects text starting from indexfrom(inclusive) and ending at indexto(exclusive).voidSelects entire text in the component.voidRemoves the current selection and selects no text.voidsetAutoselect(boolean autoselect) Changes whether or not the component will be auto-selecting upon focus.voidsetClearButtonVisible(boolean state) voidsetDecimalFormat(DecimalFormat format) Sets the format definition used to displaying the value.protected voidsetDecimalSeparatorAlternatives(Set<Character> alternatives) Sets decimal separator alternatives, replacing previously existing ones.voidsetErrorMessage(String errorMessage) voidsetGroupingSeparatorAlternatives(Set<Character> alternatives) Sets grouping separator alternatives, replacing previously existing ones.voidsetGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus) Changes whether or not grouping separator (used typically for thousands) should be hidden when the component gets focused.voidPositions the helper above the component.voidsetHelperAbove(boolean above) Positions the helper above or below the component.voidPositions the helper below the component.voidsetHelperComponent(com.vaadin.flow.component.Component component) voidsetHelperText(String helperText) voidSets this object's id.protected voidsetIntegerPartOptional(boolean optional) Sets whether the integer part of a floating-point number is optional.voidsetInvalid(boolean invalid) voidsetKeyboardDisallowedAlternatives(Set<Character> characters) Prevents specified alternative characters from being typed with keyboard.voidvoidsetLabelPosition(LabelPosition position) Sets the label position to a new one.voidSets the locale of the component.protected voidsetMaximumFractionDigits(int digits) Sets the maximum number of fraction digits displayed and allowed.voidsetMaximumIntegerDigits(int digits) Sets the maximum number of integer digits (before decimal point) displayed and allowed.protected voidsetMinimumFractionDigits(int digits) Sets the minimum number of fraction digits displayed.voidsetNegativeSignAlternatives(Set<Character> alternatives) Sets negative sign alternatives, replacing previously existing ones.voidsetNegativeValueAllowed(boolean negativeValueAllowed) Changes whether or not negative values are allowed.final voidsetNullValueAllowed(boolean allowingNullValue) Sets allowance ofnullas this component's value.voidsetOverlappingAlternatives(boolean overlappingAlternatives) Allows (or disallows) alternative grouping, separator and negative sign symbols to overlap with each other and with the locale's default symbols.voidsetPlaceholder(String placeholder) Sets the placeholder text for this object.voidsetPrefixComponent(com.vaadin.flow.component.Component component) protected final voidsetPresentationValue(T number) voidsetReadOnly(boolean readOnly) voidsetReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient) Configures sending events by the client-side component.voidsetRequired(boolean required) Sets the new required state.voidsetRequiredIndicatorVisible(boolean requiredIndicatorVisible) voidsetSuffixComponent(com.vaadin.flow.component.Component component) voidsetTextInputMode(TextInputMode inputMode) Changes the text input mode of this object.com.vaadin.flow.component.shared.TooltipsetTooltipText(String text) voidsetValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode) voidsetValueChangeTimeout(int valueChangeTimeout) protected voidThis method is called when the field loses its focus.protected final voidBuilds the regular expression for matching the input.protected final voidupdateRegularExpression(boolean ignoreValueChangeFromField) Builds the regular expression and optionally ignores value change events from the underlying field.protected voidUpdates the underlying field's text input mode.final SELFwithAutoselect(boolean autoselect) ChainssetAutoselect(boolean)and returns itself.protected SELFwithDecimalSeparatorAlternatives(char... alternatives) ChainssetDecimalSeparatorAlternatives(Set)and returns itself.protected SELFwithDecimalSeparatorAlternatives(Set<Character> alternatives) ChainssetDecimalSeparatorAlternatives(Set)and returns itself.withGroupingSeparatorAlternatives(char... alternatives) ChainssetGroupingSeparatorAlternatives(Set)and returns itself.withGroupingSeparatorAlternatives(Set<Character> alternatives) ChainssetGroupingSeparatorAlternatives(Set)and returns itself.final SELFwithGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus) ChainssetGroupingSeparatorHiddenOnFocus(boolean)and returns itself.withKeyboardDisallowedAlternatives(char... characters) ChainssetKeyboardDisallowedAlternatives(Set)and returns itself.withKeyboardDisallowedAlternatives(Set<Character> characters) ChainssetKeyboardDisallowedAlternatives(Set)and returns itself.final SELFwithMaximumIntegerDigits(int digits) ChainssetMaximumIntegerDigits(int)and returns itself.withNegativeSignAlternatives(char... alternatives) ChainssetNegativeSignAlternatives(Set)and returns itself.withNegativeSignAlternatives(Set<Character> alternatives) ChainssetNegativeSignAlternatives(Set)and returns itself.final SELFwithNegativeValueAllowed(boolean negativeValueAllowed) ChainssetNegativeValueAllowed(boolean)and returns itself.ChainssetOverlappingAlternatives(boolean)withfalseas a parameter, and returns itself.ChainssetOverlappingAlternatives(boolean)withtrueas a parameter, and returns itself.withOverlappingAlternatives(boolean overlappingAlternatives) ChainssetOverlappingAlternatives(boolean)and returns itself.withReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient) ChainsCanReceiveSelectionEventsFromClient.setReceivingSelectionEventsFromClient(boolean)and returns itself.Methods inherited from class com.vaadin.flow.component.customfield.CustomField
add, addThemeVariants, onAttach, remove, removeThemeVariants, updateValueMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValueMethods inherited from interface org.vaadin.miki.markers.WithClearButtonMixin
withClearButtonVisibleMethods inherited from interface org.vaadin.miki.markers.WithHelperMixin
withHelperComponent, withHelperTextMethods inherited from interface org.vaadin.miki.markers.WithHelperPositionableMixin
withHelperAbove, withHelperAbove, withHelperBelowMethods inherited from interface org.vaadin.miki.markers.WithIdMixin
withIdMethods inherited from interface org.vaadin.miki.markers.WithLabelMixin
withLabelMethods inherited from interface org.vaadin.miki.markers.WithLabelPositionableMixin
withLabelPositionMethods inherited from interface org.vaadin.miki.markers.WithLocaleMixin
withLocaleMethods inherited from interface org.vaadin.miki.markers.WithNullValueOptionallyAllowedMixin
withNullValueAllowedMethods inherited from interface org.vaadin.miki.markers.WithPlaceholderMixin
withPlaceholderMethods inherited from interface org.vaadin.miki.markers.WithRequiredMixin
withoutRequired, withRequired, withRequiredMethods inherited from interface org.vaadin.miki.markers.WithTextInputModeMixin
withTextInputModeMethods inherited from interface org.vaadin.miki.markers.WithTooltipMixin
withTooltipTextMethods inherited from interface org.vaadin.miki.markers.WithValueMixin
withValue
-
Constructor Details
-
AbstractSuperNumberField
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.- Parameters:
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 onlocale. Negative value means leaving whatever is supported by the format.
-
-
Method Details
-
setLocale
Sets the locale of the component. The locale (or more precisely, its correspondingNumberFormat) is used to format how the number is displayed. Contrary tosetDecimalFormat(DecimalFormat)this method preserves the precision of the number.- Specified by:
setLocalein interfaceHasLocale- Parameters:
locale-Localeto use. Whennull,Locale.getDefault()will be used.- See Also:
-
getLocale
Description copied from interface:HasLocaleReturns locale associated with this object. -
setDecimalFormat
Sets the format definition used to displaying the value. Note: subclasses may overwrite the data in the format to make sure it follows type-specific constraints. Also note: changes to the format object may result in unpredictable behaviour of this component.- Parameters:
format-DecimalFormatto use. Whennull,NumberFormat.getNumberInstance()will be used.
-
isIntegerPartOptional
protected boolean isIntegerPartOptional()Checks whether the integer part of a floating-point number is optional.- Returns:
- Whether the integer part is optional (
falseby default - integer part is required).
-
setIntegerPartOptional
protected void setIntegerPartOptional(boolean optional) Sets whether the integer part of a floating-point number is optional. If it is set as optional, numbers can be entered without the integer part, which will be defaulted to zero.- Parameters:
optional- Whether the integer part is optional.
-
setMinimumFractionDigits
protected void setMinimumFractionDigits(int digits) Sets the minimum number of fraction digits displayed. Overwrites the value in the underlyingDecimalFormat. Will be overwritten by calls tosetDecimalFormat(DecimalFormat). Calls tosetLocale(Locale)will preserve this value. Note: this is non-destructive, the underlying value of the field will not change (even though the representation will).- Parameters:
digits- Number of digits to use.
-
setMaximumFractionDigits
protected void setMaximumFractionDigits(int digits) Sets the maximum number of fraction digits displayed and allowed. Overwrites the value in the underlyingDecimalFormat. Will be overwritten by calls tosetDecimalFormat(DecimalFormat). Calls tosetLocale(Locale)will preserve this value. Note: this is non-destructive, the underlying value of the field will not change (even though the representation will).- Parameters:
digits- Number of digits to use.
-
setMaximumIntegerDigits
public void setMaximumIntegerDigits(int digits) Sets the maximum number of integer digits (before decimal point) displayed and allowed. Overwrites the value in the underlyingDecimalFormat. Will be overwritten by calls tosetDecimalFormat(DecimalFormat). Calls tosetLocale(Locale)will preserve this value. Note: this is non-destructive, the underlying value of the field will not change (even though the representation will).- Parameters:
digits- Number of digits to use.
-
withMaximumIntegerDigits
ChainssetMaximumIntegerDigits(int)and returns itself.- Parameters:
digits- Maximum number of integer digits allowed.- Returns:
- This.
- See Also:
-
updateRegularExpression
protected final void updateRegularExpression(boolean ignoreValueChangeFromField) Builds the regular expression and optionally ignores value change events from the underlying field. Basically allows the representation of the value to be changed, but not the value itself.- Parameters:
ignoreValueChangeFromField- Whether to ignore value change events coming from the underlying field.
-
buildAllowedCharPattern
Specifies the allowed characters and prevents invalid input.- Parameters:
builder- Builder to be used. Note that the builder passed to it already starts with[\dand]is added at the end.- Returns:
- The passed builder with added allowed characters.
-
updateRegularExpression
protected final void updateRegularExpression()Builds the regular expression for matching the input. -
updateTextInputMode
protected void updateTextInputMode()Updates the underlying field's text input mode. This shows a proper on-screen keyboard on devices that support it. -
buildRegularExpression
Builds regular expression that allows neat typing of the number already formatted. Overwrite with care.- Parameters:
builder- Builder, initially empty.format- Information about the format.- Returns:
- Builder with the regular expression.
-
updateFieldValue
protected void updateFieldValue()This method is called when the field loses its focus. Do not overwrite it without a very good reason. -
getRegexp
Returns the regular expression that matches the numbers as they are typed.- Returns:
- A string with the regular expression.
-
setPresentationValue
-
parseRawValue
Parses (somewhat) raw value from the text field into a proper typed value.- Parameters:
rawValue- Value from text field.format- Format to use.- Returns:
- Parsed value.
- Throws:
ParseException- When parsing goes wrong.NullPointerException- This will also be caught by the calling function, so beware.
-
generateModelValue
-
isAutoselect
public boolean isAutoselect()Whether or not the component is auto-selecting upon focus. Defaults tofalse.- Returns:
truewhen the component will automatically select its text upon receiving focus,falseotherwise.
-
setAutoselect
public void setAutoselect(boolean autoselect) Changes whether or not the component will be auto-selecting upon focus.- Parameters:
autoselect-truewhen the component should automatically select its text upon receiving focus,falseotherwise.
-
withAutoselect
ChainssetAutoselect(boolean)and returns itself.- Parameters:
autoselect- Autoselection value.- Returns:
- This.
- See Also:
-
isGroupingSeparatorHiddenOnFocus
public boolean isGroupingSeparatorHiddenOnFocus()Whether or not grouping separator (used typically for thousands) should be hidden when the component gets focused. Grouping separators are always shown when the component is not focused. Defaults tofalse.- Returns:
truewhen the value is shown without grouping separator upon focusing,falseotherwise.
-
setGroupingSeparatorHiddenOnFocus
public void setGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus) Changes whether or not grouping separator (used typically for thousands) should be hidden when the component gets focused. Grouping separators are always shown when the component is not focused.- Parameters:
groupingSeparatorHiddenOnFocus-truewhen the value should be shown without grouping separator upon focusing,falseotherwise.
-
withGroupingSeparatorHiddenOnFocus
ChainssetGroupingSeparatorHiddenOnFocus(boolean)and returns itself.- Parameters:
groupingSeparatorHiddenOnFocus- Whether or not to hide grouping separator on component focus.- Returns:
- This.
- See Also:
-
isNegativeValueAllowed
public boolean isNegativeValueAllowed()Whether or not negative values are allowed. Defaults totrue.- Returns:
truewhen negative values are allowed,falsewhen not.
-
setNegativeValueAllowed
public void setNegativeValueAllowed(boolean negativeValueAllowed) Changes whether or not negative values are allowed. If this is changed while the value entered is negative, it will be switched to positive.- Parameters:
negativeValueAllowed-truewhen negative values should be allowed,falsewhen not.
-
withNegativeValueAllowed
ChainssetNegativeValueAllowed(boolean)and returns itself.- Parameters:
negativeValueAllowed- Whether or not to allow negative values.- Returns:
- This.
- See Also:
-
setPrefixComponent
public void setPrefixComponent(com.vaadin.flow.component.Component component) - Specified by:
setPrefixComponentin interfacecom.vaadin.flow.component.shared.HasPrefix
-
getPrefixComponent
public com.vaadin.flow.component.Component getPrefixComponent()- Specified by:
getPrefixComponentin interfacecom.vaadin.flow.component.shared.HasPrefix
-
setSuffixComponent
public void setSuffixComponent(com.vaadin.flow.component.Component component) - Specified by:
setSuffixComponentin interfacecom.vaadin.flow.component.shared.HasSuffix
-
getSuffixComponent
public com.vaadin.flow.component.Component getSuffixComponent()- Specified by:
getSuffixComponentin interfacecom.vaadin.flow.component.shared.HasSuffix
-
setLabel
-
getLabel
-
setPlaceholder
Description copied from interface:HasPlaceholderSets the placeholder text for this object.- Specified by:
setPlaceholderin interfaceHasPlaceholder- Parameters:
placeholder- Placeholder text. Can benull, meaning no placeholder.
-
getPlaceholder
Description copied from interface:HasPlaceholderReturns current placeholder text for this object.- Specified by:
getPlaceholderin interfaceHasPlaceholder- Returns:
- Current placeholder text. Can be
null, meaning no placeholder.
-
setId
Description copied from interface:HasIdSets this object's id. -
getRawValue
Returns the raw value, as currently displayed in the underlying text field. This may depend on whether the component has focus, what locale is used, etc.- Returns:
- Raw value currently displayed in the underlying text field.
-
addThemeVariants
public void addThemeVariants(com.vaadin.flow.component.textfield.TextFieldVariant... variants) Allows adding theme variants to the underlying text field.- Parameters:
variants- Theme variants to add.- See Also:
-
HasThemeVariant.addThemeVariants(ThemeVariant[])
-
removeThemeVariants
public void removeThemeVariants(com.vaadin.flow.component.textfield.TextFieldVariant... variants) Allows removing theme variants from the underlying text field.- Parameters:
variants- Theme variants to remove.- See Also:
-
HasThemeVariant.removeThemeVariants(ThemeVariant[])
-
setReadOnly
public void setReadOnly(boolean readOnly) -
isReadOnly
public boolean isReadOnly() -
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<T extends Number,SELF extends AbstractSuperNumberField<T, SELF>> - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValueAndElement<T extends Number,SELF extends AbstractSuperNumberField<T, SELF>>
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()- Specified by:
isRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<T extends Number,SELF extends AbstractSuperNumberField<T, SELF>> - Specified by:
isRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValueAndElement<T extends Number,SELF extends AbstractSuperNumberField<T, SELF>>
-
setErrorMessage
- Specified by:
setErrorMessagein interfacecom.vaadin.flow.component.HasValidation- Specified by:
setErrorMessagein interfacecom.vaadin.flow.component.shared.HasValidationProperties
-
getErrorMessage
- Specified by:
getErrorMessagein interfacecom.vaadin.flow.component.HasValidation- Specified by:
getErrorMessagein interfacecom.vaadin.flow.component.shared.HasValidationProperties
-
setInvalid
public void setInvalid(boolean invalid) - Specified by:
setInvalidin interfacecom.vaadin.flow.component.HasValidation- Specified by:
setInvalidin interfacecom.vaadin.flow.component.shared.HasValidationProperties
-
isInvalid
public boolean isInvalid()- Specified by:
isInvalidin interfacecom.vaadin.flow.component.HasValidation- Specified by:
isInvalidin interfacecom.vaadin.flow.component.shared.HasValidationProperties
-
select
public void select(int from, int to) Description copied from interface:CanSelectTextSelects text starting from indexfrom(inclusive) and ending at indexto(exclusive).- Specified by:
selectin interfaceCanSelectText- Parameters:
from- Starting index (inclusive).to- Ending index (exclusive).
-
selectAll
public void selectAll()Description copied from interface:CanSelectTextSelects entire text in the component.- Specified by:
selectAllin interfaceCanSelectText
-
selectNone
public void selectNone()Description copied from interface:CanSelectTextRemoves the current selection and selects no text.- Specified by:
selectNonein interfaceCanSelectText
-
setReceivingSelectionEventsFromClient
public void setReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient) Description copied from interface:CanReceiveSelectionEventsFromClientConfigures sending events by the client-side component. Note: this feature is by default turned off.- Specified by:
setReceivingSelectionEventsFromClientin interfaceCanReceiveSelectionEventsFromClient- Parameters:
receivingSelectionEventsFromClient- Whenfalse, selecting text in client-side component will not send an event to server-side component. Whentrue, it will.
-
isReceivingSelectionEventsFromClient
public boolean isReceivingSelectionEventsFromClient()Description copied from interface:CanReceiveSelectionEventsFromClientCheck if client will inform server on selection change. Note: this feature is by default turned off.- Specified by:
isReceivingSelectionEventsFromClientin interfaceCanReceiveSelectionEventsFromClient- Returns:
- When
true, each selection change in the client-side component will result in this component broadcasting aTextSelectionEvent.
-
addTextSelectionListener
public com.vaadin.flow.shared.Registration addTextSelectionListener(TextSelectionListener<SELF> listener) Description copied from interface:TextSelectionNotifierAdds the listener.- Specified by:
addTextSelectionListenerin interfaceTextSelectionNotifier<T extends Number>- Parameters:
listener- A listener to add.- Returns:
- A
Registrationthat can be used to stop listening to the event.
-
withReceivingSelectionEventsFromClient
Description copied from interface:WithReceivingSelectionEventsFromClientMixinChainsCanReceiveSelectionEventsFromClient.setReceivingSelectionEventsFromClient(boolean)and returns itself. Note: this feature is by default turned off.- Specified by:
withReceivingSelectionEventsFromClientin interfaceWithReceivingSelectionEventsFromClientMixin<T extends Number>- Parameters:
receivingSelectionEventsFromClient- Whether the client should send events about text selection changes.- Returns:
- This.
- See Also:
-
setNullValueAllowed
public final void setNullValueAllowed(boolean allowingNullValue) Description copied from interface:HasNullValueOptionallyAllowedSets allowance ofnullas this component's value.- Specified by:
setNullValueAllowedin interfaceHasNullValueOptionallyAllowed<T extends Number,SELF extends AbstractSuperNumberField<T, SELF>> - Parameters:
allowingNullValue- Whether to allownullas a value.
-
isNullValueAllowed
public boolean isNullValueAllowed()Description copied from interface:HasNullValueOptionallyAllowedChecks whethernullis allowed as a value of the component.- Specified by:
isNullValueAllowedin interfaceHasNullValueOptionallyAllowed<T extends Number,SELF extends AbstractSuperNumberField<T, SELF>> - Returns:
- Whether
nullis allowed as a value. Should default tofalse.
-
setHelperComponent
public void setHelperComponent(com.vaadin.flow.component.Component component) - Specified by:
setHelperComponentin interfacecom.vaadin.flow.component.HasHelper
-
setHelperText
- Specified by:
setHelperTextin interfacecom.vaadin.flow.component.HasHelper
-
getHelperComponent
public com.vaadin.flow.component.Component getHelperComponent()- Specified by:
getHelperComponentin interfacecom.vaadin.flow.component.HasHelper
-
getHelperText
- Specified by:
getHelperTextin interfacecom.vaadin.flow.component.HasHelper
-
setHelperAbove
public void setHelperAbove()Description copied from interface:HasHelperPositionablePositions the helper above the component.- Specified by:
setHelperAbovein interfaceHasHelperPositionable
-
setHelperBelow
public void setHelperBelow()Description copied from interface:HasHelperPositionablePositions the helper below the component.- Specified by:
setHelperBelowin interfaceHasHelperPositionable
-
setHelperAbove
public void setHelperAbove(boolean above) Description copied from interface:HasHelperPositionablePositions the helper above or below the component.- Specified by:
setHelperAbovein interfaceHasHelperPositionable- Parameters:
above- Whentrue, helper should be positioned above.- See Also:
-
isHelperAbove
public boolean isHelperAbove()Description copied from interface:HasHelperPositionableChecks if the helper is positioned above.- Specified by:
isHelperAbovein interfaceHasHelperPositionable- Returns:
- When
true, helper should be positioned above.
-
setTooltipText
- Specified by:
setTooltipTextin interfacecom.vaadin.flow.component.shared.HasTooltip
-
getTooltip
public com.vaadin.flow.component.shared.Tooltip getTooltip()- Specified by:
getTooltipin interfacecom.vaadin.flow.component.shared.HasTooltip
-
setValueChangeMode
public void setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode) - Specified by:
setValueChangeModein interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
getValueChangeMode
public com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()- Specified by:
getValueChangeModein interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
setValueChangeTimeout
public void setValueChangeTimeout(int valueChangeTimeout) - Specified by:
setValueChangeTimeoutin interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
getValueChangeTimeout
public int getValueChangeTimeout()- Specified by:
getValueChangeTimeoutin interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
isFocused
protected final boolean isFocused()Checks if the field is currently focused (underlying field received a focus event). Blurring the field causes it to lose focus.- Returns:
truewhen the field has focus.
-
focus
public void focus() -
blur
public void blur() -
setClearButtonVisible
public void setClearButtonVisible(boolean state) - Specified by:
setClearButtonVisiblein interfacecom.vaadin.flow.component.shared.HasClearButton
-
isClearButtonVisible
public boolean isClearButtonVisible()- Specified by:
isClearButtonVisiblein interfacecom.vaadin.flow.component.shared.HasClearButton
-
setRequired
public void setRequired(boolean required) Description copied from interface:HasRequiredSets the new required state.- Specified by:
setRequiredin interfaceHasRequired- Parameters:
required- Whether this component should be required.
-
isRequired
public boolean isRequired()Description copied from interface:HasRequiredChecks if this object is required.- Specified by:
isRequiredin interfaceHasRequired- Returns:
- Whether this component is required.
-
getLabelPosition
Description copied from interface:HasLabelPositionableReturns current label position, if it has been set.- Specified by:
getLabelPositionin interfaceHasLabelPositionable- Returns:
- A
LabelPosition.
-
getTextInputMode
Description copied from interface:HasTextInputModeReturns the current text input mode of this object.- Specified by:
getTextInputModein interfaceHasTextInputMode- Returns:
- A
TextInputMode, ornullif none has been set.
-
isOverlappingAlternatives
public boolean isOverlappingAlternatives()Checks if alternative symbols are allowed to overlap with one another and the default locale's symbols.- Returns:
truewhen overlapping between symbols is allowed;falseotherwise and by default.
-
setOverlappingAlternatives
public void setOverlappingAlternatives(boolean overlappingAlternatives) Allows (or disallows) alternative grouping, separator and negative sign symbols to overlap with each other and with the locale's default symbols. Note that this may lead to some unexpected results. Alternative symbols are always replaced in fixed order: negative sign, grouping symbols, decimal separator symbols.- Parameters:
overlappingAlternatives- Whentrue, overlapping between symbols will be allowed.
-
withOverlappingAlternatives
ChainssetOverlappingAlternatives(boolean)and returns itself.- Parameters:
overlappingAlternatives- Whether to allow overlapping alternatives.- Returns:
- This.
- See Also:
-
withOverlappingAlternatives
ChainssetOverlappingAlternatives(boolean)withtrueas a parameter, and returns itself.- Returns:
- This.
- See Also:
-
withoutOverlappingAlternatives
ChainssetOverlappingAlternatives(boolean)withfalseas a parameter, and returns itself.- Returns:
- This.
- See Also:
-
setKeyboardDisallowedAlternatives
Prevents specified alternative characters from being typed with keyboard. Only the characters that are also used as grouping separator, decimal separator or negative sign alternative are prevented. This alters the underlying field's allowed char pattern; it is still possible to paste text with that character.- Parameters:
characters- Characters to be disallowed.
-
getKeyboardDisallowedAlternatives
Returns the set of characters that are prevented from being typed in. Note that this set may include more characters than the alternative symbols.- Returns:
- A set of characters that, if they are an alternative symbol, cannot be typed in. Never
null, but possibly empty.
-
withKeyboardDisallowedAlternatives
ChainssetKeyboardDisallowedAlternatives(Set)and returns itself.- Parameters:
characters- Characters to disallow.- Returns:
- This.
- See Also:
-
withKeyboardDisallowedAlternatives
ChainssetKeyboardDisallowedAlternatives(Set)and returns itself.- Parameters:
characters- Characters to disallow.- Returns:
- This.
- See Also:
-
getGroupingSeparatorAlternatives
Returns the currently accepted alternatives to the grouping (thousand) separator.- Returns:
- Currently allowed alternatives to the main grouping separator, which is not included in the result. Never
null, but possibly empty.
-
setGroupingSeparatorAlternatives
Sets grouping separator alternatives, replacing previously existing ones. Note that this preserves the automatically addedSPACEwhen the format usesNON_BREAKING_SPACE.- Parameters:
alternatives- Any alternatives that are identical to the already used separators or negative sign or their alternatives are ignored.
-
withGroupingSeparatorAlternatives
ChainssetGroupingSeparatorAlternatives(Set)and returns itself.- Parameters:
alternatives- Alternatives to use.- Returns:
- This.
- See Also:
-
withGroupingSeparatorAlternatives
ChainssetGroupingSeparatorAlternatives(Set)and returns itself.- Parameters:
alternatives- Alternatives to use.- Returns:
- This.
- See Also:
-
getDecimalSeparatorAlternatives
Returns the currently accepted alternatives to the decimal separator.- Returns:
- Currently allowed alternatives to the main decimal separator, which is not included in the result. Never
null, but possibly empty.
-
setDecimalSeparatorAlternatives
Sets decimal separator alternatives, replacing previously existing ones.- Parameters:
alternatives- Any alternatives that are identical to the already used separators or negative sign or their alternatives are ignored.
-
withDecimalSeparatorAlternatives
ChainssetDecimalSeparatorAlternatives(Set)and returns itself.- Parameters:
alternatives- Alternatives to use.- Returns:
- This.
- See Also:
-
withDecimalSeparatorAlternatives
ChainssetDecimalSeparatorAlternatives(Set)and returns itself.- Parameters:
alternatives- Alternatives to use.- Returns:
- This.
- See Also:
-
getNegativeSignAlternatives
Returns the currently accepted alternatives to the negative (minus) sign.- Returns:
- Currently allowed alternatives to the main negative sign, which is not included in the result. Never
null, but possibly empty.
-
setNegativeSignAlternatives
Sets negative sign alternatives, replacing previously existing ones.- Parameters:
alternatives- Any alternatives that are identical to the already used separators or negative sign or their alternatives are ignored.
-
withNegativeSignAlternatives
ChainssetNegativeSignAlternatives(Set)and returns itself.- Parameters:
alternatives- Alternatives to use.- Returns:
- This.
- See Also:
-
withNegativeSignAlternatives
ChainssetNegativeSignAlternatives(Set)and returns itself.- Parameters:
alternatives- Alternatives to use.- Returns:
- This.
- See Also:
-