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.rstudio.studio.client.pdfviewer.ui.PDFViewerPanel.java

License:Open Source License

@Override
public void navigateTo(final PdfLocation pdfLocation) {
    double factor = PDFView.currentScale() * 96 / 72;

    final double x = pdfLocation.getX() * factor;
    final double y = pdfLocation.getY() * factor;
    final double w = pdfLocation.getWidth() * factor;
    final double h = pdfLocation.getHeight() * factor;

    final Value<Integer> retries = new Value<Integer>(0);

    // Sometimes pageContainer is null during load, so retry every 100ms
    // until it's not, or we've tried 40 times.
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override/*from w w  w .j a  v a  2s  .c o m*/
        public boolean execute() {
            Element pageContainer = Document.get().getElementById("pageContainer" + pdfLocation.getPage());

            if (pageContainer == null) {
                retries.setValue(retries.getValue() + 1);
                return retries.getValue() < 40;
            }

            if (pdfLocation.isFromClick()) {
                final DivElement div = Document.get().createDivElement();
                div.getStyle().setPosition(Style.Position.ABSOLUTE);
                div.getStyle().setTop(y, Unit.PX);
                div.getStyle().setLeft(x, Unit.PX);
                div.getStyle().setWidth(w, Unit.PX);
                div.getStyle().setHeight(h, Unit.PX);
                div.getStyle().setBackgroundColor("rgba(0, 126, 246, 0.1)");
                div.getStyle().setProperty("transition", "opacity 4s");
                // use DomUtils to set transition styles so gwt doesn't assert
                // an invalid style name (no camelCase) in debug mode
                DomUtils.setStyle(div, "-moz-transition", "opacity 4s");
                DomUtils.setStyle(div, "-webkit-transition", "opacity 4s");

                pageContainer.appendChild(div);

                Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
                    @Override
                    public boolean execute() {
                        div.getStyle().setOpacity(0.0);
                        return false;
                    }
                }, 2000);
            }

            // scroll to the page
            PDFView.goToPage(pdfLocation.getPage());

            // if the target isn't on-screen then scroll to it
            if (pdfLocation.getY() > getBottomCoordinates().getY()) {
                Window.scrollTo(Window.getScrollLeft(),
                        Math.max(0, pageContainer.getAbsoluteTop() + (int) y - 180));
            }

            return false;
        }
    }, 100);
}

From source file:org.seamless.gwt.notify.client.PopupNotificationDisplay.java

License:Open Source License

@Override
public void showMessage(final Message message) {

    final PopupMessagePanel messagePanel = new PopupMessagePanel(message);

    messagePanel.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
        public void setPosition(int offsetWidth, int offsetHeight) {
            int originLeft = Window.getScrollLeft() + Window.getClientWidth() - offsetWidth
                    - MARGIN_RIGHT_PIXEL;
            int originTop = Window.getScrollTop() + Window.getClientHeight() - offsetHeight
                    - MARGIN_BOTTOM_PIXEL;
            setRelativePosition(messagePanels.values(), messagePanel, originLeft, originTop, originTop,
                    offsetHeight, offsetWidth);
        }/*from  w  w  w.  ja  va 2  s  . c om*/
    });

    messagePanels.put(message, messagePanel);
}

From source file:org.squale.gwt.distributionmap.widget.DistributionMap.java

License:Open Source License

/**
 * Moves the current detail popup to the specified position.
 * //w  w w . j a v  a  2  s.c  o  m
 * @param xPosition X position
 * @param yPosition Y position
 */
void updateDetailPopup(int xPosition, int yPosition) {
    detailPopup.setPopupPosition(xPosition + 1 + Window.getScrollLeft(), yPosition + 1 + Window.getScrollTop());
}

From source file:org.unitime.timetable.gwt.client.events.AddMeetingsDialog.java

License:Apache License

public void recenter() {
    GwtHint.getInstance().hide();//from   w  w  w .  j av a2 s.co  m

    iScrollRooms.getElement().getStyle().clearHeight();
    if (getElement().getClientHeight() > Window.getClientHeight() - 100)
        iScrollRooms.getElement().getStyle().setHeight(Window.getClientHeight() - 200, Unit.PX);

    iScrollDates.getElement().getStyle().clearHeight();
    if (getElement().getClientHeight() > Window.getClientHeight() - 100) {
        iScrollDates.getElement().getStyle().setHeight(Window.getClientHeight() - 200, Unit.PX);
    }

    int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
    int top = (Window.getClientHeight() - getOffsetHeight()) >> 1;
    setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max(Window.getScrollTop() + top, 0));
}

From source file:org.unitime.timetable.gwt.client.events.EventAdd.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance()/*from  w w w .j av a 2  s .com*/
            .setPageName(iEvent.getId() == null ? MESSAGES.pageAddEvent() : MESSAGES.pageEditEvent());
    setVisible(true);
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
    if (iForm.getRowFormatter().isVisible(iSessionRow)) {
        iSession.setFilter(this);
        iForm.setWidget(iSessionRow, 1, iSession);
    }
    iFileUpload.check();
}

From source file:org.unitime.timetable.gwt.client.events.EventDetail.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance().setPageName(MESSAGES.pageEventDetail());
    setVisible(true);/*from w w  w.  j av a  2 s.  com*/
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
}

From source file:org.unitime.timetable.gwt.client.GwtHint.java

License:Apache License

public static void showHint(final Element relativeObject, Widget content,
        final boolean showRelativeToTheObject) {
    getInstance().setWidget(content);// w w w.  j  av  a 2  s  .c  o m
    getInstance().setPopupPositionAndShow(new PositionCallback() {
        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            if (relativeObject != null && showRelativeToTheObject) {
                int textBoxOffsetWidth = relativeObject.getOffsetWidth();
                int offsetWidthDiff = offsetWidth - textBoxOffsetWidth;
                int left;
                if (LocaleInfo.getCurrentLocale().isRTL()) {
                    int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft();
                    left = textBoxAbsoluteLeft - offsetWidthDiff;
                    if (offsetWidthDiff > 0) {
                        int windowRight = Window.getClientWidth() + Window.getScrollLeft();
                        int windowLeft = Window.getScrollLeft();
                        int textBoxLeftValForRightEdge = textBoxAbsoluteLeft + textBoxOffsetWidth;
                        int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge;
                        int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft;
                        if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) {
                            left = textBoxAbsoluteLeft;
                        }
                    }
                } else {
                    left = relativeObject.getAbsoluteLeft();
                    if (offsetWidthDiff > 0) {
                        int windowRight = Window.getClientWidth() + Window.getScrollLeft();
                        int windowLeft = Window.getScrollLeft();
                        int distanceToWindowRight = windowRight - left;
                        int distanceFromWindowLeft = left - windowLeft;
                        if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) {
                            left -= offsetWidthDiff;
                        }
                    }
                }
                int top = relativeObject.getAbsoluteTop();
                int windowTop = Window.getScrollTop();
                int windowBottom = Window.getScrollTop() + Window.getClientHeight();
                int distanceFromWindowTop = top - windowTop;
                int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight());
                if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) {
                    top -= offsetHeight;
                } else {
                    top += relativeObject.getOffsetHeight();
                }
                getInstance().setPopupPosition(left, top);
            } else {
                int left = Window.getScrollLeft() + 10;
                int top = Window.getScrollTop() + Window.getClientHeight() - offsetHeight - 10;
                if (relativeObject != null && left + offsetWidth >= relativeObject.getAbsoluteLeft()
                        && top <= relativeObject.getAbsoluteBottom())
                    left = Window.getScrollLeft() + Window.getClientWidth() - offsetWidth - 10;
                getInstance().setPopupPosition(left, top);
            }

        }
    });
}

From source file:org.unitime.timetable.gwt.client.instructor.InstructorAttributeEdit.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance()//  w  w w.  j  a v  a 2  s.c om
            .setPageName(iAttribute.getId() == null ? MESSAGES.pageAddInstructorAttribute()
                    : MESSAGES.pageEditInstructorAttribute());
    setVisible(true);
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
}

From source file:org.unitime.timetable.gwt.client.page.InfoPanelImpl.java

License:Apache License

public InfoPanelImpl() {
    super("cell");
    iText = new P("text");
    add(iText);// ww  w . ja  v  a 2 s .  c om

    iHint = new ClickableHint("");
    iHint.setStyleName("hint");
    add(iHint);

    iUpdateInfo = new Callback() {
        @Override
        public void execute(Callback callback) {
            if (callback != null)
                callback.execute(null);
        }
    };

    iInfo = new FlexTable();
    iInfo.setStyleName("unitime-InfoTable");
    // iUpdateInfo = updateInfo;
    iInfoPanel = new PopupPanel();
    iInfoPanel.setWidget(iInfo);
    iInfoPanel.setStyleName("unitime-PopupHint");
    sinkEvents(Event.ONMOUSEOVER);
    sinkEvents(Event.ONMOUSEOUT);
    sinkEvents(Event.ONMOUSEMOVE);
    iShowInfo = new Timer() {
        @Override
        public void run() {
            if (iInfo.getRowCount() == 0)
                return;
            iUpdateInfo.execute(new Callback() {
                public void execute(Callback callback) {
                    iInfoPanel.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                        @Override
                        public void setPosition(int offsetWidth, int offsetHeight) {
                            int maxX = Window.getScrollLeft() + Window.getClientWidth() - offsetWidth - 10;
                            iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY);
                        }
                    });
                    if (callback != null)
                        callback.execute(null);
                }
            });
        }
    };
    iHideInfo = new Timer() {
        @Override
        public void run() {
            iInfoPanel.hide();
        }
    };

    iDefaultClickHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (iUrl != null && !iUrl.isEmpty())
                ToolBox.open(GWT.getHostPageBaseURL() + iUrl);
        }
    };
    iTextClick = iHint.addClickHandler(iDefaultClickHandler);
    iHintClick = iText.addClickHandler(iDefaultClickHandler);
    iHint.setTabIndex(-1);
}

From source file:org.unitime.timetable.gwt.client.page.InfoPanelImpl.java

License:Apache License

public void onBrowserEvent(Event event) {
    if (iHint.getText().isEmpty())
        return;//w  w w  .  jav  a2 s . com
    iX = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft();
    iY = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop();

    switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEMOVE:
        if (iInfoPanel.isShowing()) {
            int maxX = Window.getScrollLeft() + Window.getClientWidth() - iInfoPanel.getOffsetWidth() - 10;
            iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY);
        } else if (iInfo.getRowCount() > 0) {
            iShowInfo.cancel();
            iShowInfo.schedule(1000);
        }
        break;
    case Event.ONMOUSEOUT:
        iShowInfo.cancel();
        if (iInfoPanel.isShowing())
            iHideInfo.schedule(1000);
        break;
    }
}