Search in sources :

Example 1 with PositionCallback

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

the class DiagnosticsBackgroundPopup method showPopup.

private void showPopup(String text, Range range) {
    hidePopup();
    popup_ = new DiagnosticsPopupPanel(text, range);
    final Rectangle coords = editor_.toScreenCoordinates(range);
    popup_.setTitle("Diagnostics");
    popup_.setPopupPositionAndShow(new PositionCallback() {

        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            popup_.setPopupPosition(coords.getRight() + 10, coords.getBottom());
        }
    });
}
Also used : PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Rectangle(org.rstudio.core.client.Rectangle)

Example 2 with PositionCallback

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

the class ManipulatorManager method showManipulatorPopup.

private void showManipulatorPopup() {
    // show it if necessary
    if (!manipulatorPopup_.isShowing()) {
        // state of the manipulator existing below the workbench
        if (plotsSurface_.getOffsetHeight() == 0)
            return;
        manipulatorPopup_.recordPreviouslyFocusedElement();
        manipulatorPopup_.setPopupPositionAndShow(new PositionCallback() {

            @Override
            public void setPosition(int offsetWidth, int offsetHeight) {
                // position the manipulator to the right if necessary
                int xPos = plotsSurface_.getAbsoluteLeft() - offsetWidth + 20;
                if (xPos < 0) {
                    xPos = plotsSurface_.getAbsoluteLeft() + plotsSurface_.getOffsetWidth() - 20;
                }
                manipulatorPopup_.setPopupPosition(xPos, plotsSurface_.getAbsoluteTop() - 6);
                manipulatorPopup_.focusFirstControl();
            }
        });
    }
}
Also used : PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback)

Example 3 with PositionCallback

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

the class SignatureToolTipManager method setTooltipPosition.

private void setTooltipPosition(Position position) {
    final Rectangle bounds = docDisplay_.getPositionBounds(position);
    tooltipPosition_ = position;
    toolTip_.setPopupPositionAndShow(new PositionCallback() {

        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            int left = bounds.getLeft();
            boolean verticalOverflow = bounds.getBottom() + offsetHeight >= Window.getClientHeight() - 20;
            int top = verticalOverflow ? bounds.getTop() - offsetHeight - 10 : bounds.getBottom() + 10;
            toolTip_.setPopupPosition(left, top);
        }
    });
}
Also used : PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Rectangle(org.rstudio.core.client.Rectangle)

Example 4 with PositionCallback

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

the class ChunkContextToolbar method initChangeChunkEngine.

@SuppressWarnings("unused")
private void initChangeChunkEngine(String engine) {
    chunkTypeLabel_.setText(engine);
    DOM.sinkEvents(chunkTypePanel_.getElement(), Event.ONCLICK);
    DOM.setEventListener(chunkTypePanel_.getElement(), new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (DOM.eventGetType(event) == Event.ONCLICK) {
                Commands commands = RStudioGinjector.INSTANCE.getCommands();
                String engineLabel = chunkTypeLabel_.getText();
                final ToolbarPopupMenu switchChunksMenu = new ToolbarPopupMenu();
                if (engineLabel != "r") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkR(), "r"));
                    switchChunksMenu.addSeparator();
                }
                if (!BrowseCap.isWindowsDesktop() && engineLabel != "bash") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkBash(), "bash"));
                }
                if (engineLabel != "python") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkPython(), "python"));
                }
                if (engineLabel != "rcpp") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkRCPP(), "rcpp"));
                }
                if (engineLabel != "sql") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkSQL(), "sql"));
                }
                if (engineLabel != "stan") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkStan(), "stan"));
                }
                switchChunksMenu.setPopupPositionAndShow(new PositionCallback() {

                    @Override
                    public void setPosition(int offsetWidth, int offsetHeight) {
                        switchChunksMenu.setPopupPosition(chunkTypePanel_.getAbsoluteLeft() + chunkTypePanel_.getOffsetWidth() - offsetWidth + 15, chunkTypePanel_.getAbsoluteTop() + chunkTypePanel_.getOffsetHeight());
                    }
                });
            }
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Commands(org.rstudio.studio.client.workbench.commands.Commands) Event(com.google.gwt.user.client.Event) EventListener(com.google.gwt.user.client.EventListener)

Example 5 with PositionCallback

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

the class SVNPane 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_.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)

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