com.vaadin.server.UICreateEvent Java Examples

The following examples show how to use com.vaadin.server.UICreateEvent. 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: CubaUIProvider.java    From cuba with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: CustomSpringUIProvider.java    From cia with Apache License 2.0 6 votes vote down vote up
@Override
public UI createInstance(final UICreateEvent event) {
	final Class<UIID> key = UIID.class;
	final UIID identifier = new UIID(event);
	CurrentInstance.set(key, identifier);
	try {
		logger.debug("Creating a new UI bean of class [{}] with identifier [{}]",
				event.getUIClass().getCanonicalName(), identifier);
		final UI ui = getWebApplicationContext().getBean(event.getUIClass());

		getSpringViewDisplayRegistrationBean().setBeanClass(event.getUIClass());

		configureNavigator(ui);
		return ui;
	} finally {
		CurrentInstance.set(key, null);
	}
}
 
Example #3
Source File: CubaUIProvider.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public PushMode getPushMode(UICreateEvent event) {
    WebConfig webConfig = configuration.getConfig(WebConfig.class);

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

    return super.getPushMode(event);
}
 
Example #4
Source File: CubaUIProvider.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Transport getPushTransport(UICreateEvent event) {
    WebConfig webConfig = configuration.getConfig(WebConfig.class);

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

    return super.getPushTransport(event);
}
 
Example #5
Source File: SpringUIProvider.java    From jdal with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #6
Source File: CubaUIProvider.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public UI createInstance(UICreateEvent event) {
    return AppBeans.getPrototype(AppUI.NAME);
}
 
Example #7
Source File: IngestUiProvider.java    From jesterj with Apache License 2.0 4 votes vote down vote up
@Override
public UI createInstance(UICreateEvent event) {
  return IngestServletContextListener.injector().getProvider(uiClass).get();
}