com.vaadin.flow.router.

Class EventUtil

java.lang.Object
com.vaadin.flow.router.EventUtil
public final class EventUtil extends Object

Event handling utilities.

Since:

1.0

Author:

Vaadin Ltd

  • Method Details

    • collectBeforeEnterObservers

      public static List<BeforeEnterObserver> collectBeforeEnterObservers(Collection<? extends HasElement> oldChain, Collection<? extends HasElement> newChain)

      Collect before enter observer instances based on what will be attached when a new view chain is applied. Because components in the new chain might still have children that will yet be detached, the old chain is also needed in order to exclude anything that is only in the old chain but missing from the new chain.

      Parameters:

      oldChain - the view chain prior to the navigation

      newChain - the view chain after the navigation

      Returns:

      list of found BeforeEnterObservers

    • collectBeforeEnterObserversFromChain

      public static List<BeforeEnterObserver> collectBeforeEnterObserversFromChain(Collection<? extends HasElement> chain, Collection<? extends HasElement> childrenExclusions)

      Collect before enter observer instances based on what will be attached when a new view chain is applied.

      Parameters:

      chain - the view chain after the navigation

      childrenExclusions - any children of any element in the chain input that is found in this collection will be excluded from the result

      Returns:

      list of found BeforeEnterObservers in the chain tree.

    • collectBeforeEnterObserversFromChainElement

      public static List<BeforeEnterObserver> collectBeforeEnterObserversFromChainElement(HasElement element, Collection<? extends HasElement> childrenExclusions)

      Collect before enter observer instances in the element's hierarchy.

      Parameters:

      element - an element

      childrenExclusions - any children of the element input that is found in this collection will be excluded from the result

      Returns:

      list of found BeforeEnterObservers in the element hierarchy tree.

    • collectBeforeLeaveObservers

      public static List<BeforeLeaveObserver> collectBeforeLeaveObservers(UI ui)

      Collect all Components implementing BeforeLeaveObserver connected to the given UI.

      Parameters:

      ui - UI to search from

      Returns:

      navigation listeners

    • collectAfterNavigationObservers

      public static List<AfterNavigationObserver> collectAfterNavigationObservers(UI ui)

      Collect all Components implementing AfterNavigationObserver that are found in the given UI.

      Parameters:

      ui - UI to search from

      Returns:

      after navigation listeners

    • collectLocaleChangeObservers

      public static List<LocaleChangeObserver> collectLocaleChangeObservers(Element element)

      Collect all Components implementing LocaleChangeObserver connected to the given element tree.

      Parameters:

      element - element to search from

      Returns:

      navigation listeners

    • collectLocaleChangeObservers

      public static List<LocaleChangeObserver> collectLocaleChangeObservers(List<HasElement> components)

      Collect all Components implementing LocaleChangeObserver connected to the tree of all given Components in list.

      Parameters:

      components - components to search

      Returns:

      navigation listeners

    • informLocaleChangeObservers

      public static void informLocaleChangeObservers(UI ui)

      Inform components connected to the given ui that implement LocaleChangeObserver about locale change.

      Parameters:

      ui - UI for locale change

    • informLocaleChangeObservers

      public static void informLocaleChangeObservers(UI ui, List<HasElement> components)

      Inform components implementing LocaleChangeObserver about locale change.

      Parameters:

      ui - UI for locale change

      components - components to search

    • getImplementingComponents

      public static <T> Stream<T> getImplementingComponents(Stream<Element> elementStream, Class<T> type)

      Collect elements with Component implementing listener of type T.

      Type Parameters:

      T - type that is used in filtering

      Parameters:

      elementStream - collected elements

      type - class type to filter by

      Returns:

      stream of components implementing T

    • inspectHierarchy

      public static void inspectHierarchy(Element node, Collection<Element> descendants, Predicate<Element> filter)

      Collect all children for given node as a Element stream.

      Parameters:

      node - start node to collect child elements from

      descendants - a collector of descendants to fill

      filter - predicate to check whether a given element and its descendants should be included