List of usage examples for com.google.gwt.user.client Window scrollTo
public static void scrollTo(int left, int top)
From source file:org.openremote.web.console.util.BrowserUtils.java
License:Open Source License
private static void initMobile() { // Prevent window scrolling RootPanel.get().addDomHandler(new TouchMoveHandler() { public void onTouchMove(TouchMoveEvent e) { e.preventDefault();/*ww w.j a va2s.c om*/ } }, TouchMoveEvent.getType()); Window.scrollTo(0, 1); new Timer() { public void run() { Window.scrollTo(0, 1); } }.schedule(1000); // Determine current window orientation if (getWindowHeight() < getWindowWidth()) { windowOrientation = "landscape"; } // Create a native orientation change handler as resize handler isn't reliable on iOS 3.x addNativeOrientationHandler(); // If Apple device then check if loaded from bookmark if (!isBookmarked()) { Window.alert("Please add this page to your Home Screen to view in fullscreen!"); } }
From source file:org.overlord.dtgov.ui.client.local.pages.TargetPage.java
License:Apache License
/** * On submit click.//www . j a v a 2 s .c o m * * @param event * the event */ @EventHandler("btn-save") public void onSubmitClick(ClickEvent event) { final NotificationBean notification = _notificationService.startProgressNotification( _i18n.format("target-submit.save"), //$NON-NLS-1$ _i18n.format("target-submit.save-msg")); //$NON-NLS-1$ final TargetBean target = this.createTargetBean(); _validation_errors.clear(); _targetService.save(target, new IRpcServiceInvocationHandler<String>() { @Override public void onError(Throwable error) { if (error instanceof DtgovFormValidationException) { List<ValidationError> errors = ((DtgovFormValidationException) error).getErrors(); for (ValidationError err : errors) { _validation_errors.add(new InlineLabel(_i18n.format(err.getErrorLabel()))); } _formValidationErrorDiv.getElement().removeClassName("hide"); //$NON-NLS-1$ _notificationService.removeNotification(notification.getUuid()); Window.scrollTo(0, 0); } else { _notificationService.completeProgressNotification(notification.getUuid(), _i18n.format("target-submit.error-saving"), //$NON-NLS-1$ error); } } @Override public void onReturn(String data) { _uuid = data; _formValidationErrorDiv.getElement().addClassName("hide"); //$NON-NLS-1$ _notificationService.completeProgressNotification(notification.getUuid(), _i18n.format("target-submit.successfully-saved"), //$NON-NLS-1$ _i18n.format("target-submit.successfully-saved-message", target.getName())); //$NON-NLS-1$ } }); }
From source file:org.overlord.dtgov.ui.client.local.pages.WorkflowQueryPage.java
License:Apache License
/** * On submit click./*from w w w . j a v a 2 s.co m*/ * * @param event * the event */ @EventHandler("btn-save") public void onSubmitClick(ClickEvent event) { final NotificationBean notification = _notificationService.startProgressNotification( _i18n.format("workflowQuery-submit.save"), //$NON-NLS-1$ _i18n.format("workflowQuery-submit.save-msg")); //$NON-NLS-1$ final WorkflowQueryBean query = this.createWorkflowQueryBean(); _validation_errors.clear(); _workflowQueryService.save(query, new IRpcServiceInvocationHandler<String>() { @Override public void onError(Throwable error) { if (error instanceof DtgovFormValidationException) { List<ValidationError> errors = ((DtgovFormValidationException) error).getErrors(); for (ValidationError err : errors) { _validation_errors.add(new InlineLabel(_i18n.format(err.getErrorLabel()))); } _formValidationErrorDiv.getElement().removeClassName("hide"); //$NON-NLS-1$ _notificationService.removeNotification(notification.getUuid()); Window.scrollTo(0, 0); } else { _notificationService.completeProgressNotification(notification.getUuid(), _i18n.format("workflowQuery-submit.error-saving"), //$NON-NLS-1$ error); } } @Override public void onReturn(String data) { _notificationService.completeProgressNotification(notification.getUuid(), _i18n.format("workflowQuery-submit.successfully-saved"), //$NON-NLS-1$ _i18n.format("workflowQuery-submit.successfully-saved-message", query.getName())); //$NON-NLS-1$ } }); }
From source file:org.roda.wui.client.browse.EditDescriptiveMetadata.java
@UiHandler("buttonApply") void buttonApplyHandler(ClickEvent e) { Window.scrollTo(0, 0); String xmlText = metadataXML.getText(); if (inXML) {/*from w w w. ja v a 2 s.c o m*/ updateMetadataOnServer(xmlText); } else { // Get the resulting XML using the data from the form BrowserService.Util.getInstance().retrieveDescriptiveMetadataPreview(supportedBundle, new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { AsyncCallbackUtils.defaultFailureTreatment(caught); } @Override public void onSuccess(String preview) { updateMetadataOnServer(preview); } }); } }
From source file:org.roda.wui.client.management.UserDataPanel.java
/** * Is user data panel valid//from www . j a va2 s . c o m * * @return true if valid */ public boolean isValid() { List<String> errorList = new ArrayList<>(); if (username.getText().length() == 0) { username.addStyleName("isWrong"); usernameError.setText(messages.mandatoryField()); usernameError.setVisible(true); Window.scrollTo(username.getAbsoluteLeft(), username.getAbsoluteTop()); errorList.add(messages.isAMandatoryField(messages.username())); } else { username.removeStyleName("isWrong"); usernameError.setVisible(false); } if (!password.matchConfirmation()) { if (errorList.isEmpty()) { Window.scrollTo(password.getAbsoluteLeft(), password.getAbsoluteTop()); } errorList.add(messages.passwordDoesNotMatchConfirmation()); } else if (password.isSmall()) { if (errorList.isEmpty()) { Window.scrollTo(password.getAbsoluteLeft(), password.getAbsoluteTop()); } errorList.add(messages.passwordIsTooSmall()); } if (fullname.getText().length() == 0) { fullname.addStyleName("isWrong"); fullnameError.setText(messages.mandatoryField()); fullnameError.setVisible(true); if (errorList.isEmpty()) { Window.scrollTo(fullname.getAbsoluteLeft(), fullname.getAbsoluteTop()); } errorList.add(messages.isAMandatoryField(messages.fullname())); } else { fullname.removeStyleName("isWrong"); fullnameError.setVisible(false); } if (email.getText() == null || "".equals(email.getText().trim())) { email.addStyleName("isWrong"); emailError.setText(messages.mandatoryField()); emailError.setVisible(true); if (errorList.isEmpty()) { Window.scrollTo(email.getAbsoluteLeft(), email.getAbsoluteTop()); } errorList.add(messages.isAMandatoryField(messages.email())); } else if (!email.getText().matches( "^[_A-Za-z0-9-%+]+(\\.[_A-Za-z0-9-%+]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[_A-Za-z0-9-]+)")) { email.addStyleName("isWrong"); emailError.setText(messages.wrongMailFormat()); emailError.setVisible(true); if (errorList.isEmpty()) { Window.scrollTo(email.getAbsoluteLeft(), email.getAbsoluteTop()); } errorList.add(messages.emailNotValid()); } else { email.removeStyleName("isWrong"); emailError.setVisible(false); } List<String> extraErrors = FormUtilities.validate(userExtraBundle.getValues(), extra); errorList.addAll(extraErrors); checked = true; if (!errorList.isEmpty()) { errors.setVisible(true); StringBuilder errorString = new StringBuilder(); for (String error : errorList) { errorString.append("<span class='error'>").append(error).append("</span>"); errorString.append("<br/>"); } errors.setHTML(errorString.toString()); } else { errors.setVisible(false); } return errorList.isEmpty() ? true : false; }
From source file:org.roda.wui.common.client.widgets.Toast.java
/** * Start showing popup//from w ww .jav a 2 s .c o 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); }
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// ww w.j av a 2 s . co 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.silverpeas.mobile.client.apps.contacts.pages.ContactsPage.java
License:Open Source License
@Override public void onScrollEndPage(final EndPageEvent event) { if (callingNexData == false && noMoreData == false) { callingNexData = true;/*from w w w .j a v a 2s.c o m*/ list.add(getWaitingItem()); Window.scrollTo(0, Document.get().getScrollHeight()); startIndexAll += computePageSize(); EventBus.getInstance().fireEvent( new ContactsLoadEvent(currentType, filter.getText(), computePageSize(), startIndexAll)); } }
From source file:org.spiffyui.spsample.client.CSSPanel.java
License:Apache License
private void doSausage() { if (m_sausageNav.getText().equals(Index.getStrings().sausageMenuOn())) { DOM.getElementById("mainWrap").addClassName("sausagenav"); JSUtil.show("#mainContent > div"); Window.scrollTo(0, sausageJS()); m_sausageNav.setText(Index.getStrings().sausageMenuOff()); Index.setSausageMode(true);/*from w w w . j a va 2s . co m*/ JSUtil.hide("backToTop"); JSUtil.horizontalToggleSlide("#fixedScrollingTab"); } else { DOM.getElementById("mainWrap").removeClassName("sausagenav"); m_sausageNav.setText(Index.getStrings().sausageMenuOn()); Index.setSausageMode(false); destroySausageJS(); Index.selectItem(Index.CSS_NAV_ITEM_ID); Window.scrollTo(0, 0); JSUtil.horizontalToggleSlide("#fixedScrollingTab"); } }
From source file:org.spiffyui.spsample.client.Index.java
License:Apache License
@Override public void itemSelected(NavItem item) { if (item.getId().equals(LANDING_NAV_ITEM_ID)) { DOM.getElementById("main").addClassName("landing"); } else {/*from w w w . j a v a 2 s.co m*/ DOM.getElementById("main").removeClassName("landing"); } if (!m_isSausage) { for (final NavItem key : m_panels.keySet()) { /* We could hide and show these panels by just calling setVisible, but that causes a redraw bug in IE 8 where the body extends for for the total height of the page below the footer. */ if (key.equals(item)) { /* * The sliding grid on the widgets panel needs to be aligned * when it is set to visible, otherwise if the landing page * is the first page the browser's been to, the onLoad is too early * for the width of the sliding grid panel to be determined. */ if (WIDGETS_NAV_ITEM_ID.equals(key.getElement().getId())) { JSUtil.show("#" + m_panels.get(key).getElement().getId(), "normal", new JSEffectCallback() { @Override public void effectComplete(String id) { ((WidgetsPanel) m_panels.get(key)).getSlideGridPanel().reAlignGrid(); } }); } else { JSUtil.show("#" + m_panels.get(key).getElement().getId()); } } else { JSUtil.hide("#" + m_panels.get(key).getElement().getId(), "fast"); } } Window.scrollTo(0, 0); } else { for (NavItem key : m_panels.keySet()) { /* In the sausage mode we just scroll things to be visible */ if (key.equals(item)) { Window.scrollTo(0, getTop(m_panels.get(key).getElement().getId())); return; } } } }