Java 类com.vaadin.server.UICreateEvent 实例源码

项目:cuba    文件:CubaUIProvider.java   
@Override
public String getTheme(UICreateEvent event) {
    // get theme from cookies before app ui initialized for smooth theme enabling
    WebConfig webConfig = configuration.getConfig(WebConfig.class);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);

    String appWindowTheme = webConfig.getAppWindowTheme();
    String userAppTheme = getCookieValue(event.getRequest().getCookies(),
            App.APP_THEME_COOKIE_PREFIX + globalConfig.getWebContextName());
    if (userAppTheme != null) {
        if (!Objects.equals(userAppTheme, appWindowTheme)) {
            // check theme support
            ThemeConstantsRepository themeRepository = AppBeans.get(ThemeConstantsRepository.NAME);
            Set<String> supportedThemes = themeRepository.getAvailableThemes();
            if (supportedThemes.contains(userAppTheme)) {

                return userAppTheme;
            }
        }
    }

    return super.getTheme(event);
}
项目:panifex-platform    文件:ModularUIProviderTest.java   
@Test
public void testCreateUIInstance() throws Exception {
    // expect constructing new UI instance
    PageletAwareUI ui = createMockAndExpectNew(PageletAwareUI.class,
            pageletTrackerMock);

    UICreateEvent event = createMock(UICreateEvent.class);

    UI uiInstance = null;

    replayAll();
    try {
        uiInstance = provider.createInstance(event);
    } finally {
        verifyAll();

        assertEquals(ui, uiInstance);
    }
}
项目:holon-vaadin7    文件:AbstractVaadinTest.java   
/**
 * Create a Vaadin UI using given UI class
 * @param <T> UI type
 * @param uiClass UI class to create
 * @param location Page location
 * @return UI instance
 */
@SuppressWarnings("unchecked")
protected <T extends UI> T createUi(Class<T> uiClass, String location) {
    UICreateEvent evt = buildUiCreateEvent(uiClass, location);
    T ui = (T) uiProvider.createInstance(evt);
    CurrentInstance.set(UI.class, ui);
    ui.doInit(evt.getRequest(), TEST_UIID, null);
    return ui;
}
项目:osc-core    文件:MainUIProvider.java   
@Override
public UI createInstance(UICreateEvent event) {
    MainUI ui = this.mainUIFactory.getService();

    ui.addComponentDetachListener(x -> this.mainUIFactory.ungetService(ui));

    return ui;
}
项目:holon-vaadin    文件:AbstractVaadinTest.java   
/**
 * Create a Vaadin UI using given UI class
 * @param <T> UI type
 * @param uiClass UI class to create
 * @param location Page location
 * @return UI instance
 */
@SuppressWarnings("unchecked")
protected <T extends UI> T createUi(Class<T> uiClass, String location) {
    UICreateEvent evt = buildUiCreateEvent(uiClass, location);
    T ui = (T) uiProvider.createInstance(evt);
    CurrentInstance.set(UI.class, ui);
    ui.doInit(evt.getRequest(), TEST_UIID, null);
    return ui;
}
项目:cuba    文件:CubaUIProvider.java   
@Override
public PushMode getPushMode(UICreateEvent event) {
    WebConfig webConfig = configuration.getConfig(WebConfig.class);

    if (!webConfig.getPushEnabled()) {
        return PushMode.DISABLED;
    }

    return super.getPushMode(event);
}
项目:cuba    文件:CubaUIProvider.java   
@Override
public Transport getPushTransport(UICreateEvent event) {
    WebConfig webConfig = configuration.getConfig(WebConfig.class);

    if (webConfig.getUsePushLongPolling()) {
        return Transport.LONG_POLLING;
    }

    return super.getPushTransport(event);
}
项目:vaadin4spring    文件:SpringAwareUIProvider.java   
@Override
public UI createInstance(UICreateEvent event) {
    final Class<UIID> key = UIID.class;
    final UIID identifier = new UIID(event);
    CurrentInstance.set(key, identifier);
    try {
        Class<? extends UI> uiClass = event.getUIClass();
        logger.debug("Creating a new UI bean of class [{}] with identifier [{}]",
                uiClass.getCanonicalName(), identifier);
        return applicationContext.getBean(uiClass);
    } finally {
        CurrentInstance.set(key, null);
    }
}
项目:vaadin-osgi    文件:BaseVaadinUIProvider.java   
@Override
public UI createInstance(UICreateEvent event) {
    BaseVaadinUI ui = new BaseVaadinUI();
    Dictionary<String, Object> props = new Hashtable<>();
    props.put("instance.object", ui);
    try {
        factory.createComponentInstance(props);
    } catch (UnacceptableConfiguration | MissingHandlerException | ConfigurationException e) {
        e.printStackTrace();
    }
    return ui;
}
项目:jdal    文件:SpringUIProvider.java   
@Override
public UI createInstance(UICreateEvent event) {
    ApplicationContext ctx = VaadinUtils.getApplicationContext();
    CurrentInstance.set(UIid.class, new UIid(event.getUiId()));
    UI ui = this.uiMapping.getUi(event.getRequest());

    if (ui == null)
        ui =  ctx.getBean(event.getUIClass());

    CurrentInstance.set(UIid.class, null);

    return ui;
}
项目:awplab-core    文件:VaadinUIProvider.java   
@Override
public UI createInstance(UICreateEvent event) {
    //return super.createInstance(event);
    return vaadinProvider.getUI();

}
项目:cuba    文件:CubaUIProvider.java   
@Override
public UI createInstance(UICreateEvent event) {
    return AppBeans.getPrototype(AppUI.NAME);
}
项目:jesterj    文件:IngestUiProvider.java   
@Override
public UI createInstance(UICreateEvent event) {
  return IngestServletContextListener.injector().getProvider(uiClass).get();
}
项目:panifex-platform    文件:ModularUIProvider.java   
@Override
public UI createInstance(UICreateEvent event) {
    return new PageletAwareUI(pageletTracker);
}
项目:touchkit    文件:ApplicationCacheSettings.java   
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
    Document document = response.getDocument();

    // Add the widgetsetUrl parameter to the bootstrap parameters.
    // This is overridden to avoid adding the naive random query
    // parameter (used by core to avoid caching of js file).

    final VaadinService service = response.getSession().getService();
    final VaadinRequest request = response.getRequest();
    final String staticFilePath = service
            .getStaticFileLocation(request);
    // VAADIN folder location
    final String vaadinDir = staticFilePath + "/VAADIN/";
    // Figure out widgetset
    final UICreateEvent event = new UICreateEvent(request,
            response.getUiClass());
    String widgetset = response.getUIProvider().getWidgetset(event);
    if (widgetset == null) {
        widgetset = request.getService()
                .getConfiguredWidgetset(request);
    }
    // Url for the widgetset
    final String widgetsetUrl = String.format(
            "%swidgetsets/%s/%s.nocache.js", vaadinDir, widgetset,
            widgetset);

    // Update the bootstrap page
    Element scriptTag = document.getElementsByTag("script").last();
    String script = scriptTag.html();
    scriptTag.html("");

    script = script.replace("});", ",\"widgetsetUrl\":\"" + widgetsetUrl
            + "\",\"offlineEnabled\":" + isOfflineModeEnabled() + "});");

    scriptTag.appendChild(new DataNode(script, scriptTag.baseUri()));

    if (isCacheManifestEnabled()) {
        // Add cache manifest attribute to html tag
        document.getElementsByTag("html").attr(
                "manifest",
                vaadinDir + "widgetsets/" + widgetset + "/"
                        + generateManifestFileName(response));
    }
}
项目:holon-vaadin7    文件:AbstractVaadinTest.java   
/**
 * Build the UICreateEvent to pass to UIProvider
 * @param uiClass UI class
 * @param location Optional Page location
 * @return UICreateEvent
 */
protected UICreateEvent buildUiCreateEvent(Class<? extends UI> uiClass, String location) {
    VaadinServletRequest request = (location != null) ? buildVaadinRequest(location) : buildVaadinRequest();

    CurrentInstance.set(VaadinRequest.class, request);

    CurrentInstance.set(VaadinSession.class, vaadinSession);

    return new UICreateEvent(request, uiClass, TEST_UIID);
}
项目:holon-vaadin    文件:AbstractVaadinTest.java   
/**
 * Build the UICreateEvent to pass to UIProvider
 * @param uiClass UI class
 * @param location Optional Page location
 * @return UICreateEvent
 */
protected UICreateEvent buildUiCreateEvent(Class<? extends UI> uiClass, String location) {
    VaadinServletRequest request = (location != null) ? buildVaadinRequest(location) : buildVaadinRequest();

    CurrentInstance.set(VaadinRequest.class, request);

    CurrentInstance.set(VaadinSession.class, vaadinSession);

    return new UICreateEvent(request, uiClass, TEST_UIID);
}