Search in sources :

Example 11 with PositionCallback

use of com.google.gwt.user.client.ui.PopupPanel.PositionCallback in project rstudio by rstudio.

the class SVNReviewPanel method showContextMenu.

@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();
    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);
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback)

Example 12 with PositionCallback

use of com.google.gwt.user.client.ui.PopupPanel.PositionCallback in project rstudio by rstudio.

the class GitPane method showContextMenu.

@Override
public void showContextMenu(final int clientX, final int clientY) {
    final ToolbarPopupMenu menu = new ToolbarPopupMenu();
    menu.addItem(commands_.vcsDiff().createMenuItem(false));
    menu.addSeparator();
    menu.addItem(commands_.vcsRevert().createMenuItem(false));
    menu.addItem(commands_.vcsIgnore().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);
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback)

Example 13 with PositionCallback

use of com.google.gwt.user.client.ui.PopupPanel.PositionCallback in project rstudio by rstudio.

the class GitReviewPanel method showContextMenu.

@Override
public void showContextMenu(final int clientX, final int clientY, Command openSelectedCommand) {
    final ToolbarPopupMenu menu = new ToolbarPopupMenu();
    MenuItem stageMenu = new MenuItem(AppCommand.formatMenuLabel(new ImageResource2x(RES.stage2x()), "Stage", ""), true, new Command() {

        @Override
        public void execute() {
            stageFilesButton_.click();
        }
    });
    if (stageFilesButton_.isEnabled()) {
        menu.addItem(stageMenu);
        menu.addSeparator();
    }
    MenuItem revertMenu = new MenuItem(AppCommand.formatMenuLabel(new ImageResource2x(RES.discard2x()), "Revert...", ""), true, new Command() {

        @Override
        public void execute() {
            revertFilesButton_.click();
        }
    });
    if (revertFilesButton_.isEnabled())
        menu.addItem(revertMenu);
    MenuItem ignoreMenu = new MenuItem(AppCommand.formatMenuLabel(new ImageResource2x(RES.ignore2x()), "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);
        }
    });
}
Also used : PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) AppCommand(org.rstudio.core.client.command.AppCommand) Command(com.google.gwt.user.client.Command) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 14 with PositionCallback

use of com.google.gwt.user.client.ui.PopupPanel.PositionCallback in project gerrit by GerritCodeReview.

the class ShowHelpCommand method onKeyPress.

@Override
public void onKeyPress(final KeyPressEvent event) {
    if (current != null) {
        // Already open? Close the dialog.
        //
        current.hide();
        return;
    }
    final KeyHelpPopup help = new KeyHelpPopup();
    help.addCloseHandler(new CloseHandler<PopupPanel>() {

        @Override
        public void onClose(final CloseEvent<PopupPanel> event) {
            current = null;
            BUS.fireEvent(new FocusEvent() {
            });
        }
    });
    current = help;
    help.setPopupPositionAndShow(new PositionCallback() {

        @Override
        public void setPosition(final int pWidth, final int pHeight) {
            final int left = (Window.getClientWidth() - pWidth) >> 1;
            final int wLeft = Window.getScrollLeft();
            final int wTop = Window.getScrollTop();
            help.setPopupPosition(wLeft + left, wTop + 50);
        }
    });
}
Also used : PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) PopupPanel(com.google.gwt.user.client.ui.PopupPanel) FocusEvent(com.google.gwt.event.dom.client.FocusEvent)

Aggregations

PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)14 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)6 PopupPanel (com.google.gwt.user.client.ui.PopupPanel)4 Event (com.google.gwt.user.client.Event)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 MenuItem (com.google.gwt.user.client.ui.MenuItem)2 Rectangle (org.rstudio.core.client.Rectangle)2 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)2 FocusEvent (com.google.gwt.event.dom.client.FocusEvent)1 Command (com.google.gwt.user.client.Command)1 EventListener (com.google.gwt.user.client.EventListener)1 AppCommand (org.rstudio.core.client.command.AppCommand)1 Commands (org.rstudio.studio.client.workbench.commands.Commands)1