Search in sources :

Example 1 with RootWindow

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);
        }
    }
}
Also used : WindowImpl(io.jmix.ui.component.impl.WindowImpl) RootWindow(io.jmix.ui.component.RootWindow)

Example 2 with RootWindow

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));
        }
    }
}
Also used : WindowImpl(io.jmix.ui.component.impl.WindowImpl) Screen(io.jmix.ui.screen.Screen) RootWindow(io.jmix.ui.component.RootWindow)

Example 3 with RootWindow

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();
    }
}
Also used : RootWindow(io.jmix.ui.component.RootWindow) Nullable(javax.annotation.Nullable)

Example 4 with RootWindow

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();
    }
}
Also used : Screen(io.jmix.ui.screen.Screen) NotFoundScreen(io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen) RootWindow(io.jmix.ui.component.RootWindow) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) NotFoundScreen(io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen)

Example 5 with RootWindow

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;
}
Also used : RootWindow(io.jmix.ui.component.RootWindow) Preconditions.checkNotEmptyString(io.jmix.core.common.util.Preconditions.checkNotEmptyString)

Aggregations

RootWindow (io.jmix.ui.component.RootWindow)9 Screen (io.jmix.ui.screen.Screen)3 NotFoundScreen (io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen)2 WindowImpl (io.jmix.ui.component.impl.WindowImpl)2 Messages (io.jmix.core.Messages)1 Preconditions.checkNotEmptyString (io.jmix.core.common.util.Preconditions.checkNotEmptyString)1 WindowInfo (io.jmix.ui.WindowInfo)1 BaseAction (io.jmix.ui.action.BaseAction)1 DialogAction (io.jmix.ui.action.DialogAction)1 DialogWindow (io.jmix.ui.component.DialogWindow)1 Window (io.jmix.ui.component.Window)1 IllegalConcurrentAccessException (io.jmix.ui.executor.IllegalConcurrentAccessException)1 Icons (io.jmix.ui.icon.Icons)1 EditorScreen (io.jmix.ui.screen.EditorScreen)1 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)1 UnknownOperationResult (io.jmix.ui.util.UnknownOperationResult)1 LinkedHashMap (java.util.LinkedHashMap)1 Nullable (javax.annotation.Nullable)1