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

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

Introduction

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

Prototype

public static void scrollTo(int left, int top) 

Source Link

Usage

From source file:com.sun.labs.aura.music.wsitm.client.Main.java

License:Open Source License

private void setResults(String historyName, Swidget newSwidget) {

    // We're changin page; scroll the window to the top of the page
    Window.scrollTo(0, 0);

    // If we are loading the same swidget, just notify it that a new history
    // event occurent in case it needs to change its internal state
    if (curSwidget == newSwidget) {
        curSwidget.update(historyName);/* w  ww  . j a  va  2s .co  m*/
        curToken = historyName;
        return;
    }

    if (!History.getToken().equals(historyName)) {
        History.newItem(historyName, false);
        curToken = historyName;
    } else if (newSwidget.getTokenHeaders().contains(getResultNameHeader(historyName))) {
        curToken = historyName;
    }

    // Unload current swidget
    if (curSwidget != null) {
        contentPanel.remove(curSwidget);
        cdm.unregisterSwidget(curSwidget);
        curSwidget = null;
    }

    // Load new swidget
    if (newSwidget != null) {
        newSwidget.update(historyName);
        contentPanel.add(newSwidget);
        cdm.registerSwidget(newSwidget);
        curSwidget = newSwidget;
    }

    cdm.setCurrSwidget(curSwidget);
}

From source file:com.tasktop.c2c.server.common.web.client.navigation.Navigation.java

License:Open Source License

/**
 * show the element with the given id/*from   w w  w . j  av  a  2  s .c o  m*/
 * 
 * @return true if the element was found
 */
public static boolean showIdElement(Element element, String elementId) {
    Element idElement = findElementById(element, elementId);
    if (idElement != null) {
        Window.scrollTo(idElement.getAbsoluteLeft(), idElement.getAbsoluteTop());
        return true;
    }
    return false;
}

From source file:com.tasktop.c2c.server.profile.web.ui.client.view.components.ProjectView.java

License:Open Source License

private ProjectView() {
    initWidget(uiBinder.createAndBindUi(this));
    setupSelectOnClick(mavenUrlTextBox);
    setupSelectOnClick(mavenDavUrlTextBox);
    readMoreAnchor.addClickHandler(new ClickHandler() {

        @Override/*w ww .j  a va  2  s  . co m*/
        public void onClick(ClickEvent event) {
            if (wikiContentPanel.getWidget() != null) {
                Element element = wikiContentPanel.getWidget().getElement();
                Window.scrollTo(element.getAbsoluteLeft(), element.getAbsoluteTop());
            }
        }
    });
    wikiHomePageLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            Window.scrollTo(0, 0);
        }
    });
}

From source file:com.tasktop.c2c.server.scm.web.ui.client.view.ScmCommitView.java

License:Open Source License

/**
 * @param commit//from w  ww  . j a  va 2  s .  co m
 */
public void setCommit(Commit commit) {

    driver.edit(commit);

    repository.setText(commonProfileMessages.parentheses(commit.getRepository()));
    repository.setHref(ScmRepoPlace.createPlace(projectId, commit.getRepository()).getHref());

    parentsPanel.clear();
    if (commit.getParents().isEmpty()) {
        parentsPanel.add(new Label("None"));
    } else {
        boolean needSep = false;
        for (String parentId : commit.getParents()) {
            if (needSep) {
                parentsPanel.add(new Label(commonProfileMessages.comma()));
            } else {
                needSep = true;
            }
            parentsPanel.add(new Anchor(Commit.minimizeCommitId(parentId),
                    ScmCommitPlace.createPlace(projectId, commit.getRepository(), parentId).getHref()));
        }
    }

    filesPanel.clear();

    if (commit.getChanges() != null) {
        int i = 0;
        for (DiffEntry diffEntry : commit.getChanges()) {
            DiffEntryView overviewFileDiff = new DiffEntryView(diffEntry);
            filesPanel.add(overviewFileDiff);

            final int index = i++;
            overviewFileDiff.getFileNameAnchor().addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {

                    if (!patchPanel.isOpen()) {
                        patchPanel.setOpen(true);
                    }
                    Element toScrollTo = Navigation.findElementById(diffHtml.getElement(),
                            computeElementId(index));
                    if (toScrollTo != null) {
                        Window.scrollTo(0, toScrollTo.getAbsoluteTop());
                    }

                }
            });
        }
        patchPanel.setVisible(true);
        changesPanel.setVisible(true);
        diffHtml.setHTML(buildHtml(commit.getChanges()));
    } else {
        patchPanel.setVisible(false);
        changesPanel.setVisible(false);
        diffHtml.setHTML("");
    }

    authorImage.setUrl(Avatar.computeAvatarUrl(commit.getAuthor().getGravatarHash(), Avatar.Size.MEDIUM));

    UIObject.setVisible(committerInfoDiv, commit.getCommitter() != null);
    if (commit.getCommitter() != null) {
        committedByLabel.setText(scmMessages.committedByOn(commit.getCommitter().getEmail(),
                Format.getDateTimeFormat().format(commit.getCommitDate())));
    }
    if (totalDiffLines < maxPrettifiableLines) {
        GoogleCodePrettifyUtil.run();
    }
}

From source file:com.threerings.gwt.util.WindowUtil.java

License:Open Source License

/**
 * Scrolls the window to place the specified target widget at the top (or as close as possible
 * given the height of the browser)./*from   w w  w  .j a  v a  2 s .c om*/
 */
public static void scrollTo(Widget target) {
    Window.scrollTo(Window.getScrollLeft(), target.getAbsoluteTop());
}

From source file:com.threerings.gwt.util.WindowUtil.java

License:Open Source License

/**
 * Scrolls the window to place the specified target widget in view, while trying to minimize
 * scrolling./*from w  w  w  .j  av a 2 s . c  om*/
 */
public static void scrollIntoView(Widget target) {
    Window.scrollTo(Window.getScrollLeft(), getScrollIntoView(target));
}

From source file:com.threerings.gwt.util.WindowUtil.java

License:Open Source License

/**
 * Centers the target widget vertically in the browser viewport. If the widget is taller than
 * the viewport, its top is aligned with the top of the viewport.
 *//*from   w  w  w .  ja v a 2s  . c  o  m*/
public static void scrollToMiddle(Widget target) {
    Window.scrollTo(Window.getScrollLeft(), getScrollToMiddle(target));
}

From source file:com.threerings.perf.html.PerfTestHtml.java

public void onModuleLoad() {
    HtmlPlatform.Config config = new HtmlPlatform.Config();
    config.antiAliasing = false;// w  w w. j a v a  2  s. co m
    config.backgroundFrameMillis = 100; // 10 fps background rendering
    final HtmlPlatform plat = new HtmlPlatform(config);
    //plat.assets().setPathPrefix("playn-perf/");

    plat.graphics().setSize(Window.getClientWidth(), Window.getClientHeight());
    Window.scrollTo(0, 0);

    plat.log().setCollector(new Collector() {
        public void logged(Level level, String msg, Throwable e) {
            log(level.toString() + ": " + msg);
            if (e != null) {
                log(e.getMessage());
            }
        }

        native void log(String msg) /*-{ console.log(msg); }-*/;
    });

    new PerfTest(plat);
    plat.start();
}

From source file:com.ui.gwt.mobile.client.MobileEntryPoint.java

License:Apache License

@Override
public void onModuleLoad() {
    //Remove the address bar (IOS & homescreen bookmark only)
    Window.scrollTo(0, 1);
    //Inject the stylesheet into the head tag
    AppResources.INSTANCE.css().ensureInjected();

    //Enable performance logging for the app
    PerfConfig.setEnableAllClasses(true);
    PerfConfig.setPerfEnabled(true);//  w  w  w.j a v a  2  s. c  o  m
    PerfConfig.setLogImmediately(true);

    PerfTimer timer = PerfTimer.get(this, "init");

    //create a 2 column layout
    DockLayoutPanel dockPanel = new DockLayoutPanel(Style.Unit.PCT);
    dockPanel.setStyleName(AppResources.INSTANCE.css().container());

    MobileScrollPanel scrollPanel = new MobileScrollPanel(true);
    final ContactListPanel listPanel = new ContactListPanel();
    scrollPanel.add(listPanel);
    FlowPanel west = new FlowPanel();
    west.add(new Heading("Contacts"));
    west.add(scrollPanel);
    dockPanel.addWest(west, 30); //30%

    final DetailPanel detail = new DetailPanel();
    FlowPanel east = new FlowPanel();
    east.add(new Heading("Contact Details"));
    east.add(detail);
    dockPanel.addEast(east, 70); //70%

    listPanel.addSelectionHandler(new SelectionHandler<Contact>() {
        @Override
        public void onSelection(SelectionEvent<Contact> contactSelectionEvent) {
            detail.setData(contactSelectionEvent.getSelectedItem());
        }
    });

    MobileRPCService.App.getInstance().getContacts(new AsyncCallback<ArrayList<Contact>>() {
        @Override
        public void onFailure(Throwable caught) {
            Window.alert("Having trouble communicating with the server.");
        }

        @Override
        public void onSuccess(ArrayList<Contact> result) {
            listPanel.setData(result);
        }
    });

    //remove loading indicator
    RootPanel.get("loading").getElement().setInnerHTML("");

    RootLayoutPanel.get().add(dockPanel);
    timer.end();
}

From source file:com.zipsoft.widgets.client.lazylayout.VLazyLayout.java

License:Apache License

private void setScrollTop(final int topPx) {
    com.google.gwt.dom.client.Element parent = getElement();
    while (parent != null && parent.getScrollTop() <= 0) {
        parent = parent.getOffsetParent();
    }/*from   w  ww  .  j  a va2  s . c om*/
    if (parent != null) {
        parent.setScrollTop(topPx);
        debug("setting scrolltop to " + topPx);
    } else {
        final int currentScrollLeft = Window.getScrollLeft();
        Window.scrollTo(currentScrollLeft, topPx);
        debug("setting scrolltop for window to " + topPx);
    }
    scrollingWasProgrammaticallyAdjusted = true;
}