use of com.haulmont.cuba.gui.sys.RouteDefinition in project cuba by cuba-platform.
the class WebUrlRouting method getParentPrefix.
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;
}
use of com.haulmont.cuba.gui.sys.RouteDefinition in project cuba by cuba-platform.
the class WebUrlRouting method buildDialogRoute.
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;
}
use of com.haulmont.cuba.gui.sys.RouteDefinition in project cuba by cuba-platform.
the class RedirectHandler method schedule.
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);
}
}
use of com.haulmont.cuba.gui.sys.RouteDefinition in project cuba by cuba-platform.
the class UrlChangeHandler method isCurrentRootState.
protected boolean isCurrentRootState(NavigationState requestedState) {
if (!isRootState(requestedState)) {
return false;
}
Screen rootScreen = ui.getScreens().getOpenedScreens().getRootScreenOrNull();
if (rootScreen == null) {
return false;
}
RouteDefinition routeDefinition = UiControllerUtils.getScreenContext(rootScreen).getWindowInfo().getRouteDefinition();
return routeDefinition != null && routeDefinition.isRoot() && StringUtils.equals(routeDefinition.getPath(), requestedState.getRoot());
}
Aggregations