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.google.appinventor.client.Ode.java

License:Open Source License

private void resizeWorkArea(WorkAreaPanel workArea) {
    // Subtract 16px from width to account for vertical scrollbar FF3 likes to add
    workArea.onResize(Window.getClientWidth() - 16, Window.getClientHeight());
}

From source file:com.google.appinventor.client.widgets.properties.AdditionalChoicePropertyEditor.java

License:Open Source License

/**
 * Opens the additional choice dialog.//w w w . ja v a 2 s .c o  m
 */
protected void openAdditionalChoiceDialog() {
    popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
        public void setPosition(int offsetWidth, int offsetHeight) {
            // adjust the x and y positions so that the entire panel
            // is on-screen
            int xPosition = getAbsoluteLeft();
            int yPosition = getAbsoluteTop();
            int xExtrude = xPosition + offsetWidth - Window.getClientWidth() - Window.getScrollLeft();
            int yExtrude = yPosition + offsetHeight - Window.getClientHeight() - Window.getScrollTop();
            if (xExtrude > 0) {
                xPosition -= (xExtrude + ADDITIONAL_CHOICE_ONSCREEN_PADDING);
            }
            if (yExtrude > 0) {
                yPosition -= (yExtrude + ADDITIONAL_CHOICE_ONSCREEN_PADDING);
            }
            popup.setPopupPosition(xPosition, yPosition);
        }
    });
}

From source file:com.google.appinventor.client.wizards.Wizard.java

License:Open Source License

/**
 * {@inheritDoc}/*w w  w.  j  av  a  2s .com*/
 *
 * Subclasses may override this to perform additional actions
 * after the wizard is shown, such as explicitly setting the
 * initially focused widget. Remember to call {@code super.show()}
 * as the first action in such overriding methods.
 */
@Override
public void show() {
    ensureInited();

    // Wizard size (having it resize between page changes is quite annoying)
    int width = 480;
    int height = 320;
    if (adaptiveSizing) {
        width = Math.max(width, Window.getClientWidth() / 3);
        height = Math.max(height, Window.getClientHeight() / 2);
    }
    setPixelSize(width, height);

    super.show();

    if (pageDeck.getWidgetCount() == 1) {
        buttonPanel.remove(backButton);
        buttonPanel.remove(nextButton);
    }

    // Show first wizard page
    currentPageIndex = 0;
    showCurrentPage();
}

From source file:com.google.code.p.gwtchismes.client.GWTCDatePickerAbstract.java

License:Apache License

private void moveIntoVisibleArea() {
    if (calendarDlg != null) {
        int w = Window.getClientWidth() + Window.getScrollLeft();
        int xd = calendarDlg.getAbsoluteLeft();
        int wd = calendarGrid.getOffsetWidth() + 40;
        if ((xd + wd) > w) {
            xd = xd - ((xd + wd) - w);/* w  w  w.  j  a v a 2 s .  com*/
        }

        int h = Window.getClientHeight() + Window.getScrollTop();
        int yd = calendarDlg.getAbsoluteTop();
        int hd = calendarDlg.getOffsetHeight() + 20;
        if ((yd + hd) > h) {
            yd = yd - ((yd + hd) - h);
        }
        calendarDlg.setPopupPosition(xd, yd);
    }
}

From source file:com.google.collide.client.ui.menu.PositionController.java

License:Open Source License

/**
 * Checks if the element is completely visible on the screen, if not it will temporarily flip our
 * {@link #elementPositioner} with updated alignment values which might work to fix the problem.
 */// w  w w.ja v  a  2 s .c  o m
private boolean checkPositionValidAndMaybeUpdatePositioner() {
    // recalculate the element's dimensions and check to see if any of the edges
    // of the element are outside the window
    ClientRect elementRect = ensureVisibleAndGetRect(element);

    VerticalAlign updatedVerticalAlign = elementPositioner.getVerticalAlignment();
    HorizontalAlign updatedHorizontalAlign = elementPositioner.getHorizontalAlignment();

    if (elementRect.getBottom() > Window.getClientHeight()) {
        updatedVerticalAlign = VerticalAlign.TOP;
    } else if (elementRect.getTop() < 0) {
        updatedVerticalAlign = VerticalAlign.BOTTOM;
    }

    if (elementRect.getRight() > Window.getClientWidth()) {
        updatedHorizontalAlign = HorizontalAlign.RIGHT;
    } else if (elementRect.getLeft() < 0) {
        updatedHorizontalAlign = HorizontalAlign.LEFT;
    }

    if (updatedVerticalAlign != elementPositioner.getVerticalAlignment()
            || updatedHorizontalAlign != elementPositioner.getHorizontalAlignment()) {
        elementPositioner.flip(updatedVerticalAlign, updatedHorizontalAlign);
        return false;
    }
    return true;
}

From source file:com.google.gerrit.client.diff.CodeMirrorDemo.java

License:Apache License

private CodeMirror displaySide(DiffInfo.FileMeta meta, String contents, Element ele) {
    if (meta == null) {
        contents = "";
    }/*from  w  w w  .  j  a  v  a  2 s.  com*/
    Configuration cfg = Configuration.create().set("readOnly", true).set("lineNumbers", true).set("tabSize", 2)
            .set("mode", getContentType(meta)).set("value", contents).setInfinity("viewportMargin");
    final CodeMirror cm = CodeMirror.create(ele, cfg);
    cm.setWidth("100%");
    cm.setHeight(Window.getClientHeight() - HEADER_FOOTER);
    return cm;
}

From source file:com.google.gerrit.client.diff.SideBySide.java

License:Apache License

private void display(CommentsCollections comments) {
    DiffInfo diff = getDiff();//from   w ww.  ja v  a 2  s  . c o  m
    setThemeStyles(prefs.theme().isDark());
    setShowIntraline(prefs.intralineDifference());
    if (prefs.showLineNumbers()) {
        diffTable.addStyleName(Resources.I.diffTableStyle().showLineNumbers());
    }

    cmA = newCm(diff.metaA(), diff.textA(), diffTable.cmA);
    cmB = newCm(diff.metaB(), diff.textB(), diffTable.cmB);

    getDiffTable().setUpBlameIconA(cmA, base.isBaseOrAutoMerge(),
            base.isBaseOrAutoMerge() ? revision : base.asPatchSetId(), path);
    getDiffTable().setUpBlameIconB(cmB, revision, path);

    cmA.extras().side(DisplaySide.A);
    cmB.extras().side(DisplaySide.B);
    setShowTabs(prefs.showTabs());

    chunkManager = new SideBySideChunkManager(this, cmA, cmB, diffTable.scrollbar);

    operation(() -> {
        // Estimate initial CodeMirror height, fixed up in onShowView.
        int height = Window.getClientHeight() - (Gerrit.getHeaderFooterHeight() + 18);
        cmA.setHeight(height);
        cmB.setHeight(height);

        render(diff);
        commentManager.render(comments, prefs.expandAllComments());
        skipManager.render(prefs.context(), diff);
    });

    registerCmEvents(cmA);
    registerCmEvents(cmB);
    scrollSynchronizer = new ScrollSynchronizer(diffTable, cmA, cmB, chunkManager.lineMapper);

    setPrefsAction(new PreferencesAction(this, prefs));
    header.init(getPrefsAction(), getUnifiedDiffLink(), diff.sideBySideWebLinks());
    scrollSynchronizer.setAutoHideDiffTableHeader(prefs.autoHideDiffTableHeader());

    setupSyntaxHighlighting();
}

From source file:com.google.gerrit.client.diff.SideBySide2.java

License:Apache License

private void display(final CommentsCollections comments) {
    setThemeStyles(prefs.theme().isDark());
    setShowTabs(prefs.showTabs());/*from   ww  w .j  a  v  a 2s  .  co m*/
    setShowIntraline(prefs.intralineDifference());
    if (prefs.showLineNumbers()) {
        diffTable.addStyleName(DiffTable.style.showLineNumbers());
    }

    cmA = newCM(diff.meta_a(), diff.text_a(), DisplaySide.A, diffTable.cmA);
    cmB = newCM(diff.meta_b(), diff.text_b(), DisplaySide.B, diffTable.cmB);
    diffTable.overview.init(cmB);
    chunkManager = new ChunkManager(this, cmA, cmB, diffTable.overview);
    skipManager = new SkipManager(this, commentManager);

    columnMarginA = DOM.createDiv();
    columnMarginB = DOM.createDiv();
    columnMarginA.setClassName(DiffTable.style.columnMargin());
    columnMarginB.setClassName(DiffTable.style.columnMargin());
    cmA.getMoverElement().appendChild(columnMarginA);
    cmB.getMoverElement().appendChild(columnMarginB);

    if (prefs.renderEntireFile() && !canEnableRenderEntireFile(prefs)) {
        // CodeMirror is too slow to layout an entire huge file.
        prefs.renderEntireFile(false);
    }

    operation(new Runnable() {
        public void run() {
            // Estimate initial CM3 height, fixed up in onShowView.
            int height = Window.getClientHeight() - (Gerrit.getHeaderFooterHeight() + 18);
            cmA.setHeight(height);
            cmB.setHeight(height);

            render(diff);
            commentManager.render(comments, prefs.expandAllComments());
            skipManager.render(prefs.context(), diff);
        }
    });

    registerCmEvents(cmA);
    registerCmEvents(cmB);
    scrollSynchronizer = new ScrollSynchronizer(diffTable, cmA, cmB, chunkManager.getLineMapper());

    prefsAction = new PreferencesAction(this, prefs);
    header.init(prefsAction);

    if (prefs.syntaxHighlighting() && fileSize.compareTo(FileSize.SMALL) > 0) {
        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
            @Override
            public boolean execute() {
                if (prefs.syntaxHighlighting() && isAttached()) {
                    setSyntaxHighlighting(prefs.syntaxHighlighting());
                }
                return false;
            }
        }, 250);
    }
}

From source file:com.google.gerrit.client.diff.SideBySide2.java

License:Apache License

private int getCodeMirrorHeight() {
    int rest = Gerrit.getHeaderFooterHeight() + header.getOffsetHeight() + diffTable.getHeaderHeight() + 5; // Estimate
    return Window.getClientHeight() - rest;
}

From source file:com.google.gerrit.client.diff.Unified.java

License:Apache License

private void display(CommentsCollections comments) {
    DiffInfo diff = getDiff();//from www .  ja v a2  s  . co  m
    setThemeStyles(prefs.theme().isDark());
    setShowIntraline(prefs.intralineDifference());
    if (prefs.showLineNumbers()) {
        diffTable.addStyleName(Resources.I.diffTableStyle().showLineNumbers());
    }

    cm = newCm(diff.metaA() == null ? diff.metaB() : diff.metaA(), diff.textUnified(), diffTable.cm);
    setShowTabs(prefs.showTabs());

    chunkManager = new UnifiedChunkManager(this, cm, diffTable.scrollbar);

    operation(() -> {
        // Estimate initial CodeMirror height, fixed up in onShowView.
        int height = Window.getClientHeight() - (Gerrit.getHeaderFooterHeight() + 18);
        cm.setHeight(height);

        render(diff);
        commentManager.render(comments, prefs.expandAllComments());
        skipManager.render(prefs.context(), diff);
    });

    registerCmEvents(cm);

    setPrefsAction(new PreferencesAction(this, prefs));
    header.init(getPrefsAction(), getSideBySideDiffLink(), diff.unifiedWebLinks());
    setAutoHideDiffHeader(prefs.autoHideDiffTableHeader());

    setupSyntaxHighlighting();
}