Interface ComponentSupport

All Known Implementing Classes:
FlowComponentsSupport

public interface ComponentSupport
Teaches the mocked environment about specific component types, so the environment itself only depends on Flow.

The component tree walk, the pretty printer, the dialog clean-up and the label, caption and data provider lookups ask every registered implementation before falling back to what Flow alone can tell. The label lookup is the exception: a component's own HasLabel label wins, so getLabel(Component) is only asked for components that don't implement it. An implementation is registered with ServiceLoader, in META-INF/services/com.vaadin.browserless.internal.ComponentSupport. Every method has a default that handles nothing, so an implementation only overrides what its components need.

Implementations are consulted in ServiceLoader order. For getAllChildren(Component), getDataProvider(Component), getLabel(Component) and getCaption(Component) the first implementation that handles the component wins. The other methods combine the answers of all implementations: isClosedDialog(Component) and firesClosedEvent(Component) apply if any implementation returns true, getDialogTypes() uses the types of all implementations together, and describe(Component, List) lets every implementation add its details.

This is an internal extension point and may change without notice.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    describe(com.vaadin.flow.component.Component component, List<String> description)
    Adds component-specific details to the one-line description produced by PrettyPrintTree.toPrettyString(Component).
    default boolean
    firesClosedEvent(com.vaadin.flow.component.Component component)
    Checks whether the component is an overlay whose client-side part fires a closed DOM event once it has closed, which the mocked environment then simulates.
    default List<com.vaadin.flow.component.Component>
    getAllChildren(com.vaadin.flow.component.Component component)
    Returns all children of the component as seen by component lookups, including the ones that are not part of the regular component hierarchy, such as a Grid's header components.
    default String
    getCaption(com.vaadin.flow.component.Component component)
    Returns the caption of a component that shows it directly on itself, such as a button's text.
    default com.vaadin.flow.data.provider.DataProvider<?,?>
    getDataProvider(com.vaadin.flow.component.Component component)
    Returns the data provider currently set to the component.
    default Collection<Class<? extends com.vaadin.flow.component.Component>>
    Returns the dialog types that Locator._expectNoDialogs() checks for.
    default String
    getLabel(com.vaadin.flow.component.Component component)
    Returns the label of a component that doesn't implement HasLabel.
    default boolean
    isClosedDialog(com.vaadin.flow.component.Component component)
    Checks whether the component is a closed dialog that a browser would have removed from the DOM after closing it.
  • Method Details

    • getAllChildren

      default List<com.vaadin.flow.component.Component> getAllChildren(com.vaadin.flow.component.Component component)
      Returns all children of the component as seen by component lookups, including the ones that are not part of the regular component hierarchy, such as a Grid's header components.
      Parameters:
      component - the component, not null.
      Returns:
      the children, or null if this implementation doesn't handle the component.
    • isClosedDialog

      default boolean isClosedDialog(com.vaadin.flow.component.Component component)
      Checks whether the component is a closed dialog that a browser would have removed from the DOM after closing it. Such components are removed from the UI after every round trip. The component is removed if any implementation returns true.
      Parameters:
      component - the component, not null.
      Returns:
      true if the component should be removed.
    • getDialogTypes

      default Collection<Class<? extends com.vaadin.flow.component.Component>> getDialogTypes()
      Returns the dialog types that Locator._expectNoDialogs() checks for. The types of all implementations are checked together.
      Returns:
      the dialog types, not null.
    • firesClosedEvent

      default boolean firesClosedEvent(com.vaadin.flow.component.Component component)
      Checks whether the component is an overlay whose client-side part fires a closed DOM event once it has closed, which the mocked environment then simulates. The event is simulated if any implementation returns true.
      Parameters:
      component - the component, not null.
      Returns:
      true if the closed event should be simulated.
    • describe

      default void describe(com.vaadin.flow.component.Component component, List<String> description)
      Adds component-specific details to the one-line description produced by PrettyPrintTree.toPrettyString(Component). Every implementation is asked, in order.
      Parameters:
      component - the component, not null.
      description - the description parts collected so far, to add to.
    • getDataProvider

      default com.vaadin.flow.data.provider.DataProvider<?,?> getDataProvider(com.vaadin.flow.component.Component component)
      Returns the data provider currently set to the component.
      Parameters:
      component - the component, not null.
      Returns:
      the data provider, or null if this implementation doesn't handle the component or none is set.
    • getLabel

      default String getLabel(com.vaadin.flow.component.Component component)
      Returns the label of a component that doesn't implement HasLabel.
      Parameters:
      component - the component, not null.
      Returns:
      the label, an empty string if the component has none, or null if this implementation doesn't handle the component.
    • getCaption

      default String getCaption(com.vaadin.flow.component.Component component)
      Returns the caption of a component that shows it directly on itself, such as a button's text.
      Parameters:
      component - the component, not null.
      Returns:
      the caption, or null if this implementation doesn't handle the component.