Interface HasWidgets

All Superinterfaces:
Serializable
All Known Implementing Classes:
Dashboard, DashboardSection

public interface HasWidgets extends Serializable
HasWidgets is an interface for components that can contain and manage multiple DashboardWidget instances. It defines methods for adding, removing, and accessing widgets within a component.
Author:
Vaadin Ltd
See Also:
  • Method Details

    • getWidgets

      List<DashboardWidget> getWidgets()
      Returns the widgets in this component.
      Returns:
      The widgets in this component
    • add

      default void add(DashboardWidget... widgets)
      Adds the given widgets to this component.
      Parameters:
      widgets - the widgets to add, not null
    • add

      void add(Collection<DashboardWidget> widgets)
      Adds the given widgets to this component.
      Parameters:
      widgets - the widgets to add, not null
    • addWidgetAtIndex

      void addWidgetAtIndex(int index, DashboardWidget widget)
      Adds the given widget as child of this component at the specific index.

      In case the specified widget has already been added to another parent, it will be removed from there and added to this one.

      Parameters:
      index - the index, where the widget will be added. The index must be non-negative and may not exceed the children count
      widget - the widget to add, not null
    • addWidgetAfter

      void addWidgetAfter(DashboardWidget referenceWidget, DashboardWidget newWidget)
      Adds the given widget immediately after the reference widget.

      If the reference widget is located within a section, the new widget will be added to the same section, positioned after the reference widget. If the reference widget is at the root level of the dashboard, the new widget will be added at the root level, positioned after the reference widget.

      In case the new widget has already been added to another parent, it will be removed from there and added to the appropriate location.

      Parameters:
      referenceWidget - the widget after which the new widget will be added, not null
      newWidget - the widget to add, not null
      Throws:
      IllegalArgumentException - if the reference widget is not found in this component or any of its sections
    • remove

      default void remove(DashboardWidget... widgets)
      Removes the given widgets from this component.
      Parameters:
      widgets - the widgets to remove, not null
      Throws:
      IllegalArgumentException - if there is a widget whose non null parent is not this component
    • remove

      void remove(Collection<DashboardWidget> widgets)
      Removes the given widgets from this component.
      Parameters:
      widgets - the widgets to remove, not null
      Throws:
      IllegalArgumentException - if there is a widget whose non null parent is not this component
    • removeAll

      void removeAll()
      Removes all widgets from this component.