Class Dashboard

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.dashboard.Dashboard
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, HasWidgets, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, HasThemeVariant<DashboardVariant>, Serializable

@Tag("vaadin-dashboard") @JsModule("@vaadin/dashboard/src/vaadin-dashboard.js") @JsModule("./flow-component-renderer.js") @NpmPackage(value="@vaadin/dashboard", version="25.0.0-alpha19") public class Dashboard extends com.vaadin.flow.component.Component implements HasWidgets, com.vaadin.flow.component.HasSize, HasThemeVariant<DashboardVariant>
Dashboard is a responsive layout component that allows users to organize widgets either directly within the dashboard or optionally group them into sections. The component supports customizable layout options like maximum column count.

Internationalization (i18n) is supported through Dashboard.DashboardI18n, allowing customization of accessible names for the dashboard controls. The i18n object can be set using setI18n(DashboardI18n).

Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • Dashboard

      public Dashboard()
      Creates an empty dashboard.
  • Method Details

    • addSection

      public DashboardSection addSection()
      Adds an empty section to this dashboard.
    • addSection

      public DashboardSection addSection(String title)
      Adds an empty section to this dashboard.
      Parameters:
      title - the title of the section
    • addSection

      public void addSection(DashboardSection section)
      Adds the given section to this dashboard.
      Parameters:
      section - the widgets to add, not null
    • getWidgets

      public List<DashboardWidget> getWidgets()
      Returns a flattened list of all the widgets in this dashboard. This includes the nested widgets in sections.
      Specified by:
      getWidgets in interface HasWidgets
      Returns:
      The flattened list of all widgets in this dashboard
    • add

      public void add(Collection<DashboardWidget> widgets)
      Description copied from interface: HasWidgets
      Adds the given widgets to this component.
      Specified by:
      add in interface HasWidgets
      Parameters:
      widgets - the widgets to add, not null
    • addWidgetAtIndex

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

      The index specifies the intended position within the root item list returned by getChildren(). It should not be used with getWidgets() since the position in the flattened widget list returned by getWidgets() might not match the intended position.

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

      Specified by:
      addWidgetAtIndex in interface HasWidgets
      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
      See Also:
    • remove

      public void remove(Collection<DashboardWidget> widgets)
      Description copied from interface: HasWidgets
      Removes the given widgets from this component.
      Specified by:
      remove in interface HasWidgets
      Parameters:
      widgets - the widgets to remove, not null
    • remove

      public void remove(DashboardSection section)
      Removes the given section from this component.
      Parameters:
      section - the section to remove, not null
      Throws:
      IllegalArgumentException - if the non null parent of the section is not this component
    • removeAll

      public void removeAll()
      Removes all widgets and sections from this component.
      Specified by:
      removeAll in interface HasWidgets
    • getMaximumColumnCount

      public Integer getMaximumColumnCount()
      Returns the maximum column count of the dashboard.
      Returns:
      the maximum column count of the dashboard
    • setMaximumColumnCount

      public void setMaximumColumnCount(Integer maxColCount)
      Sets the maximum column count of the dashboard.
      Parameters:
      maxColCount - the new maximum column count. Pass in null to set the maximum column count back to the default value.
    • getMinimumColumnWidth

      public String getMinimumColumnWidth()
      Returns the minimum column width of the dashboard.
      Returns:
      the minimum column width of the dashboard
    • setMinimumColumnWidth

      public void setMinimumColumnWidth(String minColWidth)
      Sets the minimum column width of the dashboard.
      Parameters:
      minColWidth - the new minimum column width. Pass in null to set the minimum column width back to the default value.
    • getMaximumColumnWidth

      public String getMaximumColumnWidth()
      Returns the maximum column width of the dashboard.
      Returns:
      the maximum column width of the dashboard
    • setMaximumColumnWidth

      public void setMaximumColumnWidth(String maxColWidth)
      Sets the maximum column width of the dashboard.
      Parameters:
      maxColWidth - the new maximum column width. Pass in null to set the maximum column width back to the default value.
    • getMinimumRowHeight

      public String getMinimumRowHeight()
      Returns the minimum row height of the dashboard.
      Returns:
      the minimum row height of the dashboard
    • setMinimumRowHeight

      public void setMinimumRowHeight(String minRowHeight)
      Sets the minimum row height of the dashboard.
      Parameters:
      minRowHeight - the new minimum row height. Pass in null to set the minimum row height back to the default value.
    • getGap

      public String getGap()
      Returns the gap of the dashboard. This value adjusts the gap between elements within the dashboard.
      Returns:
      the gap of the dashboard
    • setGap

      public void setGap(String gap)
      Sets the gap of the dashboard. This value adjusts the gap between elements within the dashboard.
      Parameters:
      gap - the new gap. Pass in null to set the gap back to the default value.
    • getPadding

      public String getPadding()
      Returns the padding of the dashboard. This value adjusts the space around the outer edges of the dashboard.
      Returns:
      the padding of the dashboard
    • setPadding

      public void setPadding(String padding)
      Sets the padding of the dashboard. This value adjusts the space around the outer edges of the dashboard.
      Parameters:
      padding - the new padding. Pass in null to set the padding back to the default value.
    • setEditable

      public void setEditable(boolean editable)
      Sets the dashboard editable.
      Parameters:
      editable - whether to set the dashboard editable
    • isEditable

      public boolean isEditable()
      Returns whether the dashboard is editable.
      Returns:
      whether the dashboard is editable
    • setDenseLayout

      public void setDenseLayout(boolean dense)
      Sets the dashboard layout dense.
      Parameters:
      dense - whether to set the dashboard layout dense
    • isDenseLayout

      public boolean isDenseLayout()
      Returns whether the dashboard layout is dense.
      Returns:
      whether the dashboard layout is dense
    • addItemMovedListener

      public com.vaadin.flow.shared.Registration addItemMovedListener(com.vaadin.flow.component.ComponentEventListener<DashboardItemMovedEvent> listener)
      Adds an item moved listener to this dashboard.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addItemResizedListener

      public com.vaadin.flow.shared.Registration addItemResizedListener(com.vaadin.flow.component.ComponentEventListener<DashboardItemResizedEvent> listener)
      Adds an item resized listener to this dashboard.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addItemRemovedListener

      public com.vaadin.flow.shared.Registration addItemRemovedListener(com.vaadin.flow.component.ComponentEventListener<DashboardItemRemovedEvent> listener)
      Adds an item removed listener to this dashboard.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addItemSelectedChangedListener

      public com.vaadin.flow.shared.Registration addItemSelectedChangedListener(com.vaadin.flow.component.ComponentEventListener<DashboardItemSelectedChangedEvent> listener)
      Adds an item selected change listener to this dashboard.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addItemMoveModeChangedListener

      public com.vaadin.flow.shared.Registration addItemMoveModeChangedListener(com.vaadin.flow.component.ComponentEventListener<DashboardItemMoveModeChangedEvent> listener)
      Adds an item move mode change listener to this dashboard.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addItemResizeModeChangedListener

      public com.vaadin.flow.shared.Registration addItemResizeModeChangedListener(com.vaadin.flow.component.ComponentEventListener<DashboardItemResizeModeChangedEvent> listener)
      Adds an item resize mode change listener to this dashboard.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • getI18n

      public Dashboard.DashboardI18n getI18n()
      Gets the internationalization object previously set for this component.

      NOTE: Updating the instance that is returned from this method will not update the component if not set again using setI18n(DashboardI18n)

      Returns:
      the i18n object or null if no i18n object has been set
    • setI18n

      public void setI18n(Dashboard.DashboardI18n i18n)
      Sets the internationalization object for this component.
      Parameters:
      i18n - the i18n object, not null
    • getChildren

      public Stream<com.vaadin.flow.component.Component> getChildren()
      Overrides:
      getChildren in class com.vaadin.flow.component.Component
    • setVisible

      public void setVisible(boolean visible)
      Overrides:
      setVisible in class com.vaadin.flow.component.Component
      Throws:
      UnsupportedOperationException - Dashboard does not support setting visibility
    • isVisible

      public boolean isVisible()
      Overrides:
      isVisible in class com.vaadin.flow.component.Component
    • setRootHeadingLevel

      public void setRootHeadingLevel(Integer rootHeadingLevel)
      Sets the root heading level used by sections and widgets, which controls their aria-level attributes on title elements. The nested widgets will have their aria-level one higher than the root heading level.

      For example, if root heading level is set to 1:

      • Sections and non-nested widgets will have aria-level="1"
      • Nested widgets will have aria-level="2"
      Setting it null resets it to the default value of 2.
      Parameters:
      rootHeadingLevel - the root heading level property, null to remove
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component