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