List of usage examples for com.google.gwt.user.client Window getScrollTop
public static int getScrollTop()
From source file:ch.unifr.pai.twice.widgets.mpproxy.client.ScreenShotDistributor.java
License:Apache License
/** * Send the screenshot to the server//w w w . j a v a 2 s . c om */ public void sendScreenShot() { String screen = Document.get().getDocumentElement().getInnerHTML(); if (!screen.equals(lastSent) || lastLeft != Window.getScrollLeft() || lastTop != Window.getScrollTop()) { String url = Window.Location.getHref(); URLParser p = new URLParser(url, Rewriter.getServletPath(Window.Location.getHref())); RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, GWT.getModuleBaseURL() + "manager?url=" + p.getProxyBasePath() + "&width=" + Window.getClientWidth() + "&height=" + Window.getClientHeight() + "&top=" + Window.getScrollTop() + "&left=" + Window.getScrollLeft()); lastSent = screen; lastLeft = Window.getScrollLeft(); lastTop = Window.getScrollTop(); screen = screen.replace('\n', ' '); screen = screen.replaceAll("<body", "<body><div class=\"readOnlyView\" style=\"width:" + Window.getClientWidth() + "; height:" + Window.getClientHeight() + ";\""); screen = screen.replaceAll("<\\/body>", "</div></body>"); screen = screen.replaceAll("(<script).*?(\\/script>)", ""); try { rb.sendRequest(screen, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { // TODO Auto-generated method stub } @Override public void onError(Request request, Throwable exception) { Window.alert("Screenshot sent"); } }); } catch (RequestException e) { e.printStackTrace(); } } }
From source file:co.fxl.gui.gwt.GWTDisplay.java
License:Open Source License
void resetScrollPanelTop() { if (isChrome && !scrolling && Window.getScrollTop() != 0) { Window.scrollTo(Window.getScrollLeft(), 0); } }
From source file:com.alkacon.acacia.client.ui.AttributeChoiceWidget.java
License:Open Source License
/** * Evaluates if the choice select should be displayed above the button.<p> * //from w w w . j a v a2 s .c o m * @return <code>true</code> if the choice select should be displayed above the button */ private boolean displayAbove() { int popupHeight = m_choices.getOffsetHeight(); // Calculate top position for the choice select int top = m_buttonIcon.getAbsoluteTop(); // Make sure scrolling is taken into account, since // box.getAbsoluteTop() takes scrolling into account. int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); // Distance from the top edge of the window to the top edge of the // text box int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the bottom edge of // the text box int distanceToWindowBottom = windowBottom - (top + m_buttonIcon.getOffsetHeight()); // If there is not enough space for the popup's height below the button // and there IS enough space for the popup's height above the button, // then then position the popup above the button. However, if there // is not enough space on either side, then stick with displaying the // popup below the button. boolean displayAbove = (distanceFromWindowTop > distanceToWindowBottom) && (distanceToWindowBottom < popupHeight); return displayAbove; }
From source file:com.alkacon.acacia.client.ui.ChoiceSubmenu.java
License:Open Source License
/** * Checks whether the submenu should be opened above instead of below.<p> * // ww w .ja va2 s. c om * @param referenceElement the reference element * @return true if the new submenu should be opened above */ public boolean openAbove(Element referenceElement) { int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); int spaceAbove = referenceElement.getAbsoluteTop() - windowTop; int spaceBelow = windowBottom - referenceElement.getAbsoluteBottom(); return spaceAbove > spaceBelow; }
From source file:com.alkacon.acacia.client.ui.InlineEntityWidget.java
License:Open Source License
/** * Positions the given pop-up relative to the reference element.<p> *//* w ww .j av a2 s . c o m*/ void positionPopup() { if (m_referenceElement != null) { PositionBean referencePosition = PositionBean.getInnerDimensions(m_referenceElement); int currentTop = m_popup.getAbsoluteTop(); int windowHeight = Window.getClientHeight(); int scrollTop = Window.getScrollTop(); int contentHeight = m_popup.getOffsetHeight(); int top = referencePosition.getTop(); if (((windowHeight + scrollTop) < (top + referencePosition.getHeight() + contentHeight + 20)) && ((contentHeight + 40) < top)) { top = top - contentHeight - 5; if ((currentTop < top) && ((top - currentTop) < 200)) { // keep the current position top = currentTop; } } else { top = top + referencePosition.getHeight() + 5; if ((currentTop > top) && ((currentTop - top) < 200)) { // keep the current position top = currentTop; } } m_popup.center(); m_popup.setPopupPosition(m_popup.getPopupLeft(), top); if (((contentHeight + top) - scrollTop) > windowHeight) { Window.scrollTo(Window.getScrollLeft(), ((contentHeight + top) - windowHeight) + 20); } } else { m_popup.center(); } }
From source file:com.alkacon.geranium.client.dnd.DNDHandler.java
License:Open Source License
/** * Execute on mouse wheel event.<p> * // w w w . j av a 2 s .c om * @param event the native event */ protected void onMouseWheelScroll(Event event) { int scrollStep = event.getMouseWheelVelocityY() * 5; Element scrollTarget; if (getCurrentTarget() != null) { scrollTarget = getCurrentTarget().getElement(); } else { scrollTarget = RootPanel.getBodyElement(); } while ((scrollTarget.getScrollHeight() == scrollTarget.getClientHeight()) && (scrollTarget != RootPanel.getBodyElement())) { scrollTarget = scrollTarget.getParentElement(); } if (scrollTarget == RootPanel.getBodyElement()) { int top = Window.getScrollTop() + scrollStep; int left = Window.getScrollLeft(); if (top < 0) { top = 0; } Window.scrollTo(left, top); } else { int top = scrollTarget.getScrollTop() + scrollStep; if (top < 0) { top = 0; } scrollTarget.setScrollTop(top); } onMove(event); }
From source file:com.alkacon.geranium.client.dnd.DNDHandler.java
License:Open Source License
/** * Convenience method to get the appropriate scroll direction.<p> * /*from w w w . j a v a 2 s. co m*/ * @param offset the scroll parent border offset, if the cursor is within the border offset, scrolling should be triggered * * @return the scroll direction */ private Direction getScrollDirection(int offset) { if (m_scrollElement == null) { Element body = RootPanel.getBodyElement(); int windowHeight = Window.getClientHeight(); int bodyHeight = body.getClientHeight(); if (windowHeight < bodyHeight) { if (((windowHeight - m_clientY) < offset) && (Window.getScrollTop() < (bodyHeight - windowHeight))) { return Direction.down; } if ((m_clientY < offset) && (Window.getScrollTop() > 0)) { return Direction.up; } } int windowWidth = Window.getClientWidth(); int bodyWidth = body.getClientWidth(); if (windowWidth < bodyWidth) { if (((windowWidth - m_clientX) < offset) && (Window.getScrollLeft() < (bodyWidth - windowWidth))) { return Direction.right; } if ((m_clientX < offset) && (Window.getScrollLeft() > 0)) { return Direction.left; } } return null; } else { int outerHeight = m_scrollElement.getClientHeight(); int innerHeight = m_scrollElement.getScrollHeight(); if (outerHeight < innerHeight) { if ((((outerHeight + m_scrollElement.getAbsoluteTop()) - m_clientY) < offset) && (m_scrollElement.getScrollTop() < (innerHeight - outerHeight))) { return Direction.down; } if (((m_clientY - m_scrollElement.getAbsoluteTop()) < offset) && (m_scrollElement.getScrollTop() > 0)) { return Direction.up; } } int outerWidth = m_scrollElement.getClientWidth(); int innerWidth = m_scrollElement.getScrollWidth(); if (outerWidth < innerWidth) { if ((((outerWidth + m_scrollElement.getAbsoluteLeft()) - m_clientX) < offset) && (m_scrollElement.getScrollLeft() < (innerWidth - outerWidth))) { return Direction.right; } if (((m_clientX - m_scrollElement.getAbsoluteLeft()) < offset) && (m_scrollElement.getScrollLeft() > 0)) { return Direction.left; } } return null; } }
From source file:com.alkacon.geranium.client.ui.Popup.java
License:Open Source License
/** * Shows the dialog and centers it horizontally, but positions it at a fixed vertical position.<p> * /*from w ww . jav a 2 s .c o m*/ * @param top the top position */ public void centerHorizontally(int top) { if (Position.FIXED.getCssName().equals(getElement().getStyle().getPosition())) { show(); // keep position fixed, as may have been set to absolute setPositionFixed(); int left = (Window.getClientWidth() - getOffsetWidth()) >> 1; setPopupPosition(Math.max(left, 0), Math.max(top, 0)); } else { show(); int left = (Window.getClientWidth() - getOffsetWidth()) >> 1; setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max(Window.getScrollTop() + top, 0)); } }
From source file:com.alkacon.geranium.client.ui.ToolbarPopup.java
License:Open Source License
/** * Positions the menu popup the button.<p> * //from w w w. j av a2 s . co m * @param popup the popup to position * @param button the toolbar button * @param toolbarWidth the width of the toolbar * @param isToolbarMode a flag indicating whether the button is in toolbar mode * @param arrow the arrow shaped connector element */ protected static void positionPopup(Popup popup, Widget button, int toolbarWidth, boolean isToolbarMode, Element arrow) { int spaceAssurance = 20; int space = toolbarWidth + (2 * spaceAssurance); // get the window client width int windowWidth = Window.getClientWidth(); // get the min left position int minLeft = (windowWidth - space) / 2; if (minLeft < spaceAssurance) { minLeft = spaceAssurance; } // get the max right position int maxRight = minLeft + space; // get the middle button position PositionBean buttonPosition = PositionBean.generatePositionInfo(button.getElement()); int buttonMiddle = (buttonPosition.getLeft() - Window.getScrollLeft()) + (buttonPosition.getWidth() / 2); // get the content width int contentWidth = popup.getOffsetWidth(); // the optimum left position is in the middle of the button minus the half content width // assume that the optimum fits into the space int contentLeft = buttonMiddle - (contentWidth / 2); if (minLeft > contentLeft) { // if the optimum left position of the popup is outside the min left position: // move the popup to the right (take the min left position as left) contentLeft = minLeft; } else if ((contentLeft + contentWidth) > maxRight) { // if the left position plus the content width is outside the max right position: // move the popup to the left (take the max right position minus the content width) contentLeft = maxRight - contentWidth; } // limit the right position if the popup is right outside the window if ((contentLeft + contentWidth + spaceAssurance) > windowWidth) { contentLeft = windowWidth - contentWidth - spaceAssurance; } // limit the left position if the popup is left outside the window if (contentLeft < spaceAssurance) { contentLeft = spaceAssurance; } int arrowSpace = 10; int arrowWidth = I_LayoutBundle.INSTANCE.gwtImages().menuArrowTopImage().getWidth(); int arrowHeight = I_LayoutBundle.INSTANCE.gwtImages().menuArrowTopImage().getHeight(); // the optimum position for the arrow is in the middle of the button int arrowLeft = buttonMiddle - contentLeft - (arrowWidth / 2); if ((arrowLeft + arrowWidth + arrowSpace) > contentWidth) { // limit the arrow position if the maximum is reached (content width 'minus x') arrowLeft = contentWidth - arrowWidth - arrowSpace; } else if ((arrowLeft - arrowSpace) < 0) { // limit the arrow position if the minimum is reached ('plus x') arrowLeft = arrowWidth + arrowSpace; } int arrowTop = -(arrowHeight - 2); String arrowClass = I_LayoutBundle.INSTANCE.dialogCss().menuArrowTop(); int contentTop = (((buttonPosition.getTop() + buttonPosition.getHeight()) - Window.getScrollTop()) + arrowHeight) - 2; if (!isToolbarMode) { contentTop = (buttonPosition.getTop() + buttonPosition.getHeight() + arrowHeight) - 2; int contentHeight = popup.getOffsetHeight(); int windowHeight = Window.getClientHeight(); if (((contentHeight + spaceAssurance) < windowHeight) && ((buttonPosition.getTop() - Window.getScrollTop()) > contentHeight) && (((contentHeight + spaceAssurance + contentTop) - Window.getScrollTop()) > windowHeight)) { // content fits into the window height, // there is enough space above the button // and there is to little space below the button // so show above contentTop = ((buttonPosition.getTop() - arrowHeight) + 2) - contentHeight; arrowTop = contentHeight - 1; arrowClass = I_LayoutBundle.INSTANCE.dialogCss().menuArrowBottom(); } } else { contentLeft = contentLeft - Window.getScrollLeft(); popup.setPositionFixed(); } arrow.setClassName(arrowClass); arrow.getStyle().setLeft(arrowLeft, Unit.PX); arrow.getStyle().setTop(arrowTop, Unit.PX); popup.showArrow(arrow); popup.setPopupPosition(contentLeft + Window.getScrollLeft(), contentTop); }
From source file:com.anritsu.mcrepositorymanager.client.FilterDBForm.java
public FilterDBForm(String mcVersion) { this.mcVersion = mcVersion; initWidget(uiBinder.createAndBindUi(this)); packageListTable.setVisible(false);/*from w w w. ja va 2 s. co m*/ hPanelLoading.setVisible(false); pageHeader.setText("MasterClaw " + mcVersion + " Repository Generator"); dataProvider.addDataDisplay(packageListTable); f.setMcVersion(mcVersion); // Initiate PackageInfoParser with selected MC version getService().initiateParser(f, initiateParserCallback); filter.setEnabled(true); downloadRepositoryArchive.setVisible(false); repositoryDownloadLink.setVisible(false); q7admOutput.setHeight("200px"); q7admOutput.setPlaceholder("Please paste 'yum list' output"); serviceDescription.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { serviceDescriptionModal.show(); } }); returnToBaselineSelection.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { RootPanel.get().clear(); SelectFilterForm selectFilterForm = new SelectFilterForm(); RootPanel.get().add(selectFilterForm); } }); //Building the table buildPackageListTable(packageListTable); cancelPackageGeneration.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { generateModal.hide(); } }); generateModal.addHideHandler(new ModalHideHandler() { @Override public void onHide(ModalHideEvent evt) { t.cancel(); } }); filter.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hPanelLoading.setVisible(true); //generateRepository.setEnabled(false); downloadRepositoryArchive.setVisible(false); downloadRepositoryArchive.setActive(false); repositoryDownloadLink.setVisible(false); repositoryDownloadLink.setActive(false); packageListTable.setVisible(false); f.setRecommended((recommended.getSelectedValue().equalsIgnoreCase("recommended")) || (recommended.getSelectedValue().equalsIgnoreCase("latest validated"))); f.setCustomer(customers.getSelectedValue()); f.setAvailability(availabilities.getAllSelectedValues()); f.setQ7admOutput(q7admOutput.getText()); f.setMcComponent(packagesName.getAllSelectedValues()); f.setRecommendedFilter(recommended.getSelectedValue()); f.setLocalDependencies(localDependencies.getSelectedValue().equalsIgnoreCase("yes")); // set activities filter List<MCPackageActivities> activitiesList = new ArrayList<>(); List<String> activitiesECRValues = activitiesECR.getAllSelectedValues(); for (String string : activitiesECRValues) { String[] activitySplit = string.split(":::"); MCPackageActivities mcpa = new MCPackageActivities(); mcpa.setActivityType(activitySplit[0]); mcpa.setActivityId(activitySplit[1]); mcpa.setActivityText(activitySplit[2]); activitiesList.add(mcpa); } List<String> activitiesEPRValues = activitiesEPR.getAllSelectedValues(); for (String string : activitiesEPRValues) { String[] activitySplit = string.split(":::"); MCPackageActivities mcpa = new MCPackageActivities(); mcpa.setActivityType(activitySplit[0]); mcpa.setActivityId(activitySplit[1]); mcpa.setActivityText(activitySplit[2]); activitiesList.add(mcpa); } f.setActivities(activitiesList); getService().getPackageList(f, getPackageListCallback); } }); generateRepository.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { downloadRepositoryArchive.setVisible(false); downloadRepositoryArchive.setEnabled(false); repositoryDownloadLink.setVisible(false); repositoryDownloadLink.setEnabled(false); int downloadCount = 0; ArrayList<McPackage> packageList = new ArrayList<>(); for (McPackage p : dataProvider.getList()) { if (p.getDownloadLinks() != null && !p.getDownloadLinks().isEmpty()) { packageList.add(p); } if (p.isAddToRepository()) { downloadCount++; } } totalProgressBar.setPercent(0); packageGenerationMessage.setHTML(""); generateModal.show(); getService().generateRepository(packageList, generateRepositoryCallback); // Call status each 5 sec t = new Timer() { @Override public void run() { getService().getPackingStatus(getPackingStatusCallback); } }; t.scheduleRepeating(1500); } }); recommended.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { switch (recommended.getSelectedValue()) { case "recommended": availabilities.deselectAll(); availabilities.setEnabled(false); break; // case "latest validated": // availabilities.deselectAll(); // availabilities.selectValues("FCA", "GCA"); // break; case "latest": availabilities.deselectAll(); availabilities.setEnabled(true); break; } } }); customers.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if (!customers.getSelectedValue().equals("All")) { availabilities.selectValues("SCR"); } else if (customers.getSelectedValue().equals("All")) { availabilities.deselectAll(); } } }); downloadRepositoryArchive.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.open("/DownloadRepoArchive?archiveName=" + downloadRepositoryArchive.getTitle(), "_parent", "location=no"); } }); repositoryDownloadLink.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { PopupPanel popupContext = new PopupPanel(true); popupContext.setPopupPosition(event.getNativeEvent().getClientX() + Window.getScrollLeft(), event.getNativeEvent().getClientY() + Window.getScrollTop()); String link = Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/DownloadRepoArchive?archiveName=" + downloadRepositoryArchive.getTitle(); Anchor anchor = new Anchor(link, link); popupContext.add(anchor); popupContext.show(); } }); }