Search in sources :

Example 1 with NavigationState

use of io.jmix.ui.navigation.NavigationState in project jmix by jmix-framework.

the class AppWorkAreaImpl method reflectTabChangeToUrl.

protected void reflectTabChangeToUrl(boolean userOriginated) {
    if (!userOriginated) {
        return;
    }
    Component selectedTab = tabbedContainer.getTabSheetBehaviour().getSelectedTab();
    if (selectedTab == null) {
        return;
    }
    Window selectedWindow = ((TabWindowContainer) selectedTab).getBreadCrumbs().getCurrentWindow();
    WindowImpl windowImpl = (WindowImpl) selectedWindow;
    if (windowImpl != null) {
        NavigationState resolvedState = windowImpl.getResolvedState();
        if (resolvedState != null) {
            int stateMark = generateUrlStateMark();
            NavigationState newState = new NavigationState(resolvedState.getRoot(), String.valueOf(stateMark), resolvedState.getNestedRoute(), resolvedState.getParams());
            windowImpl.setResolvedState(newState);
            Screen screen = selectedWindow.getFrameOwner();
            UrlRouting urlRouting = UiControllerUtils.getScreenContext(screen).getUrlRouting();
            urlRouting.pushState(screen, newState.getParams());
        }
    }
}
Also used : NavigationState(io.jmix.ui.navigation.NavigationState) Screen(io.jmix.ui.screen.Screen) Component(com.vaadin.ui.Component) UrlRouting(io.jmix.ui.navigation.UrlRouting)

Example 2 with NavigationState

use of io.jmix.ui.navigation.NavigationState in project jmix by jmix-framework.

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();
    WindowImpl window = (WindowImpl) 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;
}
Also used : UrlParamsChangedEvent(io.jmix.ui.navigation.UrlParamsChangedEvent) WindowImpl(io.jmix.ui.component.impl.WindowImpl) Screen(io.jmix.ui.screen.Screen) NavigationState(io.jmix.ui.navigation.NavigationState) UrlChangeHandler(io.jmix.ui.navigation.UrlChangeHandler)

Example 3 with NavigationState

use of io.jmix.ui.navigation.NavigationState in project jmix by jmix-framework.

the class ScreensImpl method afterScreenRemove.

protected void afterScreenRemove(Screen screen) {
    if (screen.getWindow() instanceof RootWindow) {
        return;
    }
    Screen currentScreen = getAnyCurrentScreen();
    if (currentScreen != null) {
        NavigationState resolvedState = ((WindowImpl) currentScreen.getWindow()).getResolvedState();
        if (resolvedState != null) {
            String currentScreenRoute = resolvedState.asRoute();
            urlTools.replaceState(currentScreenRoute, ui);
        }
    }
}
Also used : WindowImpl(io.jmix.ui.component.impl.WindowImpl) TabWindowImpl(io.jmix.ui.component.impl.TabWindowImpl) Screen(io.jmix.ui.screen.Screen) NavigationState(io.jmix.ui.navigation.NavigationState)

Aggregations

NavigationState (io.jmix.ui.navigation.NavigationState)3 Screen (io.jmix.ui.screen.Screen)3 WindowImpl (io.jmix.ui.component.impl.WindowImpl)2 Component (com.vaadin.ui.Component)1 TabWindowImpl (io.jmix.ui.component.impl.TabWindowImpl)1 UrlChangeHandler (io.jmix.ui.navigation.UrlChangeHandler)1 UrlParamsChangedEvent (io.jmix.ui.navigation.UrlParamsChangedEvent)1 UrlRouting (io.jmix.ui.navigation.UrlRouting)1