com.vaadin.flow.router.
Class EventUtil
Event handling utilities.
Since:
1.0
Author:
Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<AfterNavigationObserver>
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<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.
static List<BeforeEnterObserver>
collectBeforeEnterObserversFromChainElement
(HasElement element, Collection<? extends HasElement> childrenExclusions) Collect before enter observer instances in the
element
's hierarchy.static List<BeforeLeaveObserver>
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
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 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 navigationnewChain
- the view chain after the navigationReturns:
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 navigationchildrenExclusions
- any children of any element in the chain input that is found in this collection will be excluded from the resultReturns:
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 elementchildrenExclusions
- any children of the element input that is found in this collection will be excluded from the resultReturns:
list of found BeforeEnterObservers in the element hierarchy tree.
-
collectBeforeLeaveObservers
Collect all Components implementing
BeforeLeaveObserver
connected to the given UI.Parameters:
ui
- UI to search fromReturns:
navigation listeners
-
collectLocaleChangeObservers
Collect all Components implementing
LocaleChangeObserver
connected to the given element tree.Parameters:
element
- element to search fromReturns:
navigation listeners
-
collectLocaleChangeObservers
Collect all Components implementing
LocaleChangeObserver
connected to the tree of all given Components in list.Parameters:
components
- components to searchReturns:
navigation listeners
-
informLocaleChangeObservers
Inform components connected to the given ui that implement
LocaleChangeObserver
about locale change.Parameters:
ui
- UI for locale change -
informLocaleChangeObservers
Inform components implementing
LocaleChangeObserver
about locale change.Parameters:
ui
- UI for locale changecomponents
- components to search -
getImplementingComponents
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
-