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() . These examples are extracted from open source projects. 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
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 Project: unitime   File: RoomEdit.java    License: 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 3
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 4
Source Project: unitime   File: InstructorAttributeEdit.java    License: 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 5
Source Project: unitime   File: RoomGroupEdit.java    License: 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 6
Source Project: unitime   File: RoomDetail.java    License: 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 7
Source Project: unitime   File: RoomFeatureEdit.java    License: 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 8
@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 Project: unitime   File: EventAdd.java    License: 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 10
Source Project: unitime   File: EventDetail.java    License: 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 11
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 12
@Override
public void onNavigation(NavigationEvent navigationEvent) {
    Window.scrollTo(0, 0);
}
 
Example 13
Source Project: unitime   File: InstructorAttributeEdit.java    License: 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);
}
 
Example 14
Source Project: unitime   File: RoomGroupEdit.java    License: 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 15
Source Project: unitime   File: RoomDetail.java    License: Apache License 2.0 4 votes vote down vote up
public void hide() {
	setVisible(false);
	onHide();
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 16
Source Project: unitime   File: RoomFeatureEdit.java    License: 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 17
Source Project: unitime   File: RoomDepartmentsEdit.java    License: Apache License 2.0 4 votes vote down vote up
private void hide(boolean refresh) {
	setVisible(false);
	onHide(refresh);
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 18
Source Project: unitime   File: RoomEdit.java    License: 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 19
Source Project: unitime   File: EventAdd.java    License: Apache License 2.0 4 votes vote down vote up
public void hide() {
	setVisible(false);
	onHide();
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}
 
Example 20
Source Project: unitime   File: EventDetail.java    License: Apache License 2.0 4 votes vote down vote up
public void hide() {
	setVisible(false);
	onHide();
	Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}