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));
}
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);
}
}
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);
}
}
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();
}
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());
}
Aggregations