Class SuperBigDecimalField
- 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>
-
- org.vaadin.miki.superfields.numbers.AbstractSuperFloatingPointField<BigDecimal,SuperBigDecimalField>
-
- org.vaadin.miki.superfields.numbers.SuperBigDecimalField
-
- 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<BigDecimal>,BigDecimal>,BigDecimal>,com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<BigDecimal>,BigDecimal>,BigDecimal>,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<SuperBigDecimalField>,CanReceiveSelectionEventsFromClient,CanSelectText,HasHelperPositionable,HasId,HasLabelPositionable,HasLocale,HasNullValueOptionallyAllowed<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<BigDecimal>,BigDecimal>,BigDecimal>,HasPlaceholder,HasRequired,WithClearButtonMixin<SuperBigDecimalField>,WithHelperMixin<SuperBigDecimalField>,WithHelperPositionableMixin<SuperBigDecimalField>,WithIdMixin<SuperBigDecimalField>,WithLabelMixin<SuperBigDecimalField>,WithLabelPositionableMixin<SuperBigDecimalField>,WithLocaleMixin<SuperBigDecimalField>,WithNullValueOptionallyAllowedMixin<SuperBigDecimalField,com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<BigDecimal>,BigDecimal>,BigDecimal>,WithPlaceholderMixin<SuperBigDecimalField>,WithReceivingSelectionEventsFromClientMixin<SuperBigDecimalField>,WithRequiredMixin<SuperBigDecimalField>,WithTooltipMixin<SuperBigDecimalField>,WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.customfield.CustomField<BigDecimal>,BigDecimal>,BigDecimal,SuperBigDecimalField>
@JsModule("./super-big-decimal-field.ts") @Tag("super-big-decimal-field") public class SuperBigDecimalField extends AbstractSuperFloatingPointField<BigDecimal,SuperBigDecimalField>A field forBigDecimalvalues that are properly formatted. In addition it supports entering precise numbers through scientific notation. Note: the value entered through scientific notation will be formatted according to the settings and as such the displayed value may differ from the actual value.- Since:
- 2020-04-08
- 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 Constructor Description SuperBigDecimalField()Constructs the field with an empty label,BigDecimal.ZEROas default value and with defaultLocale.SuperBigDecimalField(String label)Constructs the field with defaultLocaleandBigDecimal.ZEROas default value.SuperBigDecimalField(String label, Locale locale)Constructs the field withBigDecimal.ZEROas the default value.SuperBigDecimalField(String label, Locale locale, int maxFractionDigits)Constructs the field withBigDecimal.ZEROas the default value..SuperBigDecimalField(BigDecimal defaultValue, String label)Constructs the field with given default value and label, and with defaultLocale.SuperBigDecimalField(BigDecimal defaultValue, String label, Locale locale, int maxFractionDigits)Constructs the field.SuperBigDecimalField(Locale locale)Constructs the field with an empty label andBigDecimal.ZEROas default value.SuperBigDecimalField(Locale locale, int maxFractionDigits)Constructs the field with an empty label andBigDecimal.ZEROas default value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringBuilderbuildRegularExpression(StringBuilder builder, DecimalFormat format)Builds regular expression that allows neat typing of the number already formatted.chargetExponentSeparator()Returns the current exponent separator in the scientific notation.intgetMaximumExponentDigits()Returns the number of allowed digits in exponent.intgetMaximumSignificandFractionDigits()Returns the maximum number of digits allowed in the fractional (decimal) part of the significand in the scientific notation.intgetMaximumSignificandIntegerDigits()Returns the maximum number of digits allowed in the integer part of the significand in the scientific notation.booleanisNegativeExponentAllowed()Checks whether or not negative exponent is allowed when entering number in scientific notation.booleanisScientificNotationEnabled()Checks whether scientific notation input is supported (by default it is not).protected BigDecimalparseRawValue(String rawValue, DecimalFormat format)Parses (somewhat) raw value from the text field into a proper typed value.voidsetDecimalFormat(DecimalFormat format)Sets the format definition used to displaying the value.voidsetExponentSeparator(char exponentSeparator)Sets the exponent separator.voidsetMaximumExponentDigits(int maximumExponentDigits)Sets maximum allowed digits in exponent.voidsetMaximumSignificandFractionDigits(int maximumSignificandFractionDigits)Sets the number of digits allowed in the fractional (decimal) part of the significand in the scientific notation.voidsetMaximumSignificandIntegerDigits(int maximumSignificandIntegerDigits)Sets the number of digits allowed in the integer part of the significand in the scientific notation.voidsetNegativeExponentAllowed(boolean negativeExponentAllowed)Allows or disallows the exponent in scientific notation to be negative.protected voidupdateFieldValue()This method is called when the field loses its focus.SuperBigDecimalFieldwithExponentSeparator(char exponentSeparator)ChainssetExponentSeparator(char)and returns itself.SuperBigDecimalFieldwithMaximumExponentDigits(int maximumExponentDigits)ChainssetMaximumExponentDigits(int)and returns itself.SuperBigDecimalFieldwithMaximumSignificandFractionDigits(int maximumSignificandFractionDigits)ChainssetMaximumSignificandFractionDigits(int)and returns itself.SuperBigDecimalFieldwithMaximumSignificandIntegerDigits(int maximumSignificandIntegerDigits)ChainssetMaximumSignificandIntegerDigits(int)and returns itself.SuperBigDecimalFieldwithNegativeExponentAllowed(boolean negativeExponentAllowed)ChainssetNegativeExponentAllowed(boolean)and returns itself.-
Methods inherited from class org.vaadin.miki.superfields.numbers.AbstractSuperFloatingPointField
isIntegerPartOptional, setIntegerPartOptional, setMaximumFractionDigits, setMinimumFractionDigits, withIntegerPartOptional, withIntegerPartOptional, withIntegerPartRequired, withMaximumFractionDigits, withMinimumFractionDigits
-
Methods inherited from class org.vaadin.miki.superfields.numbers.AbstractSuperNumberField
addTextSelectionListener, addThemeVariants, blur, escapeDot, focus, generateModelValue, getErrorMessage, getHelperComponent, getHelperText, getLabel, getLabelPosition, getLocale, getPlaceholder, getPrefixComponent, getRawValue, getRegexp, getSuffixComponent, getTooltip, getValueChangeMode, getValueChangeTimeout, isAutoselect, isClearButtonVisible, isFocused, isGroupingSeparatorHiddenOnFocus, isHelperAbove, isInvalid, isNegativeValueAllowed, isNullValueAllowed, isReadOnly, isReceivingSelectionEventsFromClient, isRequired, isRequiredIndicatorVisible, removeThemeVariants, select, selectAll, selectNone, setAutoselect, setClearButtonVisible, setErrorMessage, setGroupingSeparatorHiddenOnFocus, setHelperAbove, setHelperAbove, setHelperBelow, setHelperComponent, setHelperText, setId, setInvalid, setLabel, setLabelPosition, setLocale, setMaximumIntegerDigits, setNegativeValueAllowed, setNullValueAllowed, setPlaceholder, setPrefixComponent, setPresentationValue, setReadOnly, setReceivingSelectionEventsFromClient, setRequired, setRequiredIndicatorVisible, setSuffixComponent, setTooltipText, setValueChangeMode, setValueChangeTimeout, updateRegularExpression, updateRegularExpression, withAutoselect, withGroupingSeparatorHiddenOnFocus, withMaximumIntegerDigits, withNegativeValueAllowed, withReceivingSelectionEventsFromClient
-
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
-
SuperBigDecimalField
public SuperBigDecimalField()
Constructs the field with an empty label,BigDecimal.ZEROas default value and with defaultLocale.
-
SuperBigDecimalField
public SuperBigDecimalField(Locale locale)
Constructs the field with an empty label andBigDecimal.ZEROas default value.- Parameters:
locale- Locale to use for formatting.
-
SuperBigDecimalField
public SuperBigDecimalField(Locale locale, int maxFractionDigits)
Constructs the field with an empty label andBigDecimal.ZEROas default value.- Parameters:
locale- Locale to use for formatting.maxFractionDigits- Maximum number of fraction digits allowed (overwrites setting found inlocale.
-
SuperBigDecimalField
public SuperBigDecimalField(String label)
Constructs the field with defaultLocaleandBigDecimal.ZEROas default value.- Parameters:
label- Label accompanying the field.
-
SuperBigDecimalField
public SuperBigDecimalField(String label, Locale locale)
Constructs the field withBigDecimal.ZEROas the default value.- Parameters:
label- Label accompanying the field.locale- Locale to use for formatting.
-
SuperBigDecimalField
public SuperBigDecimalField(BigDecimal defaultValue, String label)
Constructs the field with given default value and label, and with defaultLocale.- Parameters:
defaultValue- Default value.label- Label that accompanies the field.
-
SuperBigDecimalField
public SuperBigDecimalField(String label, Locale locale, int maxFractionDigits)
Constructs the field withBigDecimal.ZEROas the default value..- Parameters:
label- Label accompanying the field.locale- Locale to use for formatting.maxFractionDigits- Maximum number of fraction digits allowed (overwrites setting found inlocale.
-
SuperBigDecimalField
public SuperBigDecimalField(BigDecimal defaultValue, String label, Locale locale, int maxFractionDigits)
Constructs the field.- Parameters:
defaultValue- Default value.label- Label accompanying the field.locale- Locale to use for formatting.maxFractionDigits- Maximum number of fraction digits allowed (overwrites setting found inlocale.
-
-
Method Detail
-
setDecimalFormat
public void setDecimalFormat(DecimalFormat format)
Description copied from class:AbstractSuperNumberFieldSets 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.- Overrides:
setDecimalFormatin classAbstractSuperNumberField<BigDecimal,SuperBigDecimalField>- Parameters:
format-DecimalFormatto use. Whennull,NumberFormat.getNumberInstance()will be used.
-
buildRegularExpression
protected StringBuilder buildRegularExpression(StringBuilder builder, DecimalFormat format)
Description copied from class:AbstractSuperNumberFieldBuilds regular expression that allows neat typing of the number already formatted. Overwrite with care.- Overrides:
buildRegularExpressionin classAbstractSuperNumberField<BigDecimal,SuperBigDecimalField>- Parameters:
builder- Builder, initially empty.format- Information about the format.- Returns:
- Builder with the regular expression.
-
isScientificNotationEnabled
public final boolean isScientificNotationEnabled()
Checks whether scientific notation input is supported (by default it is not).- Returns:
truewhengetExponentSeparator()is defined andgetMaximumExponentDigits()is greater than zero,falseotherwise.
-
parseRawValue
protected BigDecimal parseRawValue(String rawValue, DecimalFormat format) throws ParseException
Description copied from class:AbstractSuperNumberFieldParses (somewhat) raw value from the text field into a proper typed value.- Specified by:
parseRawValuein classAbstractSuperNumberField<BigDecimal,SuperBigDecimalField>- Parameters:
rawValue- Value from text field.format- Format to use.- Returns:
- Parsed value.
- Throws:
ParseException- When parsing goes wrong.
-
updateFieldValue
protected void updateFieldValue()
Description copied from class:AbstractSuperNumberFieldThis method is called when the field loses its focus. Do not overwrite it without a very good reason.- Overrides:
updateFieldValuein classAbstractSuperNumberField<BigDecimal,SuperBigDecimalField>
-
setMaximumExponentDigits
public void setMaximumExponentDigits(int maximumExponentDigits)
Sets maximum allowed digits in exponent. If this number is greater than zero, it enables scientific notation input.- Parameters:
maximumExponentDigits- Number of digits allowed in the exponent part of scientific notation.- See Also:
isScientificNotationEnabled()
-
getMaximumExponentDigits
public int getMaximumExponentDigits()
Returns the number of allowed digits in exponent.- Returns:
- Number of digits. Values of zero or less indicate that scientific notation input is not enabled.
-
withMaximumExponentDigits
public final SuperBigDecimalField withMaximumExponentDigits(int maximumExponentDigits)
ChainssetMaximumExponentDigits(int)and returns itself.- Parameters:
maximumExponentDigits- Number of digits allowed in the exponent part of scientific notation.- Returns:
- This.
- See Also:
setMaximumExponentDigits(int)
-
getMaximumSignificandIntegerDigits
public int getMaximumSignificandIntegerDigits()
Returns the maximum number of digits allowed in the integer part of the significand in the scientific notation.- Returns:
- The number of digits. It will never be more than
AbstractSuperNumberField.getMaximumIntegerDigits(). - See Also:
AbstractSuperNumberField.getMaximumIntegerDigits()
-
setMaximumSignificandIntegerDigits
public void setMaximumSignificandIntegerDigits(int maximumSignificandIntegerDigits)
Sets the number of digits allowed in the integer part of the significand in the scientific notation.- Parameters:
maximumSignificandIntegerDigits- The number of digits. The lesser value of this number andAbstractSuperNumberField.getMaximumIntegerDigits()will be used.
-
withMaximumSignificandIntegerDigits
public final SuperBigDecimalField withMaximumSignificandIntegerDigits(int maximumSignificandIntegerDigits)
ChainssetMaximumSignificandIntegerDigits(int)and returns itself.- Parameters:
maximumSignificandIntegerDigits- The number of digits allowed in the integer part of the significand.- Returns:
- This.
- See Also:
setMaximumSignificandIntegerDigits(int)
-
getMaximumSignificandFractionDigits
public int getMaximumSignificandFractionDigits()
Returns the maximum number of digits allowed in the fractional (decimal) part of the significand in the scientific notation.- Returns:
- The number of digits. It will never be more than
AbstractSuperNumberField.getMaximumFractionDigits(). - See Also:
AbstractSuperNumberField.getMaximumFractionDigits()
-
setMaximumSignificandFractionDigits
public void setMaximumSignificandFractionDigits(int maximumSignificandFractionDigits)
Sets the number of digits allowed in the fractional (decimal) part of the significand in the scientific notation.- Parameters:
maximumSignificandFractionDigits- The number of digits. The lesser value of this number andAbstractSuperNumberField.getMaximumFractionDigits()will be used.
-
withMaximumSignificandFractionDigits
public final SuperBigDecimalField withMaximumSignificandFractionDigits(int maximumSignificandFractionDigits)
ChainssetMaximumSignificandFractionDigits(int)and returns itself.- Parameters:
maximumSignificandFractionDigits- The number of digits allowed in the fraction (decimal) part of the significand.- Returns:
- This.
- See Also:
setMaximumSignificandFractionDigits(int)
-
getExponentSeparator
public char getExponentSeparator()
Returns the current exponent separator in the scientific notation. Both cases (according toAbstractSuperNumberField.getLocale()of this character are supported.- Returns:
- A character that serves as a separator in scientific notation.
-
setExponentSeparator
public void setExponentSeparator(char exponentSeparator)
Sets the exponent separator. Both cases (according toAbstractSuperNumberField.getLocale()) of the character will be supported.- Parameters:
exponentSeparator- A character to use. Setting this to0will disable scientific notation support.- See Also:
isScientificNotationEnabled()
-
withExponentSeparator
public final SuperBigDecimalField withExponentSeparator(char exponentSeparator)
ChainssetExponentSeparator(char)and returns itself.- Parameters:
exponentSeparator- A character to use as exponent separator in scientific notation.- Returns:
- This.
- See Also:
setExponentSeparator(char)
-
isNegativeExponentAllowed
public boolean isNegativeExponentAllowed()
Checks whether or not negative exponent is allowed when entering number in scientific notation.- Returns:
true(default) when the exponent part can be negative number,falseotherwise.
-
setNegativeExponentAllowed
public void setNegativeExponentAllowed(boolean negativeExponentAllowed)
Allows or disallows the exponent in scientific notation to be negative.- Parameters:
negativeExponentAllowed- Whether or not the exponent can be negative.
-
withNegativeExponentAllowed
public final SuperBigDecimalField withNegativeExponentAllowed(boolean negativeExponentAllowed)
ChainssetNegativeExponentAllowed(boolean)and returns itself.- Parameters:
negativeExponentAllowed- Whether or not the exponent can be negative.- Returns:
- This.
- See Also:
setNegativeExponentAllowed(boolean)
-
-