Examples of UI


Examples of com.vaadin.ui.UI

     * connector has not been attached, <code>null</code> is returned.
     *
     * @return The connector's session, or <code>null</code> if not attached
     */
    protected VaadinSession getSession() {
        UI uI = getUI();
        if (uI == null) {
            return null;
        } else {
            return uI.getSession();
        }
    }
View Full Code Here

Examples of com.vaadin.ui.UI

            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);

            stringWriter.write(JsonUtil.stringify(params));
        } catch (JsonException e) {
View Full Code Here

Examples of com.vaadin.ui.UI

        for (UIProvider p : uiProviders) {
            // Check for existing LegacyWindow
            if (p instanceof LegacyApplicationUIProvider) {
                LegacyApplicationUIProvider legacyProvider = (LegacyApplicationUIProvider) p;

                UI existingUi = legacyProvider
                        .getExistingUI(classSelectionEvent);
                if (existingUi != null) {
                    reinitUI(existingUi, request);
                    return existingUi;
                }
            }

            uiClass = p.getUIClass(classSelectionEvent);
            if (uiClass != null) {
                provider = p;
                break;
            }
        }

        if (provider == null || uiClass == null) {
            return null;
        }

        // Check for an existing UI based on embed id

        String embedId = getEmbedId(request);

        UI retainedUI = session.getUIByEmbedId(embedId);
        if (retainedUI != null) {
            if (vaadinService.preserveUIOnRefresh(provider, new UICreateEvent(
                    request, uiClass))) {
                if (uiClass.isInstance(retainedUI)) {
                    reinitUI(retainedUI, request);
                    return retainedUI;
                } else {
                    getLogger().info(
                            "Not using the preserved UI " + embedId
                                    + " because it is of type "
                                    + retainedUI.getClass() + " but " + uiClass
                                    + " is expected for the request.");
                }
            }
            /*
             * Previous UI without preserve on refresh will be closed when the
             * new UI gets added to the session.
             */
        }

        // No existing UI found - go on by creating and initializing one

        Integer uiId = Integer.valueOf(session.getNextUIid());

        // Explicit Class.cast to detect if the UIProvider does something
        // unexpected
        UICreateEvent event = new UICreateEvent(request, uiClass, uiId);
        UI ui = uiClass.cast(provider.createInstance(event));

        // Initialize some fields for a newly created UI
        if (ui.getSession() != session) {
            // Session already set for LegacyWindow
            ui.setSession(session);
        }

        PushMode pushMode = provider.getPushMode(event);
        if (pushMode == null) {
            pushMode = session.getService().getDeploymentConfiguration()
                    .getPushMode();
        }
        ui.getPushConfiguration().setPushMode(pushMode);

        Transport transport = provider.getPushTransport(event);
        if (transport != null) {
            ui.getPushConfiguration().setTransport(transport);
        }

        // Set thread local here so it is available in init
        UI.setCurrent(ui);

        ui.doInit(request, uiId.intValue(), embedId);

        session.addUI(ui);

        // Warn if the window can't be preserved
        if (embedId == null
View Full Code Here

Examples of com.vaadin.ui.UI

    }

    @Override
    public boolean synchronizedHandleRequest(VaadinSession session,
            VaadinRequest request, VaadinResponse response) throws IOException {
        UI uI = session.getService().findUI(request);
        if (uI == null) {
            // This should not happen but it will if the UI has been closed. We
            // really don't want to see it in the server logs though
            response.getWriter().write(
                    getUINotFoundErrorJSON(session.getService(), request));
View Full Code Here

Examples of com.vaadin.ui.UI

     *
     * @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();
    }
View Full Code Here

Examples of com.vaadin.ui.UI

public class AxessingWebPageAndBrowserInfoUI extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        UI someUI = this;

        Page page = someUI.getPage();
        page.addBrowserWindowResizeListener(new BrowserWindowResizeListener() {
            @Override
            public void browserWindowResized(BrowserWindowResizeEvent event) {
                Notification.show("Window width=" + event.getWidth()
                        + ", height=" + event.getHeight());
View Full Code Here

Examples of com.vaadin.ui.UI

    private LegacyCommunicationManager cm;

    @Override
    protected void setUp() throws Exception {
        final VaadinSession application = new AlwaysLockedVaadinSession(null);
        final UI uI = new UI() {
            @Override
            protected void init(VaadinRequest request) {
                // TODO Auto-generated method stub

            }
View Full Code Here

Examples of com.vaadin.ui.UI

        }

    }

    private void prepareMockUI(Component newInstance) {
        UI ui = Mockito.mock(UI.class);
        Mockito.when(ui.getLocale()).thenReturn(Locale.ENGLISH);
        ConnectorTracker connectorTracker = Mockito
                .mock(ConnectorTracker.class);
        Mockito.when(ui.getConnectorTracker()).thenReturn(connectorTracker);
        Mockito.doThrow(new RuntimeException("getState(true) called in getter"))
                .when(connectorTracker).markDirty(newInstance);

        newInstance.setParent(ui);
    }
View Full Code Here

Examples of com.vaadin.ui.UI

    public void addSubWindow() {
        VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null));
        TestApp app = new TestApp();
        app.init();
        Window subWindow = new Window("Sub window");
        UI mainWindow = app.getMainWindow();

        mainWindow.addWindow(subWindow);
        // Added to main window so the parent of the sub window should be the
        // main window
        assertEquals(subWindow.getParent(), mainWindow);

        try {
            mainWindow.addWindow(subWindow);
            assertTrue("Window.addWindow did not throw the expected exception",
                    false);
        } catch (IllegalArgumentException e) {
            // Should throw an exception as it has already been added to the
            // main window
View Full Code Here

Examples of com.vaadin.ui.UI

    @Test
    public void removeSubWindow() {
        TestApp app = new TestApp();
        app.init();
        Window subWindow = new Window("Sub window");
        UI mainWindow = app.getMainWindow();
        mainWindow.addWindow(subWindow);

        // Added to main window so the parent of the sub window should be the
        // main window
        assertEquals(subWindow.getParent(), mainWindow);

        // Parent should still be set
        assertEquals(subWindow.getParent(), mainWindow);

        // Remove from the main window and assert it has been removed
        boolean removed = mainWindow.removeWindow(subWindow);
        assertTrue("Window was not removed correctly", removed);
        assertNull(subWindow.getParent());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.