protected String getRoute(Screen screen) { RouteDefinition routeDef = getRouteDef(screen); return routeDef == null ? null : routeDef.getPath(); }
protected void registerScreen(String id, WindowInfo windowInfo) { String controllerClassName = windowInfo.getControllerClassName(); if (controllerClassName != null) { MetadataReader classMetadata = loadClassMetadata(controllerClassName); AnnotationMetadata annotationMetadata = classMetadata.getAnnotationMetadata(); registerPrimaryEditor(windowInfo, annotationMetadata); registerPrimaryLookup(windowInfo, annotationMetadata); } screens.put(id, windowInfo); RouteDefinition routeDef = windowInfo.getRouteDefinition(); if (routeDef != null) { String anotherScreenId = routes.get(routeDef.getPath()); if (anotherScreenId != null && !Objects.equals(id, anotherScreenId)) { log.debug("Multiple use of the route '{}' for different screens is detected: '{}' and '{}'. " + "The screen '{}' will be opened during navigation as the last registered screen", routeDef.getPath(), id, anotherScreenId, id); } routes.put(routeDef.getPath(), id); } }
protected RouteDefinition loadRouteDefinition(Element screenElement) { String screenId = screenElement.attributeValue("id"); String route = screenElement.attributeValue("route"); String parentPrefix = screenElement.attributeValue("routeParentPrefix"); RouteDefinition routeDefinition; WindowInfo superScreen = screens.get(screenId); RouteDefinition superScreenRouteDefinition = superScreen != null ? superScreen.getRouteDefinition() : null; if (route != null && !route.isEmpty()) { if (superScreenRouteDefinition != null) { String superScreenRoute = superScreenRouteDefinition.getPath(); String superScreenParentPrefix = superScreenRouteDefinition.getParentPrefix(); if (!route.equals(superScreenRoute)) { routes.remove(superScreenRoute); } if (parentPrefix == null || parentPrefix.isEmpty()) { parentPrefix = superScreenParentPrefix; } } routeDefinition = new RouteDefinition(route, parentPrefix); } else { routeDefinition = superScreenRouteDefinition; } return routeDefinition; }
protected String buildDialogRoute(Screen dialog) { RouteDefinition dialogRouteDefinition = getRouteDef(dialog); Iterator<Screen> currentTabScreens = ui.getScreens().getOpenedScreens().getCurrentBreadcrumbs().iterator(); Screen currentScreen = currentTabScreens.hasNext() ? currentTabScreens.next() : null; String currentScreenRoute = currentScreen != null ? buildScreenRoute(currentScreen) : ""; if (dialogRouteDefinition == null) { return currentScreenRoute; } String dialogRoute = dialogRouteDefinition.getPath(); if (dialogRoute == null || dialogRoute.isEmpty()) { return currentScreenRoute; } String parentPrefix = dialogRouteDefinition.getParentPrefix(); if (StringUtils.isNotEmpty(parentPrefix) && dialogRoute.startsWith(parentPrefix + '/') && currentScreenRoute.endsWith(parentPrefix)) { dialogRoute = dialogRoute.substring(parentPrefix.length() + 1); } return currentScreenRoute == null || currentScreenRoute.isEmpty() ? dialogRoute : currentScreenRoute + '/' + dialogRoute; }
public void schedule(NavigationState redirect) { UrlHandlingMode urlHandlingMode = webConfig.getUrlHandlingMode(); if (UrlHandlingMode.URL_ROUTES != urlHandlingMode) { log.debug("RedirectHandler is disabled for {} URL handling mode", urlHandlingMode); return; } Preconditions.checkNotNullArgument(redirect); RouteDefinition notFoundScreenRouteDef = windowConfig.getWindowInfo(NotFoundScreen.ID).getRouteDefinition(); if (Objects.equals(notFoundScreenRouteDef.getPath(), redirect.getNestedRoute())) { return; } this.redirect = redirect; String nestedRoute = redirect.getNestedRoute(); if (StringUtils.isEmpty(nestedRoute)) { return; } Map<String, String> params = new LinkedHashMap<>(); params.put(REDIRECT_PARAM, nestedRoute); if (redirect.getParams() != null) { params.putAll(redirect.getParams()); } RootWindow rootWindow = ui.getTopLevelWindow(); if (rootWindow != null) { ui.getUrlRouting().replaceState(rootWindow.getFrameOwner(), params); } }