Example usage for com.google.gwt.user.client.ui PositionCallback PositionCallback

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

Introduction

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

Prototype

PositionCallback

Source Link

Usage

From source file:org.openremote.app.client.widget.PopupPanel.java

License:Apache License

/**
 * Normally, the popup is positioned directly below the relative target, with
 * its left edge aligned with the left edge of the target. Depending on the
 * width and height of the popup and the distance from the target to the
 * bottom and right edges of the window, the popup may be displayed directly
 * above the target, and/or its right edge may be aligned with the right edge
 * of the target.//w  w  w.j a v  a  2 s.co m
 *
 * @param target the target to show the popup below
 */
public final void showRelativeTo(final UIObject target) {
    // Set the position of the popup right before it is shown.
    setPopupPositionAndShow(new PositionCallback() {
        public void setPosition(int offsetWidth, int offsetHeight) {
            position(target, offsetWidth, offsetHeight);
        }
    });
}

From source file:org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupMenu.java

License:Open Source License

public void showRelativeToUpward(final UIObject target) {
    setPopupPositionAndShow(new PositionCallback() {
        public void setPosition(int offsetWidth, int offsetHeight) {
            setPopupPosition(target.getAbsoluteLeft(), target.getAbsoluteTop() - offsetHeight);
        }//from  w w w  . j  a  v a 2s . c o  m
    });
}

From source file:org.rstudio.studio.client.workbench.views.vcs.git.dialog.GitReviewPanel.java

License:Open Source License

@Override
public void showContextMenu(final int clientX, final int clientY, Command openSelectedCommand) {
    final ToolbarPopupMenu menu = new ToolbarPopupMenu();

    MenuItem stageMenu = new MenuItem(AppCommand.formatMenuLabel(RES.stage(), "Stage", ""), true,
            new Command() {
                @Override/*from  www  .j a v a 2s.  c  om*/
                public void execute() {
                    stageFilesButton_.click();
                }

            });
    if (stageFilesButton_.isEnabled()) {
        menu.addItem(stageMenu);
        menu.addSeparator();
    }

    MenuItem revertMenu = new MenuItem(AppCommand.formatMenuLabel(RES.discard(), "Revert...", ""), true,
            new Command() {
                @Override
                public void execute() {
                    revertFilesButton_.click();
                }

            });
    if (revertFilesButton_.isEnabled())
        menu.addItem(revertMenu);

    MenuItem ignoreMenu = new MenuItem(AppCommand.formatMenuLabel(RES.ignore(), "Ignore...", ""), true,
            new Command() {
                @Override
                public void execute() {
                    ignoreButton_.click();
                }

            });
    if (ignoreButton_.isEnabled())
        menu.addItem(ignoreMenu);

    menu.addSeparator();
    MenuItem openMenu = new MenuItem(AppCommand.formatMenuLabel(null, "Open File", ""), true,
            openSelectedCommand);
    menu.addItem(openMenu);

    menu.setPopupPositionAndShow(new PositionCallback() {
        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            menu.setPopupPosition(clientX, clientY);
        }
    });

}

From source file:org.rstudio.studio.client.workbench.views.vcs.svn.dialog.SVNReviewPanel.java

License:Open Source License

@Override
public void showContextMenu(final int clientX, final int clientY) {
    final ToolbarPopupMenu menu = new ToolbarPopupMenu();

    menu.addItem(commands_.vcsAddFiles().createMenuItem(false));
    menu.addItem(commands_.vcsRemoveFiles().createMenuItem(false));
    menu.addSeparator();/*from w w w .jav a  2s.  c om*/
    menu.addItem(commands_.vcsRevert().createMenuItem(false));
    menu.addItem(commands_.vcsIgnore().createMenuItem(false));
    menu.addSeparator();
    menu.addItem(commands_.vcsResolve().createMenuItem(false));
    menu.addSeparator();
    menu.addItem(commands_.vcsOpen().createMenuItem(false));

    menu.setPopupPositionAndShow(new PositionCallback() {
        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            menu.setPopupPosition(clientX, clientY);
        }
    });
}