Search in sources :

Example 1 with ConnectionImpl

use of com.haulmont.cuba.web.security.ConnectionImpl in project cuba by cuba-platform.

the class TestUiEnvironment method setupVaadinUi.

protected void setupVaadinUi() {
    AutowireCapableBeanFactory injector = getInjector();
    app = new DefaultApp();
    setThemeConstants(app, new ThemeConstants(new HashMap<>()));
    setCookies(app, new AppCookies());
    Connection connection = new ConnectionImpl();
    injector.autowireBean(connection);
    setConnection(app, connection);
    VaadinSession vaadinSession = new TestVaadinSession(new WebBrowser(), getLocale());
    vaadinSession.setAttribute(App.class, app);
    vaadinSession.setAttribute(App.NAME, app);
    vaadinSession.setAttribute(Connection.class, connection);
    vaadinSession.setAttribute(Connection.NAME, connection);
    vaadinSession.setAttribute(UserSession.class, sessionSource.getSession());
    VaadinSession.setCurrent(vaadinSession);
    injector.autowireBean(app);
    ui = new AppUI();
    injector.autowireBean(ui);
    // setup UI
    ConnectorTracker connectorTracker = new TestConnectorTracker(ui);
    try {
        getDeclaredField(UI.class, "connectorTracker", true).set(ui, connectorTracker);
        getDeclaredField(UI.class, "session", true).set(ui, vaadinSession);
    } catch (Exception e) {
        throw new RuntimeException("Unable to init Vaadin UI state", e);
    }
    UI.setCurrent(ui);
    VaadinRequest vaadinRequest = new TestVaadinRequest();
    ui.getPage().init(vaadinRequest);
    initUi(ui, vaadinRequest);
}
Also used : DefaultApp(com.haulmont.cuba.web.DefaultApp) VaadinSession(com.vaadin.server.VaadinSession) Connection(com.haulmont.cuba.web.Connection) ConnectorTracker(com.vaadin.ui.ConnectorTracker) ConnectionImpl(com.haulmont.cuba.web.security.ConnectionImpl) AutowireCapableBeanFactory(org.springframework.beans.factory.config.AutowireCapableBeanFactory) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) WebBrowser(com.vaadin.server.WebBrowser) UI(com.vaadin.ui.UI) AppUI(com.haulmont.cuba.web.AppUI) VaadinRequest(com.vaadin.server.VaadinRequest) AppCookies(com.haulmont.cuba.web.sys.AppCookies) AppUI(com.haulmont.cuba.web.AppUI)

Aggregations

ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)1 AppUI (com.haulmont.cuba.web.AppUI)1 Connection (com.haulmont.cuba.web.Connection)1 DefaultApp (com.haulmont.cuba.web.DefaultApp)1 ConnectionImpl (com.haulmont.cuba.web.security.ConnectionImpl)1 AppCookies (com.haulmont.cuba.web.sys.AppCookies)1 VaadinRequest (com.vaadin.server.VaadinRequest)1 VaadinSession (com.vaadin.server.VaadinSession)1 WebBrowser (com.vaadin.server.WebBrowser)1 ConnectorTracker (com.vaadin.ui.ConnectorTracker)1 UI (com.vaadin.ui.UI)1 AutowireCapableBeanFactory (org.springframework.beans.factory.config.AutowireCapableBeanFactory)1