Java Code Examples for com.google.gwt.user.client.Window#scrollTo()

The following examples show how to use com.google.gwt.user.client.Window#scrollTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Scrolling.java    From jetpad-projectional-open-source with Apache License 2.0 6 votes vote down vote up
public static void scrollTo(Rectangle rect, Element element) {
  rect = rect.intersect(new Rectangle(0, 0, element.getScrollWidth(), element.getScrollHeight()));

  adjustScrollers(rect, element);
  Rectangle visibleArea = new Rectangle(getScrollX(), getScrollY(), getScrollWidth(), getScrollHeight());
  Rectangle elementBounds = getBounds(element);
  Rectangle bounds = new Rectangle(elementBounds.origin.add(rect.origin), rect.dimension);
  if (!visibleArea.contains(bounds)) {    // are we sure about this?
    int top = element.getAbsoluteTop() + rect.origin.y;
    int left = element.getAbsoluteLeft() + rect.origin.x;
    int width = rect.dimension.x;
    int height = rect.dimension.y;

    int winTop = getScrollY();
    int winLeft = getScrollX();
    int winWidth = getScrollWidth();
    int winHeigh = getScrollHeight();

    int deltaX = getScrollAdjustment(new Interval(winLeft, winLeft + winWidth), new Interval(left, left + width), winLeft);
    int deltaY = getScrollAdjustment(new Interval(winTop, winTop + winHeigh), new Interval(top, top + height), winTop);

    if (deltaX != 0 || deltaY != 0) {
      Window.scrollTo(winLeft + deltaX, winTop + deltaY);
    }
  }
}
 
Example 2
Source File: NavSpy.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
NavWidget(NavWidget parentNav, final Element heading) {
	super(heading.getInnerHTML(), new ScheduledCommand() {
		@Override
		public void execute() {
			int top = NavSpy.this.getElementTop(heading) - NavSpy.this.spyOffset;
			if (NavSpy.this.isBodyScrollWidget()) {
				Window.scrollTo(Document.get().getScrollLeft(), top);
			} else {
				NavSpy.this.scrollWidget.getElement().setScrollTop(top);
			}
		}
	});

	this.parentNav = parentNav;
	this.level = NavSpy.this.getLevel(heading);
}
 
Example 3
Source File: RoomEdit.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(iRoom.getUniqueId() == null ? MESSAGES.pageAddRoom() : MESSAGES.pageEditRoom());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
	
	if (iMap != null) {
		if (iMap.isEnabled() || iRoom.hasCoordinates()) {
			iMap.setVisible(true);
			iMap.onShow();
		} else {
			iMap.setVisible(false);
		}
	}
}
 
Example 4
Source File: RoomGroupEdit.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(iGroup.getId() == null ? MESSAGES.pageAddRoomGroup() : MESSAGES.pageEditRoomGroup());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example 5
Source File: DocumentationDisplay.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void redraw(boolean autoScroll) {
	if (autoScroll) {
		String historyToken = History.getToken();
		if (!Strings.isNullOrEmpty(historyToken)) {
			int top = this.affixMenu.getPinnedOffset();
			Window.scrollTo(Window.getScrollLeft(), top);
		} else {
			Window.scrollTo(Window.getScrollLeft(), 0);
		}
	}
}
 
Example 6
Source File: EventDetail.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(MESSAGES.pageEventDetail());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example 7
Source File: EventAdd.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().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();
}
 
Example 8
Source File: MobileUniTimeFrameDialogImpl.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void openDialog(String title, String source, String width, String height, boolean noCacheTS) {
	if (isShowing()) hideDialog();
	GwtHint.hideHint();
	
	iScrollLeft = Window.getScrollLeft(); iScrollTop = Window.getScrollTop();
	Window.scrollTo(0, 0);

	LoadingWidget.getInstance().show("Loading " + title + " ...");
	setText(title);
	if (noCacheTS) {
		String hash = null;
		int hashIdx = source.lastIndexOf('#');
		if (hashIdx >= 0) {
			hash = source.substring(hashIdx);
			source = source.substring(0, hashIdx);
		}
		iFrame.setUrl(source + (source.indexOf('?') >= 0 ? "&" : "?") + "noCacheTS=" + new Date().getTime() + (hash == null ? "" : hash));
	} else {
		iFrame.setUrl(source);
	}
	iCheckLoadingWidgetIsShowing.schedule(30000);
	
	History.newItem(title, false);
	iPopup.setPopupPosition(0, 0);
	iPopup.show();
	RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
}
 
Example 9
Source File: InstructorAttributeEdit.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(iAttribute.getId() == null ? MESSAGES.pageAddInstructorAttribute() : MESSAGES.pageEditInstructorAttribute());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example 10
Source File: RoomFeatureEdit.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(iFeature.getId() == null ? MESSAGES.pageAddRoomFeature() : MESSAGES.pageEditRoomFeature());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example 11
Source File: RoomDetail.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(MESSAGES.pageRoomDetail());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example 12
Source File: RoomDepartmentsEdit.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void hide(boolean refresh) {
	setVisible(false);
	onHide(refresh);
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 13
Source File: ApplicationPresenter.java    From gwt-material-demo with Apache License 2.0 4 votes vote down vote up
@Override
public void onNavigation(NavigationEvent navigationEvent) {
    Window.scrollTo(0, 0);
}
 
Example 14
Source File: RoomEdit.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void hide(RoomDetailInterface room, boolean canShowDetail, String message) {
	setVisible(false);
	onHide(room, canShowDetail, message);
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 15
Source File: RoomFeatureEdit.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void hide(boolean refresh, FeatureInterface feature) {
	setVisible(false);
	onHide(refresh, feature);
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 16
Source File: RoomDetail.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void hide() {
	setVisible(false);
	onHide();
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 17
Source File: EventAdd.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void hide() {
	setVisible(false);
	onHide();
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 18
Source File: EventDetail.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void hide() {
	setVisible(false);
	onHide();
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 19
Source File: RoomGroupEdit.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void hide(boolean refresh, GroupInterface group) {
	setVisible(false);
	onHide(refresh, group);
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 20
Source File: InstructorAttributeEdit.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void hide(boolean refresh, AttributeInterface attribute) {
	setVisible(false);
	onHide(refresh, attribute);
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}