Example usage for com.google.gwt.user.client.ui Widget getAbsoluteLeft

List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteLeft

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget getAbsoluteLeft.

Prototype

public int getAbsoluteLeft() 

Source Link

Document

Gets the object's absolute left position in pixels, as measured from the browser window's client area.

Usage

From source file:edu.caltech.ipac.firefly.ui.catalog.CatalogSearchDialog.java

private void performSearch(List<Param> params, final AsyncCallback<String> cb) {
    CatalogRequest req = new CatalogRequest(CatalogRequest.RequestType.GATOR_QUERY);
    req.setParams(params);/* ww  w  .j  av  a2  s .c  o  m*/
    req.setUse(CatalogRequest.Use.CATALOG_OVERLAY);
    Widget w = getDialogWidget();
    int cX = w.getAbsoluteLeft() + w.getOffsetWidth() / 2;
    int cY = w.getAbsoluteTop() + w.getOffsetHeight() / 2;
    IrsaCatalogTask.getCatalog(this.getDialogWidget(), req, new CatalogSearchResponse() {
        public void showNoRowsReturned() {
            PopupUtil.showError(_prop.getTitle("noRowsReturned"), _prop.getError("noRowsReturned"));
        }

        public void status(RequestStatus requestStatus) {
            cb.onSuccess("ok");
        }
    }, cX, cY, panel.getTitle());
}

From source file:edu.caltech.ipac.firefly.ui.catalog.CatalogSearchDropDown.java

private void performSearch(List<Param> params) {
    CatalogRequest req = new CatalogRequest(CatalogRequest.RequestType.GATOR_QUERY);
    req.setParams(params);/*from  w  w w .j a  va 2s  . co  m*/
    req.setUse(CatalogRequest.Use.CATALOG_OVERLAY);
    if (useSearchAdmin) {
        hide();
        String title = req.getParam(CatalogRequest.CATALOG_PROJECT) == null ? ""
                : req.getParam(CatalogRequest.CATALOG_PROJECT) + "-";
        title = title + req.getQueryCatName();
        SearchAdmin.getInstance().submitSearch(req, title);
    } else {
        Widget w = _mainPanel.getParent();
        int cX = w.getAbsoluteLeft() + w.getOffsetWidth() / 2;
        int cY = w.getAbsoluteTop() + w.getOffsetHeight() / 2;
        IrsaCatalogTask.getCatalog(_mainPanel, req, new CatalogSearchResponse() {
            public void showNoRowsReturned() {
                PopupUtil.showError(_prop.getTitle("noRowsReturned"), _prop.getError("noRowsReturned"));
            }

            public void status(RequestStatus requestStatus) {
                hide();
            }
        }, cX, cY, _catalogPanel.getTitle());
    }
}

From source file:edu.caltech.ipac.firefly.ui.DynDownloadSelectionDialog.java

private void startPackaging() {
    TitleRet title = buildTitle();//from  w  w  w.j  a  va2 s. com

    String emailStr = null;
    if (_useEmail.getValue() && !StringUtils.isEmpty(_emailField.getValue())) {
        emailStr = _emailField.getValue();
        Preferences.set(BackgroundManager.EMAIL_PREF, emailStr);
    }

    DownloadRequest dataRequest = getDownloadRequest();
    LayoutManager lman = Application.getInstance().getLayoutManager();
    dataRequest.setBaseFileName(title.getFileName());
    dataRequest.setTitle(title.getTitle());
    dataRequest.setEmail(emailStr);
    dataRequest.setDataSource(DynRequestHandler.getCurrentProject());

    // set options into request
    List<InputField> ifs = Form.searchForFields(_optionsPanel);
    for (InputField i : ifs) {
        if (GwtUtil.isOnDisplay(i) || i instanceof HiddenField) {
            dataRequest.setParam(i.getFieldDef().getName(), i.getValue());
        }
    }

    Widget maskW = lman.getRegion(LayoutManager.RESULT_REGION).getDisplay();
    Widget w = getDialogWidget();
    int cX = w.getAbsoluteLeft() + w.getOffsetWidth() / 2;
    int cY = w.getAbsoluteTop() + w.getOffsetHeight() / 2;
    PackageTask.preparePackage(maskW, cX, cY, dataRequest);
}

From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java

public static ScreenPt getCenterPos(Widget w) {
    if (w == null)
        return new ScreenPt(-1, -1);
    int x = w.getOffsetWidth() / 2 + w.getAbsoluteLeft();
    int y = w.getOffsetHeight() / 2 + w.getAbsoluteTop();
    return new ScreenPt(x, y);
}

From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java

public static int getX(Widget w) {
    WebAssert.argTst(w, "w cannot be null");
    int retval;//from   w  w w.j  av a2  s.  c o  m
    if (w.getParent() != null) {
        retval = w.getAbsoluteLeft() - w.getParent().getAbsoluteLeft();
    } else {
        retval = w.getAbsoluteLeft();
    }
    return retval;
}

From source file:edu.caltech.ipac.firefly.ui.PopupPane.java

/**
 * Determine where the place the popup. This is a huge and central method to PopupPane - it needs come cleaning up
 * @param xoffset offset x added to alignment
 * @param yoffset offset y added to alignment
 *//*from   w w  w  .  j a  va  2s .c  o m*/
private void alignPopup(final int xoffset, final int yoffset) {
    int x, y;

    if (popup != null)
        GwtUtil.setStyle(popup, "clip", "auto");
    if (firstAlign) {
        optimalWidth = content.getOffsetWidth();
        optimalHeight = content.getOffsetHeight();
        DeferredCommand.addCommand(new Command() {
            public void execute() {
                adjustResizable();
            }
        });
    }

    firstAlign = false;
    locateMask();

    PointerDir dir = PointerDir.NONE;

    if (alignAt == Align.DISABLE) {
        if (_pointerPopup)
            alignPointer(PointerDir.NORTH);
        return;
    }

    Widget alignWidget = this.alignWidget;
    if (alignWidget == null)
        alignWidget = RootPanel.get();

    int popupHeight = popup.getOffsetHeight();
    int popupWidth = popup.getOffsetWidth();
    int rootHeight = Window.getClientHeight();
    int rootWidth = Window.getClientWidth();

    int alignX = alignWidget.getAbsoluteLeft();
    int alignY = alignWidget.getAbsoluteTop();
    int alignWidth = alignWidget.getOffsetWidth();
    int alignHeight = alignWidget.getOffsetHeight();

    if (alignAt == Align.BOTTOM_LEFT) {
        x = alignX + xoffset;
        y = alignY + alignHeight + yoffset;

    } else if (alignAt == Align.BOTTOM_RIGHT) {
        x = alignX + alignWidth + xoffset;
        y = alignY + alignHeight + yoffset;

    } else if (alignAt == Align.AUTO_POINTER) {
        dir = PointerDir.NORTH;
        definePointerDirection(dir);
        x = alignX + (alignWidth / 2) - (popupWidth >> 1);
        if (_pointerPopup)
            x += HOR_PTR_IMAGE_OFFSET;
        y = alignY + alignHeight + yoffset;
        if (y + popupHeight > Window.getClientHeight()) {
            dir = PointerDir.SOUTH_WEST;
            definePointerDirection(dir);
            x = alignX + alignWidth + xoffset;
            if (_pointerPopup)
                x += HOR_PTR_IMAGE_OFFSET;
            y = (alignY - popupHeight + 5) - yoffset;

        }
    } else if (alignAt == Align.BOTTOM_CENTER) {
        x = alignX + (alignWidth / 2) - (popupWidth >> 1);
        if (_pointerPopup)
            x += HOR_PTR_IMAGE_OFFSET;
        y = alignY + alignHeight + yoffset;
    } else if (alignAt == Align.VISIBLE_BOTTOM) { //todo
        rootHeight = Window.getClientHeight();
        x = Window.getScrollLeft() + xoffset;
        y = Window.getScrollTop() + Window.getClientHeight() - popupHeight + yoffset;

    } else if (alignAt == Align.BOTTOM_CENTER_POPUP_BOTTOM) {
        x = alignX + (alignWidth / 2) - (popupWidth >> 1);
        if (_pointerPopup)
            x += HOR_PTR_IMAGE_OFFSET;
        y = alignY + alignHeight - popupHeight + yoffset;

    } else if (alignAt == Align.TOP_CENTER) {
        x = alignX + (alignWidth / 2) - (popupWidth >> 1);
        if (_pointerPopup)
            x += HOR_PTR_IMAGE_OFFSET;
        y = (alignY - popupHeight) - yoffset;

    } else if (alignAt == Align.TOP_RIGHT) {
        x = alignX + alignWidth + xoffset - popupWidth;
        y = alignY + yoffset;

    } else if (alignAt == Align.TOP_RIGHT_POPUP_RIGHT) {
        x = alignX + alignWidth + xoffset;
        y = alignY + yoffset;

    } else if (alignAt == Align.CENTER) {
        if (alignWidget == null) {
            int left = (Window.getClientWidth() - popupWidth) >> 1;
            int top = (Window.getClientHeight() - popupHeight) >> 1;
            x = Window.getScrollLeft() + left;
            y = Window.getScrollTop() + top;
        } else {
            int width = content.getOffsetWidth();
            int height = content.getOffsetHeight();
            x = alignX + alignWidth / 2;
            x = x - width / 2 + xoffset;
            y = alignY + alignHeight / 2;
            y = y - height / 2 + yoffset;
        }
        if (y < 0)
            y = 10;
        if (x < 0)
            x = 10;
    } else if (alignAt == Align.TOP_LEFT_POPUP_RIGHT) {
        x = alignX + xoffset - popupWidth;
        if (x < 0)
            x = 0;
        y = alignY + yoffset;
    } else if (alignAt == Align.TOP_LEFT_POPUP_BOTTOM) {
        x = alignX + xoffset;
        if (x < 0)
            x = 0;
        y = alignY + yoffset - popupHeight;
    } else if (alignAt == Align.TOP_RIGHT_OR_LEFT) {
        if (Window.getClientWidth() < (alignWidth + popupWidth)) {
            x = Window.getClientWidth() - ((xoffset + 35) + popupWidth);
            if (x < 0)
                x = 0;
            y = alignY + yoffset;
        } else {
            x = alignX + alignWidth + xoffset;
            y = alignY + yoffset;
        }

    } else {

        // default to TOP_LEFT
        x = 1 + xoffset;
        y = 1 + yoffset;
    }

    //----
    // Now adjust the popup to fit in the viewable area
    //----

    if (x + popupWidth > rootWidth) {
        x = x - ((x + popupWidth) - rootWidth); // move if over by the amount it is off the side
    }

    if (y + popupHeight > rootHeight && rootHeight > 10) { //if bottom of dialog is off the bottom, if root height is near 0 then don't adjust
        y = y - ((y + popupHeight) - rootHeight); // move if up by the amount it is off the bottom
    }

    if (y < Window.getScrollTop())
        y = Window.getScrollTop() + 1; // if it is off the top set it to the top +1
    if (x < Window.getScrollLeft())
        x = Window.getScrollLeft() + 1;// if it is off the left set it to the left +1

    if (_doAlign)
        _doAlign = _autoAlign;

    alignPointer(dir);

    if (popup.isVisible()) {
        if (popup.getAbsoluteLeft() != x || popup.getAbsoluteTop() != y) {
            popup.setPopupPosition(x, y);
        }
    }

}

From source file:edu.caltech.ipac.firefly.ui.PopupUtil.java

public static void showMinimalError(Widget anchor, String msg) {
    final PopupPanel p = new PopupPanel(true);
    p.setAnimationEnabled(true);//from   w  ww  . j  a  va 2s  . c  o m
    p.addStyleName("onTopDialog");
    p.setWidget(new HTML(msg));
    p.setPopupPosition(anchor.getAbsoluteLeft() + anchor.getOffsetWidth(),
            anchor.getAbsoluteTop() + anchor.getOffsetHeight());
    p.show();
    new Timer() {
        public void run() {
            p.hide();
        }
    }.schedule(4000);

}

From source file:edu.caltech.ipac.firefly.visualize.FloatingVisBar.java

private void startPackaging(DownloadRequest dataRequest) {
    /*todo: title= buildTitle();
            /*  ww w .j  av a 2  s.co  m*/
    String emailStr= null;
    if (_useEmail.getValue() && !StringUtils.isEmpty(_emailField.getValue()))  {
    emailStr= _emailField.getValue();
    Preferences.set(BackgroundManager.EMAIL_PREF, emailStr);
    }*/

    LayoutManager lman = Application.getInstance().getLayoutManager();
    dataRequest.setBaseFileName(dataRequest.getFilePrefix());
    dataRequest.setTitle(dataRequest.getTitlePrefix() + "-pdf-" + downloadCounter++);
    /*todo: add dialog box dataRequest.setEmail(emailStr);*/
    dataRequest.setDataSource(DynRequestHandler.getCurrentProject());
    dataRequest.setParam("file_type", "pdf");

    /*todo: add dialog box
    // set options into request
    List<InputField> ifs = Form.searchForFields(_optionsPanel);
    for (InputField i : ifs) {
    if (GwtUtil.isOnDisplay(i) || i instanceof HiddenField) {
        dataRequest.setParam(i.getFieldDef().getName(), i.getValue());
    }
    }*/

    Widget maskW = lman.getRegion(LayoutManager.RESULT_REGION).getDisplay();
    Widget w = _popup.getPopupPanel().getParent();
    int cX = w.getAbsoluteLeft() + w.getOffsetWidth() / 2;
    int cY = w.getAbsoluteTop() + w.getOffsetHeight() / 2;
    PackageTask.preparePackage(maskW, cX, cY, dataRequest);
}

From source file:es.deusto.weblab.client.lab.ui.themes.es.deusto.weblab.defaultmobile.LoginWindow.java

License:Open Source License

private void setupWidgets(final Widget wid) {
    this.logoImage.setUrl(GWT.getModuleBaseURL()
            + this.configurationManager.getProperty(DefaultTheme.Configuration.HOST_ENTITY_MOBILE_IMAGE, ""));

    final String hostEntityLink = this.configurationManager
            .getProperty(DefaultTheme.Configuration.HOST_ENTITY_LINK, "");
    this.institutionLink.setHref(hostEntityLink);

    // If ENTER is pressed, login as if the button had been clicked.
    final KeyDownHandler keyboardHandler = new KeyDownHandler() {
        @Override//w ww  . ja  va  2 s.  c om
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                LoginWindow.this.onLoginButtonClicked(null);
        }
    };
    this.usernameTextbox.addKeyDownHandler(keyboardHandler);
    this.passwordTextbox.addKeyDownHandler(keyboardHandler);

    final DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true);
    final VerticalPanel languageList = new VerticalPanel();
    for (int i = 0; i < IWebLabI18N.LANGUAGES.length; ++i) {
        final String curLanguage = IWebLabI18N.LANGUAGES[i];
        final String curLanguageCode = IWebLabI18N.LANGUAGE_CODES[i];
        final Anchor languageButton = new Anchor(curLanguage);
        languageButton.addClickHandler(new LanguageButtonClickHandler(curLanguageCode));
        languageList.add(languageButton);
    }
    languageList.setSpacing(15);

    simplePopup.setWidget(languageList);

    this.languages.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final Widget source = (Widget) event.getSource();
            final int left = source.getAbsoluteLeft() + 10;
            final int top = source.getAbsoluteTop() + 10;
            simplePopup.setPopupPosition(left, top);
            simplePopup.setModal(true);
            simplePopup.show();
        }
    });

    this.mainPanel.add(wid);

    final boolean demoAvailable = this.configurationManager
            .getBoolProperty(WebLabClientLab.DEMO_AVAILABLE_PROPERTY, WebLabClientLab.DEFAULT_DEMO_AVAILABLE);

    this.guestPanel.setVisible(demoAvailable);
}

From source file:gov.nih.nci.ncicb.tcgaportal.level4.gwt.anomalysearch.client.results.ModeController.java

protected void hookupCopyToFilterListener(final ResultsPanelCanCopyToFilter resultsPanel) {
    resultsPanel.addCopyToFilterClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            String list = resultsPanel.getResultsTable().makeListFromCheckedRows();
            if (list != null && list.length() > 0) {
                if (resultsPanel.getListBy() == FilterSpecifier.ListBy.Genes) {
                    filterPanel.addToGeneList(list);
                } else if (resultsPanel.getListBy() == FilterSpecifier.ListBy.Patients) {
                    filterPanel.addToPatientList(list);
                }//from   w w w  .j a v a  2  s .  c  o  m
                addToFilterPopup.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop() - 15);
                addToFilterPopup.show();
                Timer hideTimer = new Timer() {
                    public void run() {
                        addToFilterPopup.hide();
                    }
                };
                hideTimer.schedule(2000);
            }
        }
    });
}