Search in sources :

Example 1 with NavigationState

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

the class AppUI method init.

@Override
protected void init(VaadinRequest request) {
    log.trace("Initializing UI {}", this);
    NavigationState requestedState = getUrlRouting().getState();
    try {
        this.testMode = globalConfig.getTestMode();
        this.performanceTestMode = globalConfig.getPerformanceTestMode();
        // init error handlers
        setErrorHandler(this);
        // do not grab focus
        setTabIndex(-1);
        initJsLibraries();
        initInternalComponents();
        if (!App.isBound()) {
            App app = createApplication();
            app.init(request.getLocale());
            this.app = app;
            publishAppInitializedEvent(app);
        } else {
            this.app = App.getInstance();
        }
        // check that middleware is accessible before calling other services
        trustedClientService.healthCheck();
        Connection connection = app.getConnection();
        if (connection != null && !isUserSessionAlive(connection)) {
            connection.logout();
            Notification.show(messages.getMainMessage("app.sessionExpiredCaption"), messages.getMainMessage("app.sessionExpiredMessage"), Notification.Type.HUMANIZED_MESSAGE);
        }
        if (connection != null) {
            setUserSession(connection.getSession());
        }
        setupUI();
    } catch (Exception e) {
        log.error("Unable to init ui", e);
        // unable to connect to middle ware
        showCriticalExceptionMessage(e);
        return;
    }
    processExternalLink(request, requestedState);
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) NoUserSessionException(com.haulmont.cuba.security.global.NoUserSessionException) LoginException(com.haulmont.cuba.security.global.LoginException) RemoteAccessException(org.springframework.remoting.RemoteAccessException) LocalServiceAccessException(com.haulmont.cuba.web.sys.remoting.LocalServiceAccessException) PaintException(com.vaadin.server.PaintException)

Example 2 with NavigationState

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

the class WebUrlRouting method getStateMark.

protected String getStateMark(Screen screen) {
    WebWindow webWindow = (WebWindow) screen.getWindow();
    NavigationState resolvedState = webWindow.getResolvedState();
    return resolvedState != null ? resolvedState.getStateMark() : NavigationState.EMPTY.getStateMark();
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 3 with NavigationState

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

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 : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) RootWindow(com.haulmont.cuba.gui.components.RootWindow) Preconditions.checkNotEmptyString(com.haulmont.bali.util.Preconditions.checkNotEmptyString)

Example 4 with NavigationState

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

the class RedirectHandler method redirect.

public void redirect() {
    UrlHandlingMode urlHandlingMode = webConfig.getUrlHandlingMode();
    if (UrlHandlingMode.URL_ROUTES != urlHandlingMode) {
        log.debug("RedirectHandler is disabled for {} URL handling mode", urlHandlingMode);
        return;
    }
    String nestedRoute = redirect.getNestedRoute();
    Map<String, String> params = redirect.getParams();
    String redirectTarget = null;
    if (StringUtils.isNotEmpty(nestedRoute)) {
        redirectTarget = nestedRoute;
    } else if (MapUtils.isNotEmpty(params) && params.containsKey(REDIRECT_PARAM)) {
        redirectTarget = params.remove(REDIRECT_PARAM);
    }
    if (StringUtils.isEmpty(redirectTarget)) {
        return;
    }
    NavigationState currentState = ui.getUrlRouting().getState();
    NavigationState newState = new NavigationState(currentState.getRoot(), "", redirectTarget, params);
    ui.getUrlChangeHandler().getScreenNavigator().handleScreenNavigation(newState);
    redirect = null;
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) UrlHandlingMode(com.haulmont.cuba.web.gui.UrlHandlingMode)

Example 5 with NavigationState

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

the class WebAppWorkArea 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();
    WebWindow webWindow = (WebWindow) selectedWindow;
    NavigationState resolvedState = webWindow.getResolvedState();
    if (resolvedState != null) {
        int stateMark = generateUrlStateMark();
        NavigationState newState = new NavigationState(resolvedState.getRoot(), String.valueOf(stateMark), resolvedState.getNestedRoute(), resolvedState.getParams());
        webWindow.setResolvedState(newState);
        Screen screen = selectedWindow.getFrameOwner();
        UrlRouting urlRouting = UiControllerUtils.getScreenContext(screen).getUrlRouting();
        urlRouting.pushState(screen, newState.getParams());
    }
}
Also used : WebWindow(com.haulmont.cuba.web.gui.WebWindow) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) Screen(com.haulmont.cuba.gui.screen.Screen) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) Component(com.vaadin.ui.Component) UrlRouting(com.haulmont.cuba.gui.UrlRouting) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Aggregations

NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)21 WebWindow (com.haulmont.cuba.web.gui.WebWindow)9 Screen (com.haulmont.cuba.gui.screen.Screen)6 Nullable (javax.annotation.Nullable)4 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)3 UrlChangeHandler (com.haulmont.cuba.web.sys.navigation.UrlChangeHandler)3 RootWindow (com.haulmont.cuba.gui.components.RootWindow)2 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)2 UrlParamsChangedEvent (com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent)2 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)2 MapScreenOptions (com.haulmont.cuba.gui.screen.MapScreenOptions)2 Matcher (java.util.regex.Matcher)2 Pair (com.haulmont.bali.datastruct.Pair)1 ParamsMap (com.haulmont.bali.util.ParamsMap)1 Preconditions.checkNotEmptyString (com.haulmont.bali.util.Preconditions.checkNotEmptyString)1 MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 Entity (com.haulmont.cuba.core.entity.Entity)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1 UrlRouting (com.haulmont.cuba.gui.UrlRouting)1