Example usage for com.google.gwt.user.client Window getClientHeight

List of usage examples for com.google.gwt.user.client Window getClientHeight

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window getClientHeight.

Prototype

public static int getClientHeight() 

Source Link

Usage

From source file:com.vaadin.terminal.gwt.client.ui.VView.java

License:Open Source License

/**
 * Called when a resize event is received.
 *///from   ww w.  j  ava2  s.com
private void onResize() {
    /*
     * IE (pre IE9 at least) will give us some false resize events due to
     * problems with scrollbars. Firefox 3 might also produce some extra
     * events. We postpone both the re-layouting and the server side event
     * for a while to deal with these issues.
     * 
     * We may also postpone these events to avoid slowness when resizing the
     * browser window. Constantly recalculating the layout causes the resize
     * operation to be really slow with complex layouts.
     */
    boolean lazy = resizeLazy || BrowserInfo.get().isIE8();

    if (lazy) {
        delayedResizeExecutor.trigger();
    } else {
        windowSizeMaybeChanged(Window.getClientWidth(), Window.getClientHeight());
    }
}

From source file:com.vaadin.terminal.gwt.client.ui.VWindow.java

License:Open Source License

public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    id = uidl.getId();/*from  w  ww  .j av a2 s.c  om*/
    this.client = client;

    // Workaround needed for Testing Tools (GWT generates window DOM
    // slightly different in different browsers).
    DOM.setElementProperty(closeBox, "id", id + "_window_close");

    if (uidl.hasAttribute("invisible")) {
        hide();
        return;
    }

    if (!uidl.hasAttribute("cached")) {
        if (uidl.getBooleanAttribute("modal") != vaadinModality) {
            setVaadinModality(!vaadinModality);
        }
        if (!isAttached()) {
            setVisible(false); // hide until possible centering
            show();
        }
        if (uidl.getBooleanAttribute("resizable") != resizable) {
            setResizable(!resizable);
        }
        resizeLazy = uidl.hasAttribute(VView.RESIZE_LAZY);

        setDraggable(!uidl.hasAttribute("fixedposition"));

        // Caption must be set before required header size is measured. If
        // the caption attribute is missing the caption should be cleared.
        setCaption(uidl.getStringAttribute("caption"), uidl.getStringAttribute("icon"));
    }

    visibilityChangesDisabled = true;
    if (client.updateComponent(this, uidl, false)) {
        return;
    }
    visibilityChangesDisabled = false;

    clickEventHandler.handleEventHandlerRegistration(client);

    immediate = uidl.hasAttribute("immediate");

    setClosable(!uidl.getBooleanAttribute("readonly"));

    // Initialize the position form UIDL
    int positionx = uidl.getIntVariable("positionx");
    int positiony = uidl.getIntVariable("positiony");
    if (positionx >= 0 || positiony >= 0) {
        if (positionx < 0) {
            positionx = 0;
        }
        if (positiony < 0) {
            positiony = 0;
        }
        setPopupPosition(positionx, positiony);
    }

    boolean showingUrl = false;
    int childIndex = 0;
    UIDL childUidl = uidl.getChildUIDL(childIndex++);
    while ("open".equals(childUidl.getTag())) {
        // TODO multiple opens with the same target will in practice just
        // open the last one - should we fix that somehow?
        final String parsedUri = client.translateVaadinUri(childUidl.getStringAttribute("src"));
        if (!childUidl.hasAttribute("name")) {
            final Frame frame = new Frame();
            DOM.setStyleAttribute(frame.getElement(), "width", "100%");
            DOM.setStyleAttribute(frame.getElement(), "height", "100%");
            DOM.setStyleAttribute(frame.getElement(), "border", "0px");
            frame.setUrl(parsedUri);
            contentPanel.setWidget(frame);
            showingUrl = true;
        } else {
            final String target = childUidl.getStringAttribute("name");
            Window.open(parsedUri, target, "");
        }
        childUidl = uidl.getChildUIDL(childIndex++);
    }

    final Paintable lo = client.getPaintable(childUidl);
    if (layout != null) {
        if (layout != lo) {
            // remove old
            client.unregisterPaintable(layout);
            contentPanel.remove((Widget) layout);
            // add new
            if (!showingUrl) {
                contentPanel.setWidget((Widget) lo);
            }
            layout = lo;
        }
    } else if (!showingUrl) {
        contentPanel.setWidget((Widget) lo);
        layout = lo;
    }

    dynamicWidth = !uidl.hasAttribute("width");
    dynamicHeight = !uidl.hasAttribute("height");

    layoutRelativeWidth = uidl.hasAttribute("layoutRelativeWidth");
    layoutRelativeHeight = uidl.hasAttribute("layoutRelativeHeight");

    if (dynamicWidth && layoutRelativeWidth) {
        /*
         * Relative layout width, fix window width before rendering (width
         * according to caption)
         */
        setNaturalWidth();
    }

    layout.updateFromUIDL(childUidl, client);
    if (!dynamicHeight && layoutRelativeWidth) {
        /*
         * Relative layout width, and fixed height. Must update the size to
         * be able to take scrollbars into account (layout gets narrower
         * space if it is higher than the window) -> only vertical scrollbar
         */
        client.runDescendentsLayout(this);
    }

    /*
     * No explicit width is set and the layout does not have relative width
     * so fix the size according to the layout.
     */
    if (dynamicWidth && !layoutRelativeWidth) {
        setNaturalWidth();
    }

    if (dynamicHeight && layoutRelativeHeight) {
        // Prevent resizing until height has been fixed
        resizable = false;
    }

    // we may have actions and notifications
    if (uidl.getChildCount() > 1) {
        final int cnt = uidl.getChildCount();
        for (int i = 1; i < cnt; i++) {
            childUidl = uidl.getChildUIDL(i);
            if (childUidl.getTag().equals("actions")) {
                if (shortcutHandler == null) {
                    shortcutHandler = new ShortcutActionHandler(id, client);
                }
                shortcutHandler.updateActionMap(childUidl);
            }
        }

    }

    // setting scrollposition must happen after children is rendered
    contentPanel.setScrollPosition(uidl.getIntVariable("scrollTop"));
    contentPanel.setHorizontalScrollPosition(uidl.getIntVariable("scrollLeft"));

    // Center this window on screen if requested
    // This has to be here because we might not know the content size before
    // everything is painted into the window
    if (uidl.getBooleanAttribute("center")) {
        // mark as centered - this is unset on move/resize
        centered = true;
        center();
    } else {
        // don't try to center the window anymore
        centered = false;
    }
    updateShadowSizeAndPosition();
    setVisible(true);

    boolean sizeReduced = false;
    // ensure window is not larger than browser window
    if (getOffsetWidth() > Window.getClientWidth()) {
        setWidth(Window.getClientWidth() + "px");
        sizeReduced = true;
    }
    if (getOffsetHeight() > Window.getClientHeight()) {
        setHeight(Window.getClientHeight() + "px");
        sizeReduced = true;
    }

    if (dynamicHeight && layoutRelativeHeight) {
        /*
         * Window height is undefined, layout is 100% high so the layout
         * should define the initial window height but on resize the layout
         * should be as high as the window. We fix the height to deal with
         * this.
         */

        int h = contents.getOffsetHeight() + getExtraHeight();
        int w = getElement().getOffsetWidth();

        client.updateVariable(id, "height", h, false);
        client.updateVariable(id, "width", w, true);
    }

    if (sizeReduced) {
        // If we changed the size we need to update the size of the child
        // component if it is relative (#3407)
        client.runDescendentsLayout(this);
    }

    Util.runWebkitOverflowAutoFix(contentPanel.getElement());

    client.getView().scrollIntoView(uidl);

    if (uidl.hasAttribute("bringToFront")) {
        /*
         * Focus as a side-efect. Will be overridden by
         * ApplicationConnection if another component was focused by the
         * server side.
         */
        contentPanel.focus();
        bringToFrontSequence = uidl.getIntAttribute("bringToFront");
        deferOrdering();
    }
}

From source file:com.vaadin.terminal.gwt.client.VDebugConsole.java

License:Open Source License

private void setToDefaultSizeAndPos() {
    String cookie = Cookies.getCookie(POS_COOKIE_NAME);
    int width, height, top, left;
    boolean autoScrollValue = false;
    if (cookie != null) {
        String[] split = cookie.split(",");
        left = Integer.parseInt(split[0]);
        top = Integer.parseInt(split[1]);
        width = Integer.parseInt(split[2]);
        height = Integer.parseInt(split[3]);
        autoScrollValue = Boolean.valueOf(split[4]);
    } else {// w  w  w.j  av a  2s  .  c om
        width = 400;
        height = 150;
        top = Window.getClientHeight() - 160;
        left = Window.getClientWidth() - 410;
    }
    setPixelSize(width, height);
    setPopupPosition(left, top);
    autoScroll.setValue(autoScrollValue);
}

From source file:com.vaadin.terminal.gwt.client.VTooltip.java

License:Open Source License

/**
 * Show a popup containing the information in the "info" tooltip
 * /*from  ww  w .  jav  a2 s.  c o  m*/
 * @param info
 */
private void show(TooltipInfo info) {
    boolean hasContent = false;
    if (info.getErrorUidl() != null) {
        em.setVisible(true);
        em.updateFromUIDL(info.getErrorUidl());
        hasContent = true;
    } else {
        em.setVisible(false);
    }
    if (info.getTitle() != null && !"".equals(info.getTitle())) {
        DOM.setInnerHTML(description, info.getTitle());
        DOM.setStyleAttribute(description, "display", "");
        hasContent = true;
    } else {
        DOM.setInnerHTML(description, "");
        DOM.setStyleAttribute(description, "display", "none");
    }
    if (hasContent) {
        setPopupPositionAndShow(new PositionCallback() {
            public void setPosition(int offsetWidth, int offsetHeight) {

                if (offsetWidth > MAX_WIDTH) {
                    setWidth(MAX_WIDTH + "px");

                    // Check new height and width with reflowed content
                    offsetWidth = getOffsetWidth();
                    offsetHeight = getOffsetHeight();
                }

                int x = tooltipEventMouseX + 10 + Window.getScrollLeft();
                int y = tooltipEventMouseY + 10 + Window.getScrollTop();

                if (x + offsetWidth + MARGIN - Window.getScrollLeft() > Window.getClientWidth()) {
                    x = Window.getClientWidth() - offsetWidth - MARGIN;
                }

                if (y + offsetHeight + MARGIN - Window.getScrollTop() > Window.getClientHeight()) {
                    y = tooltipEventMouseY - 5 - offsetHeight;
                    if (y - Window.getScrollTop() < 0) {
                        // tooltip does not fit on top of the mouse either,
                        // put it at the top of the screen
                        y = Window.getScrollTop();
                    }
                }

                setPopupPosition(x, y);
                sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT);
            }
        });
    } else {
        hide();
    }
}

From source file:com.webgocommerce.client.Main.java

private void initStyle() {
    int alto = Window.getClientHeight();
    img.setWidth("100%");
    img.setHeight(alto + "px");
    btnEntrar.getElement().setId("btnEntrar");
}

From source file:com.webgocommerce.client.uiutil.UIBuscarCliente.java

private void reCalcularWindows() {
    int alto = Window.getClientHeight();
    this.getPnlTabla().setHeight(alto - 340 + "px");
}

From source file:com.webgocommerce.client.uiutil.UIGridDetalleVenta.java

private void initStyle() {
    int ancho = Window.getClientWidth() - 5;
    int alto = (Window.getClientHeight()) / 3;
    pnlContenedor.setWidth(ancho + "px");
    pnlContenedor.setHeight(alto + "px");
    grid.setWidth("99%");
    grid.getElement().getStyle().setBorderStyle(Style.BorderStyle.SOLID);
    grid.getElement().getStyle().setBorderWidth(0.2, Style.Unit.PX);
    grid.getElement().getStyle().setFloat(Style.Float.LEFT);
    grid.getElement().getStyle().setMargin(3, Style.Unit.PX);
}

From source file:com.webgocommerce.client.uiutil.UIItem.java

private void initStyle() {
    int ancho = Window.getClientWidth() - 5;
    int alto = (Window.getClientHeight()) / 3;
    pnlContenedor.setWidth(ancho + "px");
    pnlContenedor.setHeight(alto + "px");
    gridItem.setHeight("97%");
    gridItem.setWidth("99%");
    gridItem.setColumnWidth(gridItem.descripcion, 85, Style.Unit.PCT);
    gridItem.getElement().getStyle().setBorderStyle(Style.BorderStyle.SOLID);
    gridItem.getElement().getStyle().setBorderWidth(0.2, Style.Unit.PX);
    gridItem.getElement().getStyle().setFloat(Style.Float.LEFT);
    gridItem.getElement().getStyle().setMargin(3, Style.Unit.PX);
}

From source file:com.webgocommerce.client.uiutil.UIStockItemAlmacen.java

private void initStyle() {
    int ancho = Window.getClientWidth() - 5;
    int alto = (Window.getClientHeight()) / 3;
    pnlContenedor.setWidth(ancho + "px");
    pnlContenedor.setHeight(alto + "px");
    gridItem.setHeight("97%");
    gridItem.setWidth("69%");
    gridAlmacen.setHeight("97%");
    gridAlmacen.setWidth("29%");
    gridItem.getElement().getStyle().setBorderStyle(Style.BorderStyle.SOLID);
    gridItem.getElement().getStyle().setBorderWidth(0.2, Style.Unit.PX);
    gridItem.getElement().getStyle().setFloat(Style.Float.LEFT);
    gridItem.getElement().getStyle().setMargin(3, Style.Unit.PX);
    gridAlmacen.getElement().getStyle().setBorderStyle(Style.BorderStyle.SOLID);
    gridAlmacen.getElement().getStyle().setBorderWidth(0.2, Style.Unit.PX);
    gridAlmacen.getElement().getStyle().setFloat(Style.Float.LEFT);
    gridAlmacen.getElement().getStyle().setMargin(3, Style.Unit.PX);
}

From source file:com.webgocommerce.client.view.uiaddconsultor.UIAddConsultor.java

private void reCalcularWindows() {
    int alto = Window.getClientHeight();
    this.getPnlTabla().setHeight(alto - 280 + "px");
    //this.getPnlBotones().setHeight(alto-150 + "px");
}