protected String getRoute(Screen screen) { RouteDefinition routeDef = getRouteDef(screen); return routeDef == null ? null : routeDef.getPath(); }
protected RouteDefinition extractRouteDefinition(MetadataReader metadataReader) { Map<String, Object> routeAnnotation = metadataReader.getAnnotationMetadata().getAnnotationAttributes(Route.class.getName()); RouteDefinition routeDefinition = null; if (routeAnnotation != null) { String pathAttr = (String) routeAnnotation.get(Route.PATH_ATTRIBUTE); String parentPrefixAttr = (String) routeAnnotation.get(Route.PARENT_PREFIX_ATTRIBUTE); routeDefinition = new RouteDefinition(pathAttr, parentPrefixAttr); } return routeDefinition; }
@Override public String toString() { return "UiControllerDefinition{" + "id='" + id + '\'' + ", controllerClass='" + controllerClass + '\'' + (routeDefinition == null ? "" : ", " + routeDefinition.toString()) + '}'; }
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; }
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; }
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); } }