public UI createInstance(UICreateEvent event) { return ReflectTools.createInstance(event.getUIClass()); }
/** * Override if required. * * @param context * @return */ public String getThemeName(BootstrapContext context) { UICreateEvent event = new UICreateEvent(context.getRequest(), context.getUIClass()); return context.getBootstrapResponse().getUIProvider().getTheme(event); }
Widgetset uiWidgetset = getAnnotationFor(event.getUIClass(), Widgetset.class); String initParameterWidgetSet = event.getService() .getDeploymentConfiguration().getWidgetset(null); if (initParameterWidgetSet != null) { } else { InputStream resource = event.getUIClass() .getResourceAsStream("/" + APP_WIDGETSET_NAME + ".gwt.xml"); if (resource != null) {
@Override public UI createInstance(UICreateEvent event) { return (UI) SpringApplicationContext.getApplicationContext().getBean(getUIBeanName(event.getRequest())); }
public UIID(UICreateEvent createEvent) { this.uiId = createEvent.getUiId(); }
/** * 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; }
/** * Checks whether the same UI state should be reused if the framework can * detect that the application is opened in a browser window where it has * previously been open. The framework attempts to discover this by checking * the value of window.name in the browser. * <p> * Whenever a preserved UI is reused, its * {@link UI#refresh(com.vaadin.server.VaadinRequest) refresh} method is * invoked by the framework first. * * * @param event * the UI create event with information about the UI and the * current request. * * @return <code>true</code>if the same UI instance should be reused e.g. * when the browser window is refreshed. */ public boolean isPreservedOnRefresh(UICreateEvent event) { PreserveOnRefresh preserveOnRefresh = getAnnotationFor( event.getUIClass(), PreserveOnRefresh.class); return preserveOnRefresh != null; }
new UICreateEvent(context.getRequest(), context.getUIClass())); if (title != null) { head.appendElement("title").appendText(title);
/** * 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; }
public String getPageTitle(UICreateEvent event) { Title titleAnnotation = getAnnotationFor(event.getUIClass(), Title.class); if (titleAnnotation == null) { return null; } else { return titleAnnotation.value(); } }
public WidgetsetInfo getWidgetsetForUI(BootstrapContext context) { VaadinRequest request = context.getRequest(); UICreateEvent event = new UICreateEvent(context.getRequest(), context.getUIClass()); WidgetsetInfo widgetset = context.getBootstrapResponse().getUIProvider() .getWidgetsetInfo(event); if (widgetset == null) { // TODO do we want to move WidgetsetInfoImpl elsewhere? widgetset = new WidgetsetInfoImpl( request.getService().getConfiguredWidgetset(request)); } return widgetset; }
@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); }
/** * Finds the {@link Transport} to use for a specific UI. If no transport is * defined, <code>null</code> is returned. * <p> * The default implementation uses the @{@link Push} annotation if it's * defined for the UI class. * * @param event * the UI create event with information about the UI and the * current request. * @return the transport type to use, or <code>null</code> if the default * transport type should be used */ public Transport getPushTransport(UICreateEvent event) { Push push = getAnnotationFor(event.getUIClass(), Push.class); if (push == null) { return null; } else { return push.transport(); } }
if (retainedUI != null) { if (vaadinService.preserveUIOnRefresh(provider, new UICreateEvent(request, uiClass))) { if (uiClass.isInstance(retainedUI)) { reinitUI(retainedUI, request); UICreateEvent event = new UICreateEvent(request, uiClass, uiId); UI ui = uiClass.cast(provider.createInstance(event));
/** * Finds the theme to use for a specific UI. If no specific theme is * required, <code>null</code> is returned. * <p> * The default implementation checks for a @{@link Theme} annotation on the * UI class. * * @param event * the UI create event with information about the UI and the * current request. * @return the name of the theme, or <code>null</code> if the default theme * should be used * */ public String getTheme(UICreateEvent event) { Theme uiTheme = getAnnotationFor(event.getUIClass(), Theme.class); if (uiTheme != null) { return uiTheme.value(); } else { return null; } }
/** * Gets the push mode to use. * * @return the desired push mode */ public PushMode getPushMode() { if (pushMode == null) { UICreateEvent event = new UICreateEvent(getRequest(), getUIClass()); pushMode = getBootstrapResponse().getUIProvider() .getPushMode(event); if (pushMode == null) { pushMode = getRequest().getService() .getDeploymentConfiguration().getPushMode(); } if (pushMode.isEnabled() && !getRequest().getService().ensurePushAvailable()) { /* * Fall back if not supported (ensurePushAvailable will log * information to the developer the first time this happens) */ pushMode = PushMode.DISABLED; } } return pushMode; }
/** * Finds the {@link PushMode} to use for a specific UI. If no specific push * mode is required, <code>null</code> is returned. * <p> * The default implementation uses the @{@link Push} annotation if it's * defined for the UI class. * * @param event * the UI create event with information about the UI and the * current request. * @return the push mode to use, or <code>null</code> if the default push * mode should be used * */ public PushMode getPushMode(UICreateEvent event) { Push push = getAnnotationFor(event.getUIClass(), Push.class); if (push == null) { return null; } else { return push.value(); } }
/** * 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); }
@Override public UI createInstance(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); return webApplicationContext.getBean(event.getUIClass()); } finally { CurrentInstance.set(key, null); } }
/** * 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); }