private WidgetsetInfo getWidgetsetClassInfo() { Class<WidgetsetInfo> cls = findWidgetsetClass(); if (cls != null) { try { return cls.newInstance(); } catch (InstantiationException e) { getLogger().log(Level.INFO, "Unexpected trying to instantiate class " + cls.getName(), e); } catch (IllegalAccessException e) { getLogger().log(Level.INFO, "Unexpected trying to access class " + cls.getName(), e); } } return null; }
/** * 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; }
@Override public String getPageTitle(UICreateEvent event) { UI uiInstance = getUIInstance(event); if (uiInstance != null) { return uiInstance.getCaption(); } else { return super.getPageTitle(event); } }
uiClass = p.getUIClass(classSelectionEvent); if (uiClass != null) { provider = p; UI ui = uiClass.cast(provider.createInstance(event)); PushMode pushMode = provider.getPushMode(event); if (pushMode == null) { pushMode = session.getService().getDeploymentConfiguration() Transport transport = provider.getPushTransport(event); if (transport != null) { ui.getPushConfiguration().setTransport(transport);
/** * Create a Vaadin UI using given UI class * @param <T> UI type * @param uiClass UI class to create * @return UI instance */ @SuppressWarnings("unchecked") protected <T extends UI> T createUi(Class<T> uiClass) { T ui = (T) uiProvider.createInstance(buildUiCreateEvent(uiClass, null)); CurrentInstance.set(UI.class, ui); return ui; }
Widgetset uiWidgetset = getAnnotationFor(event.getUIClass(), Widgetset.class); WidgetsetInfo info = getWidgetsetClassInfo();
/** * 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); }
UIProvider provider = null; for (UIProvider p : uiProviders) { uiClass = p.getUIClass(classSelectionEvent);
/** * 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; }
/** * Create a Vaadin UI using given UI class * @param <T> UI type * @param uiClass UI class to create * @return UI instance */ @SuppressWarnings("unchecked") protected <T extends UI> T createUi(Class<T> uiClass) { T ui = (T) uiProvider.createInstance(buildUiCreateEvent(uiClass, null)); CurrentInstance.set(UI.class, ui); return ui; }
/** * 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(); } }
String title = response.getUIProvider().getPageTitle( new UICreateEvent(context.getRequest(), context.getUIClass())); if (title != null) {
/** * 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; }
private void readConfigurationAnnotation(Properties initParameters) throws ServletException { VaadinServletConfiguration configAnnotation = UIProvider .getAnnotationFor(getClass(), VaadinServletConfiguration.class); if (configAnnotation != null) { Method[] methods = VaadinServletConfiguration.class
/** * 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(); } }
/** * 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; } }
/** * 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(); } }