Class TabbedDemo

All Implemented Interfaces:
AttachNotifier, ClickNotifier<VerticalLayout>, DetachNotifier, HasComponents, HasElement, HasEnabled, HasOrderedComponents, HasSize, HasStyle, FlexComponent, ThemableLayout, RouterLayout, Serializable

@StyleSheet("context://frontend/styles/commons-demo/shared-styles.css") @CssImport(value="./styles/commons-demo/vaadin-select-overlay.css", themeFor="vaadin-select") public class TabbedDemo extends VerticalLayout implements RouterLayout
A layout for displaying a tabbed demo with source code integration.

This layout consists of a set of tabs for navigating between different demos, a content area for displaying the current demo, and a footer with controls for toggling the source code visibility, orientation, and theme.

See Also:
  • Constructor Details

    • TabbedDemo

      public TabbedDemo()
      Constructs a new TabbedDemo instance.
  • Method Details

    • addDemo

      public void addDemo(Class<? extends Component> clazz, String label)
      Add a tab with a demo component.
      Parameters:
      clazz - the class of routed demo view component
      label - the demo name (tab label)
      Throws:
      IllegalArgumentException - if the class is not annotated with Route
    • setAutoVisibility

      public void setAutoVisibility(boolean autoVisibility)
      Sets the autovisibility mode. When autovisibility is enabled, the tabs component is hidden unless it contains two or more tabs.
      Parameters:
      autoVisibility - true to enable autovisibility, false to disable it
    • addDemo

      public void addDemo(Class<? extends Component> clazz)
      Add a tab with a demo component. The tab label is retrieved from the PageTitle annotations in the demo class.
      Parameters:
      clazz - the class of routed demo view component
    • showRouterLayoutContent

      public void showRouterLayoutContent(HasElement content)
      Specified by:
      showRouterLayoutContent in interface RouterLayout
    • configureSourceUrlResolver

      public static void configureSourceUrlResolver(@NonNull @NonNull SourceUrlResolver resolver)
      Configures the SourceUrlResolver for resolving source URLs. This method can only be called once; subsequent calls will result in an exception.
      Parameters:
      resolver - The SourceUrlResolver to be used. Must not be null.
      Throws:
      IllegalStateException - if a resolver has already been set.
      NullPointerException - if the provided resolver is null.
    • lookupGithubBranch

      public static String lookupGithubBranch(Class<? extends TabbedDemo> clazz)
      Looks up the GitHub branch name associated with the given TabbedDemo class.
      Parameters:
      clazz - the TabbedDemo class to inspect
      Returns:
      the GitHub branch name, or "master" if the annotation is not found
    • removeRouterLayoutContent

      public void removeRouterLayoutContent(HasElement oldContent)
      Specified by:
      removeRouterLayoutContent in interface RouterLayout
    • setSourceVisible

      public void setSourceVisible(boolean visible)
      Sets the visibility of the source code.
      Parameters:
      visible - true to make the source code visible, false otherwise
    • toggleSourcePosition

      public void toggleSourcePosition()
      Toggles the position of the source code relative to the demo content.
    • getOrientation

      public SplitLayout.Orientation getOrientation()
      Returns the current orientation of the split layout.
      Returns:
      the current orientation
    • setOrientation

      public void setOrientation(SplitLayout.Orientation orientation)
      Sets the orientation of the split layout.
      Parameters:
      orientation - the new orientation
    • getThemeAttribute

      @Deprecated public static String getThemeAttribute()
      Deprecated.
      Returns the theme attribute value.

      The "theme attribute" is either an empty string (light) or "dark".

      Returns:
      the theme attribute value
    • getColorScheme

      public static ColorScheme getColorScheme()
      Returns the current color scheme.
      Returns:
      the current color scheme
    • applyThemeAttribute

      @Deprecated public static void applyThemeAttribute(Element element, String theme)
      Applies the theme attribute to the given element.

      The "theme attribute" is either an empty string (light) or "dark".

      Parameters:
      element - the element to apply the theme to
      theme - the theme attribute value
    • setColorScheme

      public static void setColorScheme(Component component, @NonNull @NonNull ColorScheme colorScheme)
      Sets the color scheme for the given component.
      Parameters:
      component - the component to apply the color scheme to
      colorScheme - the color scheme to apply
    • addTabbedDemoSourceListener

      public void addTabbedDemoSourceListener(ComponentEventListener<TabbedDemoSourceEvent> listener)
      Adds a listener for TabbedDemoSourceEvent.
      Parameters:
      listener - the listener to add
    • onAttach

      protected void onAttach(AttachEvent attachEvent)
      Overrides:
      onAttach in class Component
    • setDemoHelperViewer

      public void setDemoHelperViewer(DemoHelperViewer demoHelperViewer)
      Sets the DemoHelperViewer to be used for displaying demo helpers.
      Parameters:
      demoHelperViewer - the viewer to set