Class SimpleButtonState

java.lang.Object
org.vaadin.miki.superfields.buttons.SimpleButtonState
All Implemented Interfaces:
Serializable, HasComponentAsIcon, HasText, WithComponentAsIconMixin<SimpleButtonState>, WithTextMixin<SimpleButtonState>, ButtonState

public class SimpleButtonState extends Object implements ButtonState, WithComponentAsIconMixin<SimpleButtonState>, WithTextMixin<SimpleButtonState>
See Also:
  • Constructor Details

    • SimpleButtonState

      public SimpleButtonState()
      Creates a completely blank state.
    • SimpleButtonState

      public SimpleButtonState(String text, String... classNames)
      Creates button state with corresponding text.
      Parameters:
      text - Text.
      classNames - Optional style class names associated with this state.
    • SimpleButtonState

      public SimpleButtonState(com.vaadin.flow.component.Component icon, String... classNames)
      Creates button state with corresponding icon.
      Parameters:
      icon - A Component to use as an icon.
      classNames - Optional style class names associated with this state.
    • SimpleButtonState

      public SimpleButtonState(String text, com.vaadin.flow.component.Component icon, String... classNames)
      Creates button state.
      Parameters:
      text - Text.
      icon - A Component to use as an icon.
      classNames - Optional style class names associated with this state.
  • Method Details

    • forTexts

      public static List<ButtonState> forTexts(String... texts)
      Turns given texts into corresponding ButtonStates, one for each text.
      Parameters:
      texts - Texts to produce ButtonStates for.
      Returns:
      A non-null list of ButtonStates.
    • getText

      public String getText()
      Description copied from interface: ButtonState
      Returns current text of the button.
      Specified by:
      getText in interface ButtonState
      Specified by:
      getText in interface HasText
      Returns:
      Text.
    • setText

      public void setText(String text)
      Description copied from interface: HasText
      Sets text of this object.
      Specified by:
      setText in interface HasText
      Parameters:
      text - Text to set.
    • getIcon

      public com.vaadin.flow.component.Component getIcon()
      Description copied from interface: ButtonState
      Returns current icon of the button.
      Specified by:
      getIcon in interface ButtonState
      Specified by:
      getIcon in interface HasComponentAsIcon
      Returns:
      Icon.
    • setIcon

      public void setIcon(com.vaadin.flow.component.Component icon)
      Description copied from interface: HasComponentAsIcon
      Sets given Component as an icon of this object.
      Specified by:
      setIcon in interface HasComponentAsIcon
      Parameters:
      icon - A Component to be used as an icon. Can be null to clear current icon.
    • addClassName

      public void addClassName(String... classNames)
      Adds given style class names to this state.
      Parameters:
      classNames - Style class names to be associated with this state. If a style class name already exists, it is ignored.
    • removeClassName

      public void removeClassName(String... classNames)
      Removes given style class names from this state.
      Parameters:
      classNames - Style class names to be removed from this state. If a style class name is not present, nothing happens.
    • getClassNames

      public Set<String> getClassNames()
      Description copied from interface: ButtonState
      Returns current (ordered) set of style class names associated with this state.
      Specified by:
      getClassNames in interface ButtonState
      Returns:
      An ordered set of style class names. Changes to the returned object affect this object.
    • withClassName

      public SimpleButtonState withClassName(String... classNames)
      Chains addClassName(String...) and returns itself.
      Parameters:
      classNames - Style class names to add.
      Returns:
      This.
    • withoutClassName

      public SimpleButtonState withoutClassName(String... classNames)
      Chains removeClassName(String...) and returns itself.
      Parameters:
      classNames - Style class names to remove.
      Returns:
      This.
    • addThemeName

      public void addThemeName(String... themeNames)
      Adds given theme names to this state.
      Parameters:
      themeNames - Theme names to be associated with this state. If a theme name already exists, it is ignored.
    • removeThemeName

      public void removeThemeName(String... themeNames)
      Removes given theme names from this state.
      Parameters:
      themeNames - Theme names to be removed from this state. If a theme name is not present, nothing happens.
    • getThemeNames

      public Set<String> getThemeNames()
      Description copied from interface: ButtonState
      Returns current (ordered) set of theme names associated with this state.
      Specified by:
      getThemeNames in interface ButtonState
      Returns:
      An ordered set of theme names. Changes to the returned object affect this object.
    • withThemeName

      public SimpleButtonState withThemeName(String... themeNames)
      Chains addThemeName(String...) and returns itself.
      Parameters:
      themeNames - Theme names to add.
      Returns:
      This.
    • withoutThemeName

      public SimpleButtonState withoutThemeName(String... themeNames)
      Chains removeThemeName(String...) and returns itself.
      Parameters:
      themeNames - Names to remove.
      Returns:
      This.
    • addThemeVariant

      public void addThemeVariant(com.vaadin.flow.component.button.ButtonVariant... variants)
      Adds given theme variants to this state.
      Parameters:
      variants - Theme variants to be associated with this state. If a theme variant already exists, it is ignored.
    • removeThemeVariant

      public void removeThemeVariant(com.vaadin.flow.component.button.ButtonVariant... variants)
      Removes given theme variants from this state.
      Parameters:
      variants - Theme variants to be removed from this state. If a variant is not present, nothing happens.
    • getThemeVariants

      public Set<com.vaadin.flow.component.button.ButtonVariant> getThemeVariants()
      Description copied from interface: ButtonState
      Returns current (ordered) set of theme variants associated with this state.
      Specified by:
      getThemeVariants in interface ButtonState
      Returns:
      An ordered set of theme variants. Changes to the returned object affect this object.
    • withThemeVariant

      public SimpleButtonState withThemeVariant(com.vaadin.flow.component.button.ButtonVariant... variants)
      Chains addThemeVariant(ButtonVariant...) and returns itself.
      Parameters:
      variants - Variants to add.
      Returns:
      This.
    • withoutThemeVariant

      public SimpleButtonState withoutThemeVariant(com.vaadin.flow.component.button.ButtonVariant... variants)
      Chains removeThemeVariant(ButtonVariant...) and returns itself.
      Parameters:
      variants - Variants to remove.
      Returns:
      This.
    • copy

      public ButtonState copy()
      Returns a deep copy of this object.
      Returns:
      A copy of this object. Changes to the copy do not affect this object.