Interface HasTheme

All Superinterfaces:
HasElement, Serializable

public interface HasTheme extends HasElement
Represents Component which has theme attribute.

Implementation of HasElement.getElement() may return any type of element.

Since:
1.0
Author:
Vaadin Ltd
  • Method Details

    • addThemeName

      default void addThemeName(String themeName)
      Adds a theme name to this component.
      Parameters:
      themeName - the theme name to add, not null
    • removeThemeName

      default boolean removeThemeName(String themeName)
      Removes a theme name from this component.
      Parameters:
      themeName - the theme name to remove, not null
      Returns:
      true if the theme name was removed, false if the theme list didn't contain the theme name
    • setThemeName

      default void setThemeName(String themeName)
      Sets the theme names of this component. This method overwrites any previous set theme names.
      Parameters:
      themeName - a space-separated string of theme names to set, or empty string to remove all theme names
    • getThemeName

      default String getThemeName()
      Gets the theme names for this component.
      Returns:
      a space-separated string of theme names, empty string if there are no theme names or null if attribute (theme) is not set at all
    • getThemeNames

      default ThemeList getThemeNames()
      Gets the set of theme names used for this element. The returned set can be modified to add or remove theme names. The contents of the set is also reflected in the value of the theme attribute.
      Returns:
      a list of theme names, never null
      See Also:
    • setThemeName

      default void setThemeName(String themeName, boolean set)
      Sets or removes the given theme name for this component.
      Parameters:
      themeName - the theme name to set or remove, not null
      set - true to set the theme name, false to remove it
    • hasThemeName

      default boolean hasThemeName(String themeName)
      Checks if the component has the given theme name.
      Parameters:
      themeName - the theme name to check for
      Returns:
      true if the component has the given theme name, false otherwise
    • addThemeNames

      default void addThemeNames(String... themeNames)
      Adds one or more theme names to this component. Multiple theme names can be specified by using multiple parameters.
      Parameters:
      themeNames - the theme name or theme names to be added to the component
    • removeThemeNames

      default void removeThemeNames(String... themeNames)
      Removes one or more theme names from component. Multiple theme names can be specified by using multiple parameters.
      Parameters:
      themeNames - the theme name or theme names to be removed from the component
    • bindThemeName

      default SignalBinding<Boolean> bindThemeName(String name, Signal<Boolean> signal)
      Binds the presence of the given theme name to the provided signal so that the theme name is added when the signal value is true and removed when the value is false.

      Passing null as the signal removes any existing binding for the given theme name. When unbinding, the current presence of the theme name is left unchanged.

      While a binding for the given theme name is active, manual calls to addThemeName(String), removeThemeName(String), setThemeName(String, boolean), addThemeNames(String...), removeThemeNames(String...) or equivalents in ThemeList for that name will throw a BindingActiveException. Bindings are lifecycle-aware and only active while the owning Element is in attached state; they are deactivated while the element is in detached state.

      Bulk operations that indiscriminately replace or clear the theme list (for example Set.clear() or setting the theme attribute via setThemeName(String)) clear all bindings.

      Parameters:
      name - the theme name to bind, not null or blank
      signal - the boolean signal to bind to, not null
      Throws:
      BindingActiveException - thrown when there is already an existing binding
      Since:
      25.1
    • bindThemeNames

      default SignalBinding<List<String>> bindThemeNames(Signal<List<String>> names)
      Binds the theme names of this component to a Signal so that the theme list is dynamically updated to match the signal's value. Only one group binding is allowed per component.

      The group binding coexists with static values and individual toggle bindings. Names that appear in both sources may appear as duplicates in the theme attribute.

      Parameters:
      names - the signal providing the list of theme names, not null
      Since:
      25.1
      See Also: