Class RestrictionCountBadge

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.badge.Badge
com.appjars.view.components.RestrictionCountBadge
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasText, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.badge.BadgeVariant>, Serializable

public class RestrictionCountBadge extends com.vaadin.flow.component.badge.Badge
A badge that displays a restriction count with a maximum and warning threshold.

The badge automatically updates its theme based on the current value:

  • value < warn: default theme
  • warn <= value < max: "warn" theme
  • value == max: "error" theme

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText

    com.vaadin.flow.component.HasText.WhiteSpace
  • Constructor Summary

    Constructors
    Constructor
    Description
    RestrictionCountBadge(String label, long max, long warn)
    Creates a new RestrictionCountBadge.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Sets the label to display before the count.
    void
    setValue(long value)
    Sets the current value and updates the badge text and theme.

    Methods inherited from class com.vaadin.flow.component.badge.Badge

    bindNumber, bindText, getContent, getIcon, getNumber, getRole, getText, onAttach, setContent, setIcon, setNumber, setRole, setText

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, 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.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, 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, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasText

    getWhiteSpace, setWhiteSpace

    Methods inherited from interface com.vaadin.flow.component.HasTheme

    addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName

    Methods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant

    addThemeVariants, bindThemeVariant, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants
  • Constructor Details

    • RestrictionCountBadge

      public RestrictionCountBadge(String label, long max, long warn)
      Creates a new RestrictionCountBadge.
      Parameters:
      label - the label to display before the count
      max - the maximum allowed value
      warn - the warning threshold value
  • Method Details

    • setValue

      public void setValue(long value)
      Sets the current value and updates the badge text and theme.
      Parameters:
      value - the new value
    • setLabel

      public void setLabel(String label)
      Sets the label to display before the count.
      Parameters:
      label - the new label