Search in sources :

Example 1 with RouteDefinition

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;
}
Also used : RouteDefinition(com.haulmont.cuba.gui.sys.RouteDefinition) Preconditions.checkNotEmptyString(com.haulmont.bali.util.Preconditions.checkNotEmptyString) Route(com.haulmont.cuba.gui.Route)

Example 2 with RouteDefinition

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;
}
Also used : RouteDefinition(com.haulmont.cuba.gui.sys.RouteDefinition) Screen(com.haulmont.cuba.gui.screen.Screen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) Preconditions.checkNotEmptyString(com.haulmont.bali.util.Preconditions.checkNotEmptyString)

Example 3 with RouteDefinition

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);
    }
}
Also used : RouteDefinition(com.haulmont.cuba.gui.sys.RouteDefinition) UrlHandlingMode(com.haulmont.cuba.web.gui.UrlHandlingMode) RootWindow(com.haulmont.cuba.gui.components.RootWindow) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with RouteDefinition

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());
}
Also used : RouteDefinition(com.haulmont.cuba.gui.sys.RouteDefinition) Screen(com.haulmont.cuba.gui.screen.Screen)

Aggregations

RouteDefinition (com.haulmont.cuba.gui.sys.RouteDefinition)4 Preconditions.checkNotEmptyString (com.haulmont.bali.util.Preconditions.checkNotEmptyString)2 Screen (com.haulmont.cuba.gui.screen.Screen)2 Route (com.haulmont.cuba.gui.Route)1 RootWindow (com.haulmont.cuba.gui.components.RootWindow)1 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)1 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)1 UrlHandlingMode (com.haulmont.cuba.web.gui.UrlHandlingMode)1 LinkedHashMap (java.util.LinkedHashMap)1