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>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.customfield.CustomField>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.customfield.CustomField>,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.HasTooltip,com.vaadin.flow.component.textfield.HasPrefixAndSuffix,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,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>,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.textfield.HasPrefixAndSuffix, 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>Base class for super number fields.- Since:
- 2020-04-07
- Author:
- miki
- See Also:
- Serialized Form
-
-
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_VARIANT
-
Fields inherited from interface org.vaadin.miki.markers.HasLabelPositionable
LABEL_POSITION_ATTRIBUTE, LABEL_POSITION_DETAILS_ATTRIBUTE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSuperNumberField(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
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description com.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 StringBuilderbuildRegularExpression(StringBuilder builder, DecimalFormat format)Builds regular expression that allows neat typing of the number already formatted.protected static StringescapeDot(char character)Escapes theDOTfor regular expression, if needed.voidfocus()protected TgenerateModelValue()StringgetErrorMessage()com.vaadin.flow.component.ComponentgetHelperComponent()StringgetHelperText()StringgetLabel()LabelPositiongetLabelPosition()Returns current label position, if it has been set.LocalegetLocale()Returns locale associated with this object.StringgetPlaceholder()Returns current placeholder text for this object.com.vaadin.flow.component.ComponentgetPrefixComponent()StringgetRawValue()Returns the raw value, as currently displayed in the underlying text field.StringgetRegexp()Returns the regular expression that matches the numbers as they are typed.com.vaadin.flow.component.ComponentgetSuffixComponent()com.vaadin.flow.component.shared.TooltipgetTooltip()com.vaadin.flow.data.value.ValueChangeModegetValueChangeMode()intgetValueChangeTimeout()booleanisAutoselect()Whether or not the component is auto-selecting upon focus.booleanisClearButtonVisible()protected booleanisFocused()Checks if the field is currently focused (underlying field received a focus event).booleanisGroupingSeparatorHiddenOnFocus()Whether or not grouping separator (used typically for thousands) should be hidden when the component gets focused.booleanisHelperAbove()Checks if the helper is positioned above.protected booleanisIntegerPartOptional()Checks whether the integer part of a floating-point number is optional.booleanisInvalid()booleanisNegativeValueAllowed()Whether or not negative values are allowed.booleanisNullValueAllowed()Checks whethernullis allowed as a value of the component.booleanisReadOnly()booleanisReceivingSelectionEventsFromClient()Check if client will inform server on selection change.booleanisRequired()Checks if this object is required.booleanisRequiredIndicatorVisible()protected 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).voidselectAll()Selects entire text in the component.voidselectNone()Removes 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.voidsetErrorMessage(String errorMessage)voidsetGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus)Changes whether or not grouping separator (used typically for thousands) should be hidden when the component gets focused.voidsetHelperAbove()Positions the helper above the component.voidsetHelperAbove(boolean above)Positions the helper above or below the component.voidsetHelperBelow()Positions the helper below the component.voidsetHelperComponent(com.vaadin.flow.component.Component component)voidsetHelperText(String helperText)voidsetId(String id)Sets this object's id.protected voidsetIntegerPartOptional(boolean optional)Sets whether the integer part of a floating-point number is optional.voidsetInvalid(boolean invalid)voidsetLabel(String label)voidsetLabelPosition(LabelPosition position)Sets the label position to a new one.voidsetLocale(Locale locale)Sets 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.voidsetNegativeValueAllowed(boolean negativeValueAllowed)Changes whether or not negative values are allowed.voidsetNullValueAllowed(boolean allowingNullValue)Sets allowance ofnullas this component's value.voidsetPlaceholder(String placeholder)Sets the placeholder text for this object.voidsetPrefixComponent(com.vaadin.flow.component.Component component)protected 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)com.vaadin.flow.component.shared.TooltipsetTooltipText(String text)voidsetValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)voidsetValueChangeTimeout(int valueChangeTimeout)protected voidupdateFieldValue()This method is called when the field loses its focus.protected voidupdateRegularExpression()Builds the regular expression for matching the input.protected voidupdateRegularExpression(boolean ignoreValueChangeFromField)Builds the regular expression and optionally ignores value change events from the underlying field.SELFwithAutoselect(boolean autoselect)ChainssetAutoselect(boolean)and returns itself.SELFwithGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus)ChainssetGroupingSeparatorHiddenOnFocus(boolean)and returns itself.SELFwithMaximumIntegerDigits(int digits)ChainssetMaximumIntegerDigits(int)and returns itself.SELFwithNegativeValueAllowed(boolean negativeValueAllowed)ChainssetNegativeValueAllowed(boolean)and returns itself.SELFwithReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient)ChainsCanReceiveSelectionEventsFromClient.setReceivingSelectionEventsFromClient(boolean)and returns itself.-
Methods inherited from class com.vaadin.flow.component.customfield.CustomField
add, addThemeVariants, onAttach, remove, removeThemeVariants, updateValue
-
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
-
Methods 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, scrollIntoView, set, setElement, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, getTabIndex, setTabIndex
-
Methods 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, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
-
Methods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValue
-
Methods inherited from interface org.vaadin.miki.markers.WithClearButtonMixin
withClearButtonVisible
-
Methods inherited from interface org.vaadin.miki.markers.WithHelperMixin
withHelperComponent, withHelperText
-
Methods inherited from interface org.vaadin.miki.markers.WithHelperPositionableMixin
withHelperAbove, withHelperAbove, withHelperBelow
-
Methods inherited from interface org.vaadin.miki.markers.WithIdMixin
withId
-
Methods inherited from interface org.vaadin.miki.markers.WithLabelMixin
withLabel
-
Methods inherited from interface org.vaadin.miki.markers.WithLabelPositionableMixin
withLabelPosition
-
Methods inherited from interface org.vaadin.miki.markers.WithLocaleMixin
withLocale
-
Methods inherited from interface org.vaadin.miki.markers.WithNullValueOptionallyAllowedMixin
withNullValueAllowed
-
Methods inherited from interface org.vaadin.miki.markers.WithPlaceholderMixin
withPlaceholder
-
Methods inherited from interface org.vaadin.miki.markers.WithRequiredMixin
withoutRequired, withRequired, withRequired
-
Methods inherited from interface org.vaadin.miki.markers.WithTooltipMixin
withTooltipText
-
Methods inherited from interface org.vaadin.miki.markers.WithValueMixin
withValue
-
-
-
-
Constructor Detail
-
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 Detail
-
escapeDot
protected static String escapeDot(char character)
Escapes theDOTfor regular expression, if needed.- Parameters:
character- Character to escape.- Returns:
- Dot escaped or the passed character.
-
setLocale
public void setLocale(Locale locale)
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:
setDecimalFormat(DecimalFormat)
-
getLocale
public Locale getLocale()
Description copied from interface:HasLocaleReturns locale associated with this object.
-
setDecimalFormat
public void setDecimalFormat(DecimalFormat format)
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
public final SELF withMaximumIntegerDigits(int digits)
ChainssetMaximumIntegerDigits(int)and returns itself.- Parameters:
digits- Maximum number of integer digits allowed.- Returns:
- This.
- See Also:
setMaximumIntegerDigits(int)
-
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.
-
updateRegularExpression
protected final void updateRegularExpression()
Builds the regular expression for matching the input.
-
buildRegularExpression
protected StringBuilder buildRegularExpression(StringBuilder builder, DecimalFormat format)
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
public String getRegexp()
Returns the regular expression that matches the numbers as they are typed.- Returns:
- A string with the regular expression.
-
setPresentationValue
protected final void setPresentationValue(T number)
-
parseRawValue
protected abstract T parseRawValue(String rawValue, DecimalFormat format) throws ParseException
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
protected T 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
public final SELF withAutoselect(boolean autoselect)
ChainssetAutoselect(boolean)and returns itself.- Parameters:
autoselect- Autoselection value.- Returns:
- This.
- See Also:
setAutoselect(boolean)
-
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
public final SELF withGroupingSeparatorHiddenOnFocus(boolean groupingSeparatorHiddenOnFocus)
ChainssetGroupingSeparatorHiddenOnFocus(boolean)and returns itself.- Parameters:
groupingSeparatorHiddenOnFocus- Whether or not to hide grouping separator on component focus.- Returns:
- This.
- See Also:
setGroupingSeparatorHiddenOnFocus(boolean)
-
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
public final SELF withNegativeValueAllowed(boolean negativeValueAllowed)
ChainssetNegativeValueAllowed(boolean)and returns itself.- Parameters:
negativeValueAllowed- Whether or not to allow negative values.- Returns:
- This.
- See Also:
setNegativeValueAllowed(boolean)
-
setPrefixComponent
public void setPrefixComponent(com.vaadin.flow.component.Component component)
- Specified by:
setPrefixComponentin interfacecom.vaadin.flow.component.textfield.HasPrefixAndSuffix
-
getPrefixComponent
public com.vaadin.flow.component.Component getPrefixComponent()
- Specified by:
getPrefixComponentin interfacecom.vaadin.flow.component.textfield.HasPrefixAndSuffix
-
setSuffixComponent
public void setSuffixComponent(com.vaadin.flow.component.Component component)
- Specified by:
setSuffixComponentin interfacecom.vaadin.flow.component.textfield.HasPrefixAndSuffix
-
getSuffixComponent
public com.vaadin.flow.component.Component getSuffixComponent()
- Specified by:
getSuffixComponentin interfacecom.vaadin.flow.component.textfield.HasPrefixAndSuffix
-
setLabel
public void setLabel(String label)
-
getLabel
public String getLabel()
-
setPlaceholder
public void setPlaceholder(String placeholder)
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
public String 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.
-
getRawValue
public String 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:
TextField.addThemeVariants(TextFieldVariant...)
-
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:
TextField.removeThemeVariants(TextFieldVariant...)
-
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
public void setErrorMessage(String errorMessage)
-
getErrorMessage
public String getErrorMessage()
-
setInvalid
public void setInvalid(boolean invalid)
-
isInvalid
public boolean isInvalid()
-
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
public SELF withReceivingSelectionEventsFromClient(boolean receivingSelectionEventsFromClient)
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:
CanReceiveSelectionEventsFromClient.setReceivingSelectionEventsFromClient(boolean)
-
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
public void setHelperText(String helperText)
- 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
public String 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:
HasHelperPositionable.setHelperAbove(),HasHelperPositionable.setHelperBelow()
-
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
public com.vaadin.flow.component.shared.Tooltip setTooltipText(String text)
- 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.
-
setLabelPosition
public void setLabelPosition(LabelPosition position)
Description copied from interface:HasLabelPositionableSets the label position to a new one.- Specified by:
setLabelPositionin interfaceHasLabelPositionable- Parameters:
position- A position to use. Settingnullwill reset it to the default setting.
-
getLabelPosition
public LabelPosition getLabelPosition()
Description copied from interface:HasLabelPositionableReturns current label position, if it has been set.- Specified by:
getLabelPositionin interfaceHasLabelPositionable- Returns:
- A
LabelPosition.
-
-