Search in sources :

Example 11 with NavigationState

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

the class UrlTools method parseParamsRoute.

@Nullable
protected NavigationState parseParamsRoute(String uriFragment) {
    Matcher matcher = PARAMS_ROUTE_PATTERN.matcher(uriFragment);
    if (!matcher.matches()) {
        return null;
    }
    String root = matcher.group(1);
    String stateMark;
    String nestedRoute;
    String params = matcher.group(matcher.groupCount());
    if (matcher.groupCount() == 3) {
        stateMark = "";
        nestedRoute = matcher.group(2);
    } else {
        stateMark = matcher.group(2);
        nestedRoute = matcher.group(3);
    }
    return new NavigationState(root, stateMark, nestedRoute, extractParams(params));
}
Also used : Matcher(java.util.regex.Matcher) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) Nullable(javax.annotation.Nullable)

Example 12 with NavigationState

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

the class HistoryNavigator method handleHistoryBackward.

protected void handleHistoryBackward(NavigationState requestedState) {
    NavigationState currentState = history.getNow();
    NavigationState previousState = findPreviousState(requestedState);
    if (previousState == null) {
        urlChangeHandler.revertNavigationState();
        return;
    }
    NavigationFilter.AccessCheckResult accessCheckResult = urlChangeHandler.navigationAllowed(previousState);
    if (accessCheckResult.isRejected()) {
        if (StringUtils.isNotEmpty(accessCheckResult.getMessage())) {
            urlChangeHandler.showNotification(accessCheckResult.getMessage());
        }
        urlChangeHandler.revertNavigationState();
        return;
    }
    if (urlChangeHandler.isRootState(previousState)) {
        handleRootBackNavigation(previousState);
    } else {
        handleScreenBackNavigation(currentState, previousState);
    }
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) NavigationFilter(com.haulmont.cuba.web.sys.navigation.accessfilter.NavigationFilter)

Example 13 with NavigationState

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

the class WebUrlRouting method updateState.

protected void updateState(Screen screen, Map<String, String> urlParams, boolean pushState) {
    NavigationState currentState = getState();
    NavigationState newState = buildNavState(screen, urlParams);
    // do not push copy-pasted requested state to avoid double state pushing into browser history
    if (!pushState || externalNavigation(currentState, newState) || isNotFoundScreen(screen)) {
        urlTools.replaceState(newState.asRoute(), ui);
        lastHistoryOperation = CubaUIConstants.HISTORY_REPLACE_OP;
    } else {
        urlTools.pushState(newState.asRoute(), ui);
        lastHistoryOperation = CubaUIConstants.HISTORY_PUSH_OP;
    }
    ((WebWindow) screen.getWindow()).setResolvedState(newState);
    if (pushState) {
        ui.getHistory().forward(newState);
    } else {
        ui.getHistory().replace(newState);
    }
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 14 with NavigationState

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

the class UrlChangeHandler method getStateMark.

protected String getStateMark(Screen screen) {
    WebWindow webWindow = (WebWindow) screen.getWindow();
    NavigationState resolvedState = webWindow.getResolvedState();
    return resolvedState != null ? resolvedState.getStateMark() : NavigationState.EMPTY.getStateMark();
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 15 with NavigationState

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

the class UrlTools method parseNestedRoute.

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

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