protected Class<?> getAssociatedClass() { if (associatedClass == null) { UI current = UI.getCurrent(); if (current instanceof LegacyWindow) { LegacyWindow legacyWindow = (LegacyWindow) current; return legacyWindow.getApplication().getClass(); } else { return current.getClass(); } } return associatedClass; }
private Locale findLocale() { Locale l = null; if (component != null) { l = component.getLocale(); } if (l == null && UI.getCurrent() != null) { l = UI.getCurrent().getLocale(); } if (l == null) { l = Locale.getDefault(); } return l; }
/** * Gets the Page to which the current uI belongs. This is automatically * defined when processing requests to the server. In other cases, (e.g. * from background threads), the current uI is not automatically defined. * * @see UI#getCurrent() * * @return the current page instance if available, otherwise * <code>null</code> */ public static Page getCurrent() { UI currentUI = UI.getCurrent(); if (currentUI == null) { return null; } return currentUI.getPage(); }
/** * Finds an appropriate locale to be used in conversion and validation. * * @return the found locale, not null */ protected Locale findLocale() { Locale l = null; if (getField() instanceof Component) { l = ((Component) getField()).getLocale(); } if (l == null && UI.getCurrent() != null) { l = UI.getCurrent().getLocale(); } if (l == null) { l = Locale.getDefault(); } return l; }
/** * Shows a notification message on the middle of the current page. The * message automatically disappears ("humanized message"). * * The caption is rendered as plain text with HTML automatically escaped. * * @see #Notification(String) * @see #show(Page) * * @param caption * The message * @return The Notification */ public static Notification show(String caption) { Notification notification = new Notification(caption); notification.extend(UI.getCurrent()); return notification; }
/** * Called by the framework to remove an UI instance from the session because * it has been closed. * * @param ui * the UI to remove */ public void removeUI(UI ui) { assert hasLock() : "Session is locked"; assert UI.getCurrent() != null : "Current UI cannot be null"; assert ui != null : "Removed UI cannot be null"; assert UI.getCurrent().getUIId() == ui.getUIId() : "UIs don't match"; Integer id = Integer.valueOf(ui.getUIId()); ui.setSession(null); uIs.remove(id); String embedId = ui.getEmbedId(); if (embedId != null && id.equals(embedIdMap.get(embedId))) { embedIdMap.remove(embedId); } }
/** * Sets the main window of this application. Setting window as a main window * of this application also adds the window to this application. * * @param mainWindow * the UI to set as the default window */ public void setMainWindow(LegacyWindow mainWindow) { if (this.mainWindow != null) { throw new IllegalStateException("mainWindow has already been set"); } if (mainWindow.isAttached()) { throw new IllegalStateException( "mainWindow is attached to another application"); } if (UI.getCurrent() == null) { // Assume setting a main window from Application.init if there's // no current UI -> set the main window as the current UI UI.setCurrent(mainWindow); } addWindow(mainWindow); this.mainWindow = mainWindow; }
/** * Shows a notification message the current page. The position and behavior * of the message depends on the type, which is one of the basic types * defined in {@link Notification}, for instance * {@link Type#WARNING_MESSAGE}. * * The caption is rendered as plain text with HTML automatically escaped. * * @see Notification(String, int) * @see #show(Page) * * @param caption * The message * @param type * The message type * @return The Notification */ public static Notification show(String caption, Type type) { Notification notification = new Notification(caption, type); notification.extend(UI.getCurrent()); return notification; }
/** * Shows a notification message the current page. The position and behavior * of the message depends on the type, which is one of the basic types * defined in {@link Notification}, for instance * Notification.TYPE_WARNING_MESSAGE. * * The caption is rendered as plain text with HTML automatically escaped. * * @see #Notification(String, Type) * @see #show(Page) * * @param caption * The message * @param description * The message description * @param type * The message type * @return The Notification */ public static Notification show(String caption, String description, Type type) { Notification notification = new Notification(caption, description, type); notification.extend(UI.getCurrent()); return notification; }
VaadinRequest request) { if (component == null) { component = UI.getCurrent();
/** * @return current AppUI */ public static AppUI getCurrent() { return (AppUI) UI.getCurrent(); }
@Override public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { try { assert UI.getCurrent() == null; // Update browser information from the request session.getBrowser().updateRequestDetails(request); UI uI = getBrowserDetailsUI(request, session); session.getCommunicationManager().repaintAll(uI); JsonObject params = Json.createObject(); params.put(UIConstants.UI_ID_PARAMETER, uI.getUIId()); String initialUIDL = getInitialUidl(request, uI); params.put("uidl", initialUIDL); return commitJsonResponse(request, response, JsonUtil.stringify(params)); } catch (JsonException e) { throw new IOException("Error producing initial UIDL", e); } }
/** * @deprecated since 5.5.5 - use {@link #LocalMessageDispatcher(EventBus, UI)} instead. */ @Deprecated public LocalMessageDispatcher(final EventBus eventBus, VaadinSession vaadinSession) { this(eventBus, UI.getCurrent()); }
public void open() { if (UI.getCurrent() != null) { UI.getCurrent().addWindow(this); } } }
@Override public void refresh() { ((NodeMapsApplication)UI.getCurrent()).refresh(); } };
public static <T extends UI> T getCurrent(Class<T> clazz) { final T ui = (T) UI.getCurrent(); if (ui == null || !ui.isAttached()) { throw new IllegalStateException("UI is either null or not attached. Ensure it is invoked from within a VaadinRequest"); } return ui; }
try { ui = service.findUI(vaadinRequest); assert UI.getCurrent() == ui;
private TopologyServiceClient getGraphProvider() { UI ui = UI.getCurrent(); if (ui instanceof WidgetContext) { return ((WidgetContext) ui).getGraphContainer().getTopologyServiceClient(); } return null; }
@Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().getNavigator().addViewChangeListener(HeaderLayout.this); UI.getCurrent().getNavigator().navigateTo("dashboard/" + m_nativeSelect.getContainerProperty(m_nativeSelect.getValue(), "title").getValue()); } });
public Window buildAndOpen() { Window window = new Window(); window.setCaption(this.title); window.setContent(this.build()); window.center(); window.setModal(this.modal); UI.getCurrent().addWindow(window); return window; } }