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 Summary
All Methods Modifier and Type Method and Description static List<AfterNavigationObserver>
collectAfterNavigationObservers(UI ui)
Collect all Components implementing
AfterNavigationObserver
that are found in the given UI.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.
static List<BeforeLeaveObserver>
collectBeforeLeaveObservers(UI ui)
Collect all Components implementing
BeforeLeaveObserver
connected to the given UI.static List<LocaleChangeObserver>
collectLocaleChangeObservers(Element element)
Collect all Components implementing
LocaleChangeObserver
connected to the given element tree.static List<LocaleChangeObserver>
collectLocaleChangeObservers(List<HasElement> components)
Collect all Components implementing
LocaleChangeObserver
connected to the tree of all given Components in list.static <T> Stream<T>
getImplementingComponents(Stream<Element> elementStream, Class<T> type)
Collect elements with Component implementing listener of type T.
static void
informLocaleChangeObservers(UI ui)
Inform components connected to the given ui that implement
LocaleChangeObserver
about locale change.static void
informLocaleChangeObservers(UI ui, List<HasElement> components)
Inform components implementing
LocaleChangeObserver
about locale change.static void
inspectHierarchy(Element node, Collection<Element> descendants, Predicate<Element> filter)
Collect all children for given node as a Element stream.
-
-
-
Method Detail
-
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 navigationnewChain
- the view chain after the navigationReturns:
list of found BeforeEnterObservers
-
collectBeforeLeaveObservers
public static List<BeforeLeaveObserver> collectBeforeLeaveObservers(UI ui)
Collect all Components implementing
BeforeLeaveObserver
connected to the given UI.Parameters:
ui
- UI to search fromReturns:
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 fromReturns:
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 fromReturns:
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 searchReturns:
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 changecomponents
- 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 filteringParameters:
elementStream
- collected elementstype
- class type to filter byReturns:
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 fromdescendants
- a collector of descendants to fillfilter
- predicate to check whether a given element and its descendants should be included
-
-