Search in sources :

Example 1 with UrlParamsChangedEvent

use of com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent in project cuba by cuba-platform.

the class ScreenNavigationHandler method openScreen.

protected void openScreen(NavigationState requestedState, String screenRoute, WindowInfo windowInfo, AppUI ui) {
    UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
    if (!urlChangeHandler.isPermittedToNavigate(requestedState, windowInfo)) {
        return;
    }
    Screen screen = createScreen(requestedState, screenRoute, windowInfo, ui);
    if (screen == null) {
        log.info("Unable to open screen '{}' for requested route '{}'", windowInfo.getId(), requestedState.getNestedRoute());
        urlChangeHandler.revertNavigationState();
        return;
    }
    if (requestedState.getNestedRoute().endsWith(screenRoute)) {
        Map<String, String> params = requestedState.getParams();
        if (MapUtils.isNotEmpty(params)) {
            UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, params));
        }
        ((WebWindow) screen.getWindow()).setResolvedState(requestedState);
    } else {
        ((WebWindow) screen.getWindow()).setResolvedState(getNestedScreenState(screenRoute, requestedState));
    }
    screen.show();
}
Also used : UrlParamsChangedEvent(com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent) Screen(com.haulmont.cuba.gui.screen.Screen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 2 with UrlParamsChangedEvent

use of com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent in project cuba by cuba-platform.

the class RootNavigationHandler method doHandle.

@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
    UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
    if (urlChangeHandler.isEmptyState(requestedState)) {
        urlChangeHandler.revertNavigationState();
        return false;
    }
    if (!rootChanged(requestedState, ui)) {
        return false;
    }
    String rootRoute = requestedState.getRoot();
    WindowInfo windowInfo = windowConfig.findWindowInfoByRoute(rootRoute);
    if (windowInfo == null) {
        log.info("No registered screen found for route: '{}'", rootRoute);
        urlChangeHandler.revertNavigationState();
        handle404(rootRoute, ui);
        return true;
    }
    if (urlChangeHandler.shouldRedirect(windowInfo)) {
        urlChangeHandler.redirect(requestedState);
        return true;
    }
    if (!urlChangeHandler.isPermittedToNavigate(requestedState, windowInfo)) {
        return true;
    }
    Screen screen = ui.getScreens().create(windowInfo.getId(), OpenMode.ROOT);
    boolean hasNestedRoute = StringUtils.isNotEmpty(requestedState.getNestedRoute());
    if (!hasNestedRoute && MapUtils.isNotEmpty(requestedState.getParams())) {
        UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, requestedState.getParams()));
        ((WebWindow) screen.getWindow()).setResolvedState(requestedState);
    }
    screen.show();
    return !hasNestedRoute;
}
Also used : UrlParamsChangedEvent(com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent) Screen(com.haulmont.cuba.gui.screen.Screen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 3 with UrlParamsChangedEvent

use of com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent 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;
}
Also used : UrlParamsChangedEvent(com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent) Screen(com.haulmont.cuba.gui.screen.Screen) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Aggregations

UrlParamsChangedEvent (com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent)3 Screen (com.haulmont.cuba.gui.screen.Screen)3 WebWindow (com.haulmont.cuba.web.gui.WebWindow)3 UrlChangeHandler (com.haulmont.cuba.web.sys.navigation.UrlChangeHandler)3 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)2 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)1 NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)1 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)1