use of io.jmix.ui.component.RootWindow in project jmix by jmix-framework.
the class UrlChangeHandler method restoreState.
public void restoreState() {
if (notSuitableMode()) {
log.debug("UrlChangeHandler is disabled for '{}' URL handling mode", uiProperties.getUrlHandlingMode());
return;
}
NavigationState currentState = urlTools.parseState(ui.getPage().getUriFragment());
if (currentState == null || currentState == NavigationState.EMPTY) {
RootWindow topLevelWindow = ui.getTopLevelWindow();
if (topLevelWindow instanceof WindowImpl) {
NavigationState topScreenState = ((WindowImpl) topLevelWindow).getResolvedState();
urlTools.replaceState(topScreenState.asRoute(), ui);
}
}
}
use of io.jmix.ui.component.RootWindow in project jmix by jmix-framework.
the class AppUI method restoreRouteState.
/*
* During AppUI initialization process the initial URL is replaced
* with the created Root Window route. In case the requested state
* contains parameters for the root window, we need to restore it
* to keep in sync the browser URL and params that can be obtained
* from UrlParamsChangedEvent
*/
protected void restoreRouteState(NavigationState requestedState) {
// Check that the requested state doesn't contain nested route
// that will be handled by navigation handlers and that there
// are parameters to restore in the browser URL.
Map<String, String> requestedParams = requestedState.getParams();
if (!Strings.isNullOrEmpty(requestedState.getNestedRoute()) || MapUtils.isEmpty(requestedParams)) {
return;
}
RootWindow topLevelWindow = getTopLevelWindow();
if (topLevelWindow instanceof WindowImpl) {
Screen frameOwner = topLevelWindow.getFrameOwner();
NavigationState resolvedState = ((WindowImpl) topLevelWindow).getResolvedState();
if (resolvedState == null) {
return;
}
// Check that the actual Root Window and the requested Root Window is the same
if (Objects.equals(requestedState.getRoot(), resolvedState.getRoot())) {
urlRouting.replaceState(frameOwner, requestedParams);
// Because of usage of 'urlRouting.replaceState' UrlParamsChangedEvent
// won't be fired for the Root Window by ParamsNavigationHandler, hence
// we need to do it here.
UiControllerUtils.fireEvent(frameOwner, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(frameOwner, requestedParams));
}
}
}
use of io.jmix.ui.component.RootWindow in project jmix by jmix-framework.
the class App method getWindowManager.
/**
* @return WindowManagerImpl instance or null if the current UI has no MainWindow
* @deprecated Get screens API from {@link AppUI} instead.
*/
@Deprecated
@Nullable
public ScreensImpl getWindowManager() {
AppUI ui = AppUI.getCurrent();
if (ui == null) {
return null;
}
RootWindow topLevelWindow = ui.getTopLevelWindow();
if (topLevelWindow == null) {
return null;
} else {
return (ScreensImpl) UiControllerUtils.getScreenContext(topLevelWindow.getFrameOwner()).getScreens();
}
}
use of io.jmix.ui.component.RootWindow in project jmix by jmix-framework.
the class RootNavigationHandler method handle404.
protected void handle404(String route, AppUI ui) {
RootWindow topWindow = ui.getTopLevelWindow();
Screen rootScreen = topWindow != null ? topWindow.getFrameOwner() : null;
if (rootScreen instanceof Window.HasWorkArea) {
MapScreenOptions options = new MapScreenOptions(ParamsMap.of("requestedRoute", route));
ui.getScreens().create(NotFoundScreen.class, OpenMode.NEW_TAB, options).show();
} else {
ui.getNotifications().create(Notifications.NotificationType.TRAY).withCaption(messages.formatMessage("", "navigation.screenNotFound", route)).show();
}
}
use of io.jmix.ui.component.RootWindow in project jmix by jmix-framework.
the class WebUrlRouting method buildNavState.
protected NavigationState buildNavState(Screen screen, Map<String, String> urlParams) {
NavigationState state;
if (screen.getWindow() instanceof RootWindow) {
state = new NavigationState(getRoute(screen), "", "", urlParams);
} else {
String rootRoute = getRoute(ui.getScreens().getOpenedScreens().getRootScreen());
String stateMark = getStateMark(screen);
String nestedRoute = buildNestedRoute(screen);
Map<String, String> params = buildParams(screen, urlParams);
state = new NavigationState(rootRoute, stateMark, nestedRoute, params);
}
return state;
}
Aggregations