Search in sources :

Example 16 with NavigationState

use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.

the class UrlTools method parseRootRoute.

@Nullable
protected NavigationState parseRootRoute(String uriFragment) {
    Matcher matcher = ROOT_ROUTE_PATTERN.matcher(uriFragment);
    if (!matcher.matches()) {
        return null;
    }
    String root = matcher.group(1);
    return new NavigationState(root, "", "", Collections.emptyMap());
}
Also used : Matcher(java.util.regex.Matcher) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) Nullable(javax.annotation.Nullable)

Example 17 with NavigationState

use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.

the class HistoryNavigator method findPreviousState.

protected NavigationState findPreviousState(NavigationState requestedState) {
    if (urlChangeHandler.isRootState(requestedState)) {
        return requestedState;
    }
    if (Objects.equals(requestedState, history.getNow())) {
        requestedState = history.getPrevious();
    }
    NavigationState prevState;
    Screen prevStateScreen = urlChangeHandler.findScreenByState(requestedState);
    if (prevStateScreen == null && !urlChangeHandler.isRootState(requestedState)) {
        while (history.getPrevious() != null) {
            history.backward();
            NavigationState previousState = history.getPrevious();
            if (urlChangeHandler.findActiveScreenByState(previousState) != null || urlChangeHandler.isRootState(previousState)) {
                break;
            }
        }
        prevState = history.getPrevious();
    } else {
        prevState = requestedState;
    }
    return prevState;
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) Screen(com.haulmont.cuba.gui.screen.Screen)

Example 18 with NavigationState

use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.

the class WebHistory method replace.

@Override
public boolean replace(NavigationState navigationState) {
    if (checkNotNativeUrlHandlingMode()) {
        return false;
    }
    Preconditions.checkNotNullArgument(navigationState);
    NavigationState currentState = history.get(now);
    if (!Objects.equals(currentState.getRoot(), navigationState.getRoot()) || !Objects.equals(currentState.getStateMark(), navigationState.getStateMark()) || !Objects.equals(currentState.getNestedRoute(), navigationState.getNestedRoute())) {
        log.debug("It's allowed to replace state in history when only params are changed");
        return false;
    }
    history.set(now, navigationState);
    return true;
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState)

Example 19 with NavigationState

use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.

the class ParamsNavigationHandler method doHandle.

@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
    UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
    if (urlChangeHandler.isEmptyState(requestedState)) {
        return false;
    }
    Screen screen = urlChangeHandler.getActiveScreen();
    if (screen == null) {
        log.debug("Unable to find a screen for state: '{}", requestedState);
        return false;
    }
    Map<String, String> params = requestedState.getParams() != null ? requestedState.getParams() : Collections.emptyMap();
    WebWindow window = (WebWindow) screen.getWindow();
    NavigationState resolvedState = window.getResolvedState();
    if (resolvedState == null || params.equals(resolvedState.getParams())) {
        return false;
    }
    NavigationState newState = new NavigationState(resolvedState.getRoot(), resolvedState.getStateMark(), resolvedState.getNestedRoute(), params);
    window.setResolvedState(newState);
    UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, params));
    return true;
}
Also used : UrlParamsChangedEvent(com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent) Screen(com.haulmont.cuba.gui.screen.Screen) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 20 with NavigationState

use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.

the class ScreenNavigationHandler method navigate.

protected boolean navigate(NavigationState requestedState, AppUI ui, List<Pair<String, WindowInfo>> routeWindowInfos) {
    int subRouteIdx = 0;
    NavigationState currentState = ui.getHistory().getNow();
    for (Pair<String, WindowInfo> entry : routeWindowInfos) {
        String subRoute = entry.getFirst();
        if (skipSubRoute(requestedState, subRouteIdx, currentState, subRoute)) {
            subRouteIdx++;
            continue;
        }
        WindowInfo windowInfo = entry.getSecond();
        openScreen(requestedState, subRoute, windowInfo, ui);
        subRouteIdx++;
    }
    return true;
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)21 WebWindow (com.haulmont.cuba.web.gui.WebWindow)9 Screen (com.haulmont.cuba.gui.screen.Screen)6 Nullable (javax.annotation.Nullable)4 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)3 UrlChangeHandler (com.haulmont.cuba.web.sys.navigation.UrlChangeHandler)3 RootWindow (com.haulmont.cuba.gui.components.RootWindow)2 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)2 UrlParamsChangedEvent (com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent)2 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)2 MapScreenOptions (com.haulmont.cuba.gui.screen.MapScreenOptions)2 Matcher (java.util.regex.Matcher)2 Pair (com.haulmont.bali.datastruct.Pair)1 ParamsMap (com.haulmont.bali.util.ParamsMap)1 Preconditions.checkNotEmptyString (com.haulmont.bali.util.Preconditions.checkNotEmptyString)1 MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 Entity (com.haulmont.cuba.core.entity.Entity)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1 UrlRouting (com.haulmont.cuba.gui.UrlRouting)1