Example usage for com.google.gwt.user.client Window getScrollLeft

List of usage examples for com.google.gwt.user.client Window getScrollLeft

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window getScrollLeft.

Prototype

public static int getScrollLeft() 

Source Link

Usage

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  w w  .  j  a  v a 2s .c om
 * @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>
 * // w w w  .j  a  v  a 2  s  . c om
 * @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);/*  www .  ja  v a2 s.c  o  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();

        }

    });

}

From source file:com.anritsu.mcrepositorymanager.client.FilterRSSForm.java

public FilterRSSForm(String mcVersion) {
    this.mcVersion = mcVersion;
    initWidget(uiBinder.createAndBindUi(this));

    f.setMcVersion(mcVersion);//from  ww w. j av  a 2 s.  co m

    // Initiate PackageInfoParser with selected MC version
    getService().initiateParser(f, initiateParserCallback);

    // Get mcBaselineAttributes
    // getService().getMCBaselineAttributes(getMCBaselinesAttributesCallback);
    changeMCVersion.setWidth("25%");
    changeMCVersion.setText("MasterClaw " + mcVersion);
    filter.setEnabled(true);

    downloadRepositoryArchive.setVisible(false);
    repositoryDownloadLink.setVisible(false);

    q7admOutput.setHeight("200px");
    q7admOutput.setPlaceholder("Please paste q7adm output");

    // Change MC version
    changeMCVersion.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            RootPanel.get().clear();
            SelectFilterForm selectFilterForm = new SelectFilterForm();
            RootPanel.get().add(selectFilterForm);
        }
    });

    //Building the table
    buildPackageListTable();

    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) {
            downloadRepositoryArchive.setVisible(false);
            downloadRepositoryArchive.setActive(false);
            repositoryDownloadLink.setVisible(false);
            repositoryDownloadLink.setActive(false);
            f.setCustomer(customers.getSelectedValue());
            f.setAvailability(availabilities.getAllSelectedValues());
            f.setQ7admOutput(q7admOutput.getText());
            f.setMcComponent(packagesName.getAllSelectedValues());
            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()) {
                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);

        }
    });

    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();
        }
    });

    //        repositoryDownloadLink.sinkEvents(Event.ONCONTEXTMENU);
    //        repositoryDownloadLink.addHandler(new ContextMenuHandler() {
    //            @Override
    //            public void onContextMenu(ContextMenuEvent event) {
    //                event.preventDefault();
    //                event.stopPropagation();
    //                PopupPanel popupContext = new PopupPanel(true);
    //                popupContext.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
    //                String link = Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/DownloadRepoArchive?archiveName=" + downloadRepositoryArchive.getTitle();
    //                Anchor anchor = new Anchor(link, link);
    //                popupContext.add(anchor);
    //                popupContext.show();
    //            }
    //        }, ContextMenuEvent.getType());

}

From source file:com.arcbees.gquery.appear.client.Appear.java

License:Apache License

private static boolean isScrolledIntoView(Element e, AppearImpl impl) {
    int docViewTop = Window.getScrollTop();
    int docViewBottom = docViewTop + Window.getClientHeight();
    int docViewLeft = Window.getScrollLeft();
    int docViewRight = docViewLeft + Window.getClientWidth();

    AppearOffset offset = impl.getOptions().getOffset();
    int elemTop = e.getAbsoluteTop() + offset.getTop();
    int elemLeft = e.getAbsoluteLeft() + offset.getLeft();
    int elemBottom = elemTop + e.getOffsetHeight() - offset.getBottom();
    int elemRight = elemLeft + e.getOffsetWidth() - offset.getRight();

    boolean isVerticalVisible = elemTop >= docViewTop && elemBottom <= docViewBottom
            || elemTop <= docViewBottom && elemBottom > docViewBottom
            || elemBottom >= docViewTop && elemTop < docViewTop;

    boolean isHorizontalVisible = elemLeft >= docViewLeft && elemRight <= docViewRight
            || elemLeft <= docViewRight && elemRight > docViewRight
            || elemRight >= docViewLeft && elemLeft < docViewLeft;

    return isVerticalVisible && isHorizontalVisible;
}

From source file:com.areahomeschoolers.baconbits.client.content.calendar.dayview.DayView.java

License:Open Source License

@Override
public void onDoubleClick(Element element, Event event) {

    List<AppointmentWidget> list = findAppointmentWidgetsByElement(element);
    if (!list.isEmpty()) {
        Appointment appt = list.get(0).getAppointment();
        // if (appt.equals(calendarWidget.getSelectedAppointment()))
        calendarWidget.fireOpenEvent(appt);
        // exit out
    } else if (getSettings().getTimeBlockClickNumber() == Click.Double
            && element == dayViewBody.getGrid().gridOverlay.getElement()) {
        int x = DOM.eventGetClientX(event) + Window.getScrollLeft();
        int y = DOM.eventGetClientY(event) + Window.getScrollTop();
        timeBlockClick(x, y);/*www . j  av  a 2  s  . c  o m*/
    }
}

From source file:com.areahomeschoolers.baconbits.client.content.calendar.monthview.MonthView.java

License:Open Source License

private void dayClicked(Event event) {
    int y = event.getClientY() + Window.getScrollTop() - DOM.getAbsoluteTop(appointmentCanvas.getElement());
    int x = event.getClientX() + Window.getScrollLeft() - DOM.getAbsoluteLeft(appointmentCanvas.getElement());

    int row = (int) Math.floor(y / (appointmentCanvas.getOffsetHeight() / monthViewRequiredRows));
    int col = (int) Math.floor(x / (appointmentCanvas.getOffsetWidth() / DAYS_IN_A_WEEK));
    calendarWidget.fireTimeBlockClickEvent(cellDate(row * DAYS_IN_A_WEEK + col));
}

From source file:com.axlight.gbrain.client.MainPane.java

License:Apache License

private void supportDragAndDrop() {
    drawArea.addMouseDownHandler(new MouseDownHandler() {
        public void onMouseDown(MouseDownEvent event) {
            // XXX workaround for iPad, which fires mouse events even with
            // preventDefault.
            if (touchHandlerEnabled) {
                return;
            }//w ww .  j  av a  2  s  .com

            int eventX = event.getX();
            int eventY = event.getY();
            if (selectNode != null && selectNode.containsPoint(eventX, eventY)) {
                startDrag(selectNode, eventX, eventY);
            } else {
                sliding = true;
                slideStartX = eventX;
                slideStartY = eventY;
            }
        }
    });
    drawArea.addMouseUpHandler(new MouseUpHandler() {
        public void onMouseUp(MouseUpEvent event) {
            stopDrag();
            sliding = false;
        }
    });
    drawArea.addMouseMoveHandler(new MouseMoveHandler() {
        public void onMouseMove(MouseMoveEvent event) {
            int eventX = event.getX();
            int eventY = event.getY();
            updateDrag(eventX, eventY);
            if (sliding) {
                int left = Window.getScrollLeft();
                int top = Window.getScrollTop();
                left -= eventX - slideStartX;
                top -= eventY - slideStartY;
                Window.scrollTo(left, top);
            }
        }
    });
}

From source file:com.bradrydzewski.gwt.calendar.client.dayview.DayView.java

License:Open Source License

public void onDoubleClick(Element element, Event event) {

    List<AppointmentWidget> list = findAppointmentWidgetsByElement(element);
    if (!list.isEmpty()) {
        Appointment appt = list.get(0).getAppointment();
        //if (appt.equals(calendarWidget.getSelectedAppointment()))
        calendarWidget.fireOpenEvent(appt);
        // exit out
    } else if (getSettings().getTimeBlockClickNumber() == Click.Double
            && element == dayViewBody.getGrid().gridOverlay.getElement()) {
        int x = DOM.eventGetClientX(event) + Window.getScrollLeft();
        int y = DOM.eventGetClientY(event) + Window.getScrollTop();
        timeBlockClick(x, y);/*  w w w. j  a va 2s  .c  o m*/
    }
}

From source file:com.bradrydzewski.gwt.calendar.client.dayview.DayView.java

License:Open Source License

public void onSingleClick(final Element element, final Event event) {

    // Ignore the scroll panel
    if (dayViewBody.getScrollPanel().getElement().equals(element)) {
        return;/*from   w w w  . j a v a  2  s  .c  om*/
    }

    Appointment appointment = findAppointmentByElement(element);

    if (appointment != null) {
        selectAppointment(appointment);
    } else if ((getSettings().getTimeBlockClickNumber() == Click.Single
            || getSettings().getTimeBlockClickNumber() == Click.Drag)
            && element == dayViewBody.getGrid().gridOverlay.getElement()) {
        int x = DOM.eventGetClientX(event) + Window.getScrollLeft();
        int y = DOM.eventGetClientY(event) + Window.getScrollTop();
        timeBlockClick(x, y);
    }
}