com.haulmont.cuba.web.DefaultApp Java Examples

The following examples show how to use com.haulmont.cuba.web.DefaultApp. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestUiEnvironment.java    From cuba with Apache License 2.0 4 votes vote down vote up
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);
}