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

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

Introduction

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

Prototype

public static int getScrollLeft() 

Source Link

Usage

From source file:org.opendatakit.aggregate.client.popups.AbstractPopupBase.java

License:Apache License

public PopupPanel.PositionCallback getPositionCallBack() {
    return new PopupPanel.PositionCallback() {
        @Override//ww w . java2s.co m
        public void setPosition(int offsetWidth, int offsetHeight) {
            int left = Window.getScrollLeft() + ((Window.getClientWidth() - offsetWidth) / 2);
            int top = Window.getScrollTop() + ((Window.getClientHeight() - offsetHeight) / 2);
            setPopupPosition(left, top);
        }
    };
}

From source file:org.opennms.dashboard.client.portlet.Dashboard.java

License:Open Source License

/**
 * <p>/*from   w  ww  . j  a  v a  2s .co m*/
 * error
 * </p>
 * 
 * @param err
 *            a {@link java.lang.String} object.
 */
public void error(String err) {
    final DialogBox dialog = new DialogBox();
    dialog.setText("Error Occurred");

    VerticalPanel panel = new VerticalPanel();
    HTMLPanel html = new HTMLPanel(err);
    html.setStyleName("Message");
    panel.add(html);

    Button ok = new Button("OK");
    SimplePanel buttonPanel = new SimplePanel();
    buttonPanel.setWidget(ok);
    buttonPanel.setStyleName("Button");
    panel.add(buttonPanel);

    dialog.setPopupPosition(Window.getScrollLeft() + 100, Window.getScrollTop() + 100);
    dialog.setWidget(panel);

    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            dialog.hide();
        }

    });

    dialog.show();

}

From source file:org.opennms.features.dashboard.client.portlet.AbsPopup.java

License:Open Source License

public void center() {

    int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
    int top = (Window.getClientHeight() - getOffsetHeight()) >> 1;
    RootPanel.get().add(this, Math.max(Window.getScrollLeft() + left, 0),
            Math.max(Window.getScrollTop() + top, 0));
    if (!isVisible()) {
        setVisible(true);/* www . j a v  a 2  s .  co m*/
    }
}

From source file:org.openremote.app.client.toast.PopupToastDisplay.java

License:Open Source License

@Override
public void show(final Toast toast) {
    final ToastPopupPanel panel = new ToastPopupPanel(toast);

    panel.setPopupPositionAndShow((offsetWidth, offsetHeight) -> {
        int originLeft = Window.getScrollLeft() + Window.getClientWidth() - offsetWidth - MARGIN_RIGHT_PIXEL;
        int originTop = Window.getScrollTop() + Window.getClientHeight() - offsetHeight - MARGIN_BOTTOM_PIXEL;
        setRelativePosition(toastPanels.values(), panel, originLeft, originTop, originTop, offsetHeight,
                offsetWidth);//from w  ww . j  ava 2  s  .c om
    });

    toastPanels.put(toast, panel);
}

From source file:org.openremote.app.client.widget.PopupPanel.java

License:Apache License

/**
 * Positions the popup, called after the offset width and height of the popup
 * are known.//www .  j  a va2  s .  c  o  m
 *
 * @param relativeObject the ui object to position relative to
 * @param offsetWidth the drop down's offset width
 * @param offsetHeight the drop down's offset height
 */
private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) {
    // Calculate left position for the popup. The computation for
    // the left position is bidi-sensitive.

    int textBoxOffsetWidth = relativeObject.getOffsetWidth();

    // Compute the difference between the popup's width and the
    // textbox's width
    int offsetWidthDiff = offsetWidth - textBoxOffsetWidth;

    int left;

    if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case

        int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft();

        // Right-align the popup. Note that this computation is
        // valid in the case where offsetWidthDiff is negative.
        left = textBoxAbsoluteLeft - offsetWidthDiff;

        // If the suggestion popup is not as wide as the text box, always
        // align to the right edge of the text box. Otherwise, figure out whether
        // to right-align or left-align the popup.
        if (offsetWidthDiff > 0) {

            // Make sure scrolling is taken into account, since
            // box.getAbsoluteLeft() takes scrolling into account.
            int windowRight = Window.getClientWidth() + Window.getScrollLeft();
            int windowLeft = Window.getScrollLeft();

            // Compute the left value for the right edge of the textbox
            int textBoxLeftValForRightEdge = textBoxAbsoluteLeft + textBoxOffsetWidth;

            // Distance from the right edge of the text box to the right edge
            // of the window
            int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge;

            // Distance from the right edge of the text box to the left edge of the
            // window
            int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft;

            // If there is not enough space for the overflow of the popup's
            // width to the right of the text box and there IS enough space for the
            // overflow to the right of the text box, then left-align the popup.
            // However, if there is not enough space on either side, stick with
            // right-alignment.
            if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) {
                // Align with the left edge of the text box.
                left = textBoxAbsoluteLeft;
            }
        }
    } else { // LTR case

        // Left-align the popup.
        left = relativeObject.getAbsoluteLeft();

        // If the suggestion popup is not as wide as the text box, always align to
        // the left edge of the text box. Otherwise, figure out whether to
        // left-align or right-align the popup.
        if (offsetWidthDiff > 0) {
            // Make sure scrolling is taken into account, since
            // box.getAbsoluteLeft() takes scrolling into account.
            int windowRight = Window.getClientWidth() + Window.getScrollLeft();
            int windowLeft = Window.getScrollLeft();

            // Distance from the left edge of the text box to the right edge
            // of the window
            int distanceToWindowRight = windowRight - left;

            // Distance from the left edge of the text box to the left edge of the
            // window
            int distanceFromWindowLeft = left - windowLeft;

            // If there is not enough space for the overflow of the popup's
            // width to the right of hte text box, and there IS enough space for the
            // overflow to the left of the text box, then right-align the popup.
            // However, if there is not enough space on either side, then stick with
            // left-alignment.
            if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) {
                // Align with the right edge of the text box.
                left -= offsetWidthDiff;
            }
        }
    }

    // Calculate top position for the popup

    int top = relativeObject.getAbsoluteTop();

    // Make sure scrolling is taken into account, since
    // box.getAbsoluteTop() takes scrolling into account.
    int windowTop = Window.getScrollTop();
    int windowBottom = Window.getScrollTop() + Window.getClientHeight();

    // Distance from the top edge of the window to the top edge of the
    // text box
    int distanceFromWindowTop = top - windowTop;

    // Distance from the bottom edge of the window to the bottom edge of
    // the text box
    int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight());

    // If there is not enough space for the popup's height below the text
    // box and there IS enough space for the popup's height above the text
    // box, then position the popup above the text box. However, if there
    // is not enough space on either side, then stick with displaying the
    // popup below the text box.
    if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) {
        top -= offsetHeight;
    } else {
        // Position above the text box
        top += relativeObject.getOffsetHeight();
    }
    setPopupPosition(left, top);
}

From source file:org.pentaho.gwt.widgets.client.dialogs.ResizableDialogBox.java

License:Open Source License

public void center() {
    boundaryPanel.clear();//from   w ww. j av a  2s  .com
    int left = (Window.getClientWidth() - windowPanel.getOffsetWidth()) >> 1;
    int top = (Window.getClientHeight() - windowPanel.getOffsetHeight()) >> 1;
    boundaryPanel.add(windowPanel, Window.getScrollLeft() + left, Window.getScrollTop() + top);
    left = (Window.getClientWidth() - windowPanel.getOffsetWidth()) >> 1;
    top = (Window.getClientHeight() - windowPanel.getOffsetHeight()) >> 1;
    boundaryPanel.clear();
    boundaryPanel.add(windowPanel, Window.getScrollLeft() + left, Window.getScrollTop() + top);
    // hide <embeds>
    FrameUtils.toggleEmbedVisibility(false);
}

From source file:org.pentaho.mantle.client.solutionbrowser.tabs.TabWidget.java

License:Open Source License

public void onBrowserEvent(Event event) {
    // the id's which are set on these menu items must be set AFTER the items are added to their menu
    // when an element is added to a menu an auto-generated id will be assigned, so we must override this
    if (perspective != null) {
        if ((DOM.eventGetType(event) & Event.ONDBLCLICK) == Event.ONDBLCLICK) {
            openTabInNewWindow();//w  w w . ja va 2s . co m
        } else if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {
            int left = Window.getScrollLeft() + DOM.eventGetClientX(event);
            int top = Window.getScrollTop() + DOM.eventGetClientY(event);
            popupMenu.setPopupPosition(left, top);
            MenuBar menuBar = new MenuBar(true);
            menuBar.setAutoOpen(true);
            if (tabContent instanceof IFrameTabPanel) {
                MenuItem backMenuItem = new MenuItem(Messages.getString("back"), //$NON-NLS-1$
                        new TabCommand(TABCOMMANDTYPE.BACK, popupMenu));
                menuBar.addItem(backMenuItem);
                backMenuItem.getElement().setId("back"); //$NON-NLS-1$
                menuBar.addSeparator();
                MenuItem reloadTabMenuItem = new MenuItem(Messages.getString("reloadTab"), //$NON-NLS-1$
                        new TabCommand(TABCOMMANDTYPE.RELOAD, popupMenu));
                menuBar.addItem(reloadTabMenuItem);
                reloadTabMenuItem.getElement().setId("reloadTab"); //$NON-NLS-1$
            }
            if (tabPanel.getTabBar().getTabCount() > 1) {
                MenuItem reloadAllTabsMenuItem = new MenuItem(Messages.getString("reloadAllTabs"), //$NON-NLS-1$
                        new TabCommand(TABCOMMANDTYPE.RELOAD_ALL, popupMenu));
                menuBar.addItem(reloadAllTabsMenuItem);
                reloadAllTabsMenuItem.getElement().setId("reloadAllTabs"); //$NON-NLS-1$
            } else {
                MenuItem reloadAllTabsMenuItem = new MenuItem(Messages.getString("reloadAllTabs"), //$NON-NLS-1$
                        (Command) null);
                menuBar.addItem(reloadAllTabsMenuItem);
                reloadAllTabsMenuItem.getElement().setId("reloadAllTabs"); //$NON-NLS-1$
                reloadAllTabsMenuItem.setStyleName("disabledMenuItem"); //$NON-NLS-1$
            }
            menuBar.addSeparator();
            if (tabContent instanceof IFrameTabPanel) {
                MenuItem openTabInNewWindowMenuItem = new MenuItem(Messages.getString("openTabInNewWindow"), //$NON-NLS-1$
                        new TabCommand(TABCOMMANDTYPE.NEW_WINDOW, popupMenu));
                menuBar.addItem(openTabInNewWindowMenuItem);
                openTabInNewWindowMenuItem.getElement().setId("openTabInNewWindow"); //$NON-NLS-1$
                MenuItem createDeepLinkMenuItem = new MenuItem(Messages.getString("createDeepLink"), //$NON-NLS-1$
                        new TabCommand(TABCOMMANDTYPE.CREATE_DEEP_LINK, popupMenu));
                menuBar.addItem(createDeepLinkMenuItem);
                createDeepLinkMenuItem.getElement().setId("deepLink"); //$NON-NLS-1$
                menuBar.addSeparator();
            }
            menuBar.addItem(new MenuItem(Messages.getString("closeTab"), //$NON-NLS-1$
                    new TabCommand(TABCOMMANDTYPE.CLOSE, popupMenu)));
            if (tabPanel.getTabBar().getTabCount() > 1) {
                MenuItem closeOtherTabsMenuItem = new MenuItem(Messages.getString("closeOtherTabs"), //$NON-NLS-1$
                        new TabCommand(TABCOMMANDTYPE.CLOSE_OTHERS, popupMenu));
                menuBar.addItem(closeOtherTabsMenuItem);
                closeOtherTabsMenuItem.getElement().setId("closeOtherTabs"); //$NON-NLS-1$
                MenuItem closeAllTabsMenuItem = new MenuItem(Messages.getString("closeAllTabs"), //$NON-NLS-1$
                        new TabCommand(TABCOMMANDTYPE.CLOSE_ALL, popupMenu));
                menuBar.addItem(closeAllTabsMenuItem);
                closeAllTabsMenuItem.getElement().setId("closeAllTabs"); //$NON-NLS-1$
            } else {
                MenuItem closeOtherTabsMenuItem = new MenuItem(Messages.getString("closeOtherTabs"), //$NON-NLS-1$
                        (Command) null);
                closeOtherTabsMenuItem.setStyleName("disabledMenuItem"); //$NON-NLS-1$
                MenuItem closeAllTabsMenuItem = new MenuItem(Messages.getString("closeAllTabs"), //$NON-NLS-1$
                        (Command) null);
                closeAllTabsMenuItem.setStyleName("disabledMenuItem"); //$NON-NLS-1$
                menuBar.addItem(closeOtherTabsMenuItem);
                menuBar.addItem(closeAllTabsMenuItem);
                closeOtherTabsMenuItem.getElement().setId("closeOtherTabs"); //$NON-NLS-1$
                closeAllTabsMenuItem.getElement().setId("closeAllTabs"); //$NON-NLS-1$
            }
            popupMenu.setWidget(menuBar);
            popupMenu.hide();
            popupMenu.show();
        }
    }
    super.onBrowserEvent(event);
}

From source file:org.pentaho.mantle.client.ui.tabs.MantleTab.java

License:Open Source License

public void onRightClick(Event event) {
    FrameUtils.setEmbedVisibility(((IFrameTabPanel) getTabPanel().getSelectedTab().getContent()).getFrame(),
            false);/*from  w  w w  .j  a  va 2s  . c  om*/

    int left = Window.getScrollLeft() + DOM.eventGetClientX(event);
    int top = Window.getScrollTop() + DOM.eventGetClientY(event);
    popupMenu.setPopupPosition(adjustLeftIfNecessary(left), top);
    MenuBar menuBar = new MenuBar(true);
    menuBar.setAutoOpen(true);
    if (getContent() instanceof IFrameTabPanel) {
        MenuItem backMenuItem = new MenuItem(Messages.getString("back"), //$NON-NLS-1$
                new TabCommand(TABCOMMANDTYPE.BACK, popupMenu));
        menuBar.addItem(backMenuItem);
        backMenuItem.getElement().setId("back"); //$NON-NLS-1$
        menuBar.addSeparator();
        MenuItem reloadTabMenuItem = new MenuItem(Messages.getString("reloadTab"), //$NON-NLS-1$
                new TabCommand(TABCOMMANDTYPE.RELOAD, popupMenu));
        menuBar.addItem(reloadTabMenuItem);
        reloadTabMenuItem.getElement().setId("reloadTab"); //$NON-NLS-1$
    }
    if (getTabPanel().getTabCount() > 1) {
        MenuItem reloadAllTabsMenuItem = new MenuItem(Messages.getString("reloadAllTabs"), //$NON-NLS-1$
                new TabCommand(TABCOMMANDTYPE.RELOAD_ALL, popupMenu));
        menuBar.addItem(reloadAllTabsMenuItem);
        reloadAllTabsMenuItem.getElement().setId("reloadAllTabs"); //$NON-NLS-1$
    } else {
        MenuItem reloadAllTabsMenuItem = new MenuItem(Messages.getString("reloadAllTabs"), (Command) null); //$NON-NLS-1$
        menuBar.addItem(reloadAllTabsMenuItem);
        reloadAllTabsMenuItem.getElement().setId("reloadAllTabs"); //$NON-NLS-1$
        reloadAllTabsMenuItem.setStyleName("disabledMenuItem"); //$NON-NLS-1$
    }
    menuBar.addSeparator();
    if (getContent() instanceof IFrameTabPanel) {
        MenuItem openTabInNewWindowMenuItem = new MenuItem(Messages.getString("openTabInNewWindow"), //$NON-NLS-1$
                new TabCommand(TABCOMMANDTYPE.NEW_WINDOW, popupMenu));
        menuBar.addItem(openTabInNewWindowMenuItem);
        openTabInNewWindowMenuItem.getElement().setId("openTabInNewWindow"); //$NON-NLS-1$
        MenuItem createDeepLinkMenuItem = new MenuItem(Messages.getString("createDeepLink"), //$NON-NLS-1$
                new TabCommand(TABCOMMANDTYPE.CREATE_DEEP_LINK, popupMenu));
        menuBar.addItem(createDeepLinkMenuItem);
        createDeepLinkMenuItem.getElement().setId("deepLink"); //$NON-NLS-1$
        menuBar.addSeparator();
    }
    menuBar.addItem(
            new MenuItem(Messages.getString("closeTab"), new TabCommand(TABCOMMANDTYPE.CLOSE, popupMenu))); //$NON-NLS-1$
    if (getTabPanel().getTabCount() > 1) {
        MenuItem closeOtherTabsMenuItem = new MenuItem(Messages.getString("closeOtherTabs"), //$NON-NLS-1$
                new TabCommand(TABCOMMANDTYPE.CLOSE_OTHERS, popupMenu));
        menuBar.addItem(closeOtherTabsMenuItem);
        closeOtherTabsMenuItem.getElement().setId("closeOtherTabs"); //$NON-NLS-1$
        MenuItem closeAllTabsMenuItem = new MenuItem(Messages.getString("closeAllTabs"), //$NON-NLS-1$
                new TabCommand(TABCOMMANDTYPE.CLOSE_ALL, popupMenu));
        menuBar.addItem(closeAllTabsMenuItem);
        closeAllTabsMenuItem.getElement().setId("closeAllTabs"); //$NON-NLS-1$
    } else {
        MenuItem closeOtherTabsMenuItem = new MenuItem(Messages.getString("closeOtherTabs"), (Command) null); //$NON-NLS-1$
        closeOtherTabsMenuItem.setStyleName("disabledMenuItem"); //$NON-NLS-1$
        MenuItem closeAllTabsMenuItem = new MenuItem(Messages.getString("closeAllTabs"), (Command) null); //$NON-NLS-1$
        closeAllTabsMenuItem.setStyleName("disabledMenuItem"); //$NON-NLS-1$
        menuBar.addItem(closeOtherTabsMenuItem);
        menuBar.addItem(closeAllTabsMenuItem);
        closeOtherTabsMenuItem.getElement().setId("closeOtherTabs"); //$NON-NLS-1$
        closeAllTabsMenuItem.getElement().setId("closeAllTabs"); //$NON-NLS-1$
    }
    popupMenu.setWidget(menuBar);

    if (isIEBrowser()) {
        Frame iFrame = new Frame("about:blank");
        Style iFrameStyle = iFrame.getElement().getStyle();
        iFrameStyle.setWidth(100, Style.Unit.PCT);
        iFrameStyle.setHeight(100, Style.Unit.PCT);
        iFrameStyle.setBorderStyle(Style.BorderStyle.NONE);
        iFrameStyle.setTop(0, Unit.PX);
        iFrameStyle.setPosition(Style.Position.ABSOLUTE);
        iFrameStyle.setZIndex(-1);
        Element element = popupMenu.getElement();
        Node firstChild = element.getFirstChild();
        if (firstChild != null) {
            firstChild.appendChild(iFrame.getElement());
        }
    }

    popupMenu.hide();
    popupMenu.show();
}

From source file:org.psystems.dicom.browser.client.Browser.java

License:Open Source License

/**
 *  ??/*  www  .  ja v a2s .c o  m*/
 */
private void workStatusPopuppopupCentering() {
    workStatusPopup.setPopupPositionAndShow(new PositionCallback() {

        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {

            workStatusPopup.setPopupPosition(offsetWidth, offsetHeight);
            int left = (Window.getClientWidth() - offsetWidth) >> 1;
            int top = 0;

            workStatusPopup.setPopupPosition(Window.getScrollLeft() + left, Window.getScrollTop() + top);
        }

    });

}

From source file:org.roda.wui.common.client.widgets.Toast.java

/**
 * Start showing popup//from  w  w  w .ja v a  2s .  co  m
 */
public void start() {
    setPopupPositionAndShow(new PositionCallback() {

        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            int slotOffset = 0;
            for (int i = 0; i < slotNumber; i++) {
                if (slots[i] != null) {
                    slotOffset += slots[i].getOffsetHeight() + PADDING;
                }
            }

            // scrollTo - go to the top of the page when showing toast
            Window.scrollTo(Window.getScrollLeft(), 0);
            Toast.this.setPopupPosition(Window.getClientWidth() - offsetWidth - PADDING,
                    Window.getScrollTop() + PADDING + slotOffset);
        }

    });

    hideTimer.schedule(HIDE_DELAY_MS);

}