Package com.vaadin.copilot
Class FlowUtil
java.lang.Object
com.vaadin.copilot.FlowUtil
-
Method Summary
Modifier and TypeMethodDescriptionfindActiveJavaFiles(com.vaadin.flow.server.VaadinSession session, int uiId) Finds all Java files that are used to create the current component tree for the given ui.static Map<com.vaadin.flow.component.Component, ComponentTypeAndSourceLocation> findAllComponents(com.vaadin.flow.server.VaadinSession session, int uiId) static Optional<com.vaadin.flow.component.Component> findComponentByNodeIdAndUiId(com.vaadin.flow.server.VaadinSession vaadinSession, int nodeId, int uiId) Finds the Component instance with givennodeIdin UI withuiIdviaVaadinSession.accessSynchronously(Command)static IntegergetNodeId(com.vaadin.flow.component.Component component) static Optional<com.vaadin.flow.router.RouteData> getRouteData(com.vaadin.flow.server.VaadinSession session, int uiId) getViewChain(com.vaadin.flow.server.VaadinSession session, int uiId) Returns the view chain for the given UI.static booleantestAncestors(com.vaadin.flow.server.VaadinSession session, com.vaadin.flow.component.Component component, Predicate<com.vaadin.flow.component.Component> testPredicate) The method traverses up the component hierarchy, starting from the immediate parent of the given component, and applies the providedPredicateto each ancestor.
-
Method Details
-
findActiveJavaFiles
public static Map<com.vaadin.flow.component.internal.ComponentTracker.Location,File> findActiveJavaFiles(com.vaadin.flow.server.VaadinSession session, int uiId) Finds all Java files that are used to create the current component tree for the given ui.- Parameters:
uiId- the id for the UI, inside the given session- Returns:
- a map of the locations and the corresponding Java files
-
findAllComponents
public static Map<com.vaadin.flow.component.Component,ComponentTypeAndSourceLocation> findAllComponents(com.vaadin.flow.server.VaadinSession session, int uiId) -
getViewChain
public static List<Class<? extends com.vaadin.flow.component.HasElement>> getViewChain(com.vaadin.flow.server.VaadinSession session, int uiId) Returns the view chain for the given UI.- Parameters:
session- the vaadin sessionuiId- the id for the UI, inside the given session- Returns:
- a list of the view classes currently being shown in the UI
-
testAncestors
public static boolean testAncestors(com.vaadin.flow.server.VaadinSession session, com.vaadin.flow.component.Component component, Predicate<com.vaadin.flow.component.Component> testPredicate) The method traverses up the component hierarchy, starting from the immediate parent of the given component, and applies the providedPredicateto each ancestor.The session is locked during traversal
- Parameters:
session- theVaadinSessionto which the component belongs; must not benull.component- theComponentwhose ancestors are to be tested; must not benull.testPredicate- thePredicateused to test each ancestor component; must not benull.- Returns:
trueif any ancestor component satisfies the given predicate,falseotherwise.
-
getNodeId
-
getRouteData
public static Optional<com.vaadin.flow.router.RouteData> getRouteData(com.vaadin.flow.server.VaadinSession session, int uiId) -
findComponentByNodeIdAndUiId
public static Optional<com.vaadin.flow.component.Component> findComponentByNodeIdAndUiId(com.vaadin.flow.server.VaadinSession vaadinSession, int nodeId, int uiId) Finds the Component instance with givennodeIdin UI withuiIdviaVaadinSession.accessSynchronously(Command)- Parameters:
vaadinSession- Vaadin session to access UI elementsnodeId- Node iduiId- ui id- Returns:
- Component or
Optional.empty()
-