public UI createInstance(UICreateEvent event) { return ReflectTools.createInstance(event.getUIClass()); }
/** * 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; }
public String getPageTitle(UICreateEvent event) { Title titleAnnotation = getAnnotationFor(event.getUIClass(), Title.class); if (titleAnnotation == null) { return null; } else { return titleAnnotation.value(); } }
/** * 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(); } }
Widgetset uiWidgetset = getAnnotationFor(event.getUIClass(), Widgetset.class); } else { InputStream resource = event.getUIClass() .getResourceAsStream("/" + APP_WIDGETSET_NAME + ".gwt.xml"); if (resource != null) {
@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); } }
public UI createInstance(UICreateEvent event) { try { return event.getUIClass().newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Could not instantiate UI class", e); } catch (IllegalAccessException e) { throw new RuntimeException("Could not access UI class", e); } }
@Override public UI createInstance(UICreateEvent event) { ensureInitialized(); if (context == null) { throw new IllegalStateException("Couldn't load spring context."); } return context.getBean(event.getUIClass()); }
@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); } } }
@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); } } }
@Override public UI createInstance(UICreateEvent event) { Class<? extends UI> uiClass = event.getUIClass(); UIKey uiKey = new UIKey(); // hold the key while UI is created CurrentInstance.set(UIKey.class, uiKey); // and set up the scope UIScope scope = UIScope.getCurrent(); scope.startScope(uiKey); // create the UI Provider<ScopedUI> provider = uiMapBinderProvider.get(event.getUIClass().getName()); ScopedUI ui = provider.get(); ui.setInstanceKey(uiKey); ui.setScope(scope); log.debug("Returning instance of {} with key {}", uiClass.getName(), uiKey); return ui; }
@Override public UI createInstance(UICreateEvent event) { Class<? extends UI> uiClass = event.getUIClass(); UIKey uiKey = uiKeyProvider.get(); // hold the key while UI is created CurrentInstance.set(UIKey.class, uiKey); // and set up the scope UIScope scope = UIScope.getCurrent(); scope.startScope(uiKey); // create the UI ScopedUI ui = (ScopedUI) injector.getInstance(uiClass); ui.setInstanceKey(uiKey); ui.setScope(scope); log.debug("Returning instance of {} with key {}", uiClass.getName(), uiKey); return ui; }