protected RouteDefinition getRouteDef(Screen screen) { return screen == null ? null : getScreenContext(screen).getWindowInfo().getRouteDefinition(); }
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 getParentPrefix(Screen screen) { String parentPrefix = null; Route routeAnnotation = screen.getClass().getAnnotation(Route.class); if (routeAnnotation != null) { parentPrefix = routeAnnotation.parentPrefix(); } else { RouteDefinition routeDef = getScreenContext(screen) .getWindowInfo() .getRouteDefinition(); if (routeDef != null) { parentPrefix = routeDef.getParentPrefix(); } } return parentPrefix; }
public ResolvedWindowInfo(WindowInfo windowInfo, Type type, Class<? extends FrameOwner> controllerClass, String template) { super(windowInfo.getId(), null, windowInfo.getDescriptor(), windowInfo.getControllerClassName(), windowInfo.getRouteDefinition()); this.template = template; this.controllerClass = controllerClass; this.type = type; }
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); } }
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); } }