List of usage examples for com.google.gwt.user.client Window getScrollTop
public static int getScrollTop()
From source file:org.nuxeo.opensocial.container.client.view.ContainerBuilderWidget.java
License:Open Source License
public ContainerBuilderWidget() { this.setModal(false); this.setAutoHideEnabled(false); this.setAnimationEnabled(true); this.setPopupPosition(10, Window.getScrollTop() + 10); this.setText(constants.windowTitle()); this.addStyleName("builder"); builderContent = new VerticalPanel(); this.add(builderContent); builderContent.setWidth("200px"); builderContent.setStyleName("builder"); }
From source file:org.nuxeo.opensocial.container.client.view.ContainerBuilderWidget.java
License:Open Source License
public void showPopup() { this.setPopupPosition(10, Window.getScrollTop() + 10); this.show(); }
From source file:org.opencms.acacia.client.ui.CmsInlineEntityWidget.java
License:Open Source License
/** * Positions the given pop-up relative to the reference element.<p> *//*from ww w .j a v a2 s. c o m*/ void positionPopup() { if (m_popup != null) { if (m_referenceElement != null) { CmsPositionBean referencePosition = CmsPositionBean.getBoundingClientRect(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:org.opencms.ade.containerpage.client.ui.groupeditor.A_CmsGroupEditor.java
License:Open Source License
/** * Opens the group container edit dialog.<p> * * @param dialogTitle the dialog title//from w w w . j ava2 s . c o m */ protected void openDialog(String dialogTitle) { m_editorDialog.setCaption(dialogTitle); int contentHeight = m_dialogContent.getOffsetHeight(); m_editorDialog.setMainContent(m_dialogContent); // position dialog and show it if (m_groupContainerPosition != null) { int lefthandSpace = m_groupContainerPosition.getLeft() - Window.getScrollLeft(); int righthandSpace = (Window.getClientWidth() + Window.getScrollLeft()) - (m_groupContainerPosition.getLeft() + m_groupContainerPosition.getWidth()); int requiredWidth = CmsPopup.DEFAULT_WIDTH + 30; int left = m_groupContainerPosition.getLeft(); if (requiredWidth > (righthandSpace + m_groupContainerPosition.getWidth())) { left = (Window.getClientWidth() + Window.getScrollLeft()) - requiredWidth; } if (left < Window.getScrollLeft()) { left = 0; } if (lefthandSpace > requiredWidth) { // place left of the group container if there is enough space m_editorDialog.setPopupPosition(m_groupContainerPosition.getLeft() - requiredWidth, m_groupContainerPosition.getTop() - 1); } else if ((m_groupContainerPosition.getTop() - Window.getScrollTop()) > (contentHeight + DIALOG_BASE_HEIGHT + 50)) { // else place above if there is enough space m_editorDialog.setPopupPosition(left, m_groupContainerPosition.getTop() - (contentHeight + DIALOG_BASE_HEIGHT)); } else if (righthandSpace > requiredWidth) { // else on the right if there is enough space m_editorDialog.setPopupPosition( m_groupContainerPosition.getLeft() + m_groupContainerPosition.getWidth() + 20, m_groupContainerPosition.getTop() - 1); } else { // last resort, place below m_editorDialog.setPopupPosition(left, m_groupContainerPosition.getTop() + m_groupContainerPosition.getHeight() + 20); } m_editorDialog.show(); } else { // should never happen m_editorDialog.center(); } if (!m_controller.getData().isUseClassicEditor()) { for (Widget element : m_groupContainer) { if (element instanceof CmsContainerPageElementPanel) { ((CmsContainerPageElementPanel) element).initInlineEditor(m_controller); } } } }
From source file:org.opencms.gwt.client.dnd.CmsDNDHandler.java
License:Open Source License
/** * Convenience method to get the appropriate scroll direction.<p> * // www . j a v a 2s.c o 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) { 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; }
From source file:org.opencms.gwt.client.ui.CmsMenuButton.java
License:Open Source License
/** * Positions the menu popup the button.<p> *///from w ww. jav a 2 s. c om protected void positionPopup() { int spaceAssurance = 20; int space = getToolbarWidth() + (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 CmsPositionBean buttonPosition = CmsPositionBean.generatePositionInfo(m_button.getElement()); int buttonMiddle = (buttonPosition.getLeft() - Window.getScrollLeft()) + (buttonPosition.getWidth() / 2); // get the content width int contentWidth = m_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_CmsLayoutBundle.INSTANCE.gwtImages().menuArrowTopImage().getWidth(); int arrowHeight = I_CmsLayoutBundle.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_CmsLayoutBundle.INSTANCE.dialogCss().menuArrowTop(); int contentTop = (((buttonPosition.getTop() + buttonPosition.getHeight()) - Window.getScrollTop()) + arrowHeight) - 2; if (!m_isToolbarMode) { contentTop = (buttonPosition.getTop() + buttonPosition.getHeight() + arrowHeight) - 2; int contentHeight = m_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_CmsLayoutBundle.INSTANCE.dialogCss().menuArrowBottom(); } } else { contentLeft = contentLeft - Window.getScrollLeft(); m_popup.setPositionFixed(); } m_arrow.setClassName(arrowClass); m_arrow.getStyle().setLeft(arrowLeft, Unit.PX); m_arrow.getStyle().setTop(arrowTop, Unit.PX); m_popup.showArrow(m_arrow); m_popup.setPopupPosition(contentLeft + Window.getScrollLeft(), contentTop); }
From source file:org.opencms.gwt.client.ui.CmsPopup.java
License:Open Source License
/** * Shows the dialog and centers it horizontally, but positions it at a fixed vertical position.<p> * /* www . j a v a2 s. c om*/ * @param top the top position */ public void centerHorizontally(int top) { show(); int left = (Window.getClientWidth() - getOffsetWidth()) >> 1; setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max(Window.getScrollTop() + top, 0)); }
From source file:org.opencms.gwt.client.ui.CmsScrollBar.java
License:Open Source License
/** * Returns <code>true</code> if the events mouse position is above the scroll bar knob.<p> * * @param event the mouse event/* ww w .j a va 2 s . c om*/ * * @return <code>true</code> if the events mouse position is above the scroll bar knob */ private boolean sliderClicked(Event event) { boolean result = CmsPositionBean.generatePositionInfo(m_knob).isOverElement( event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop()); CmsDebugLog.getInstance().printLine("Slider was clicked: " + result); return result; }
From source file:org.opencms.gwt.client.ui.CmsShowWorkplace.java
License:Open Source License
/** * Opens the workplace.<p>/* w ww. j a va 2 s. c om*/ * * @param structureId the structure id of the resource for which the workplace should be opened */ protected static void openWorkplace(final CmsUUID structureId) { CmsRpcAction<String> callback = new CmsRpcAction<String>() { /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute() */ @Override public void execute() { CmsCoreProvider.getService().getWorkplaceLink(structureId, this); } /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object) */ @Override protected void onResponse(String result) { int width = Window.getClientWidth(); int height = Window.getClientHeight(); int left = Window.getScrollLeft(); int top = Window.getScrollTop(); openWorkplace(result, width, height, left, top); } }; callback.execute(); }
From source file:org.opencms.gwt.client.ui.CmsToolbarPopup.java
License:Open Source License
/** * Positions the popup below the toolbar button.<p> */// ww w . j a v a 2 s. c o m public void position() { // get the window client width int windowWidth = Window.getClientWidth(); // get the min left position int minLeft = MIN_MARGIN; // get the max right position int maxRight = windowWidth - MIN_MARGIN; // get the middle button position CmsPositionBean buttonPosition = CmsPositionBean.generatePositionInfo(m_button.getElement()); int buttonMiddle = (buttonPosition.getLeft() - Window.getScrollLeft()) + (buttonPosition.getWidth() / 2); // get the content width int contentWidth = 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 + MIN_MARGIN) > windowWidth) { contentLeft = windowWidth - contentWidth - MIN_MARGIN; } // limit the left position if the popup is left outside the window if (contentLeft < MIN_MARGIN) { contentLeft = MIN_MARGIN; } int arrowSpace = 10; int arrowWidth = 40; int arrowHeight = 12; // 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_CmsLayoutBundle.INSTANCE.dialogCss().menuArrowTop(); int contentTop = (((buttonPosition.getTop() + buttonPosition.getHeight()) - Window.getScrollTop()) + arrowHeight) - 2; if (!m_isToolbarMode) { contentTop = (buttonPosition.getTop() + buttonPosition.getHeight() + arrowHeight) - 2; int contentHeight = getOffsetHeight(); int windowHeight = Window.getClientHeight(); if (((contentHeight + MIN_MARGIN) < windowHeight) && ((buttonPosition.getTop() - Window.getScrollTop()) > contentHeight) && (((contentHeight + MIN_MARGIN + 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_CmsLayoutBundle.INSTANCE.dialogCss().menuArrowBottom(); } } else { contentLeft = contentLeft - Window.getScrollLeft(); setPositionFixed(); } m_arrow.setClassName(arrowClass); m_arrow.getStyle().setLeft(arrowLeft, Unit.PX); m_arrow.getStyle().setTop(arrowTop, Unit.PX); showArrow(m_arrow); setPopupPosition(contentLeft + Window.getScrollLeft(), contentTop); }