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();
}
});
}
}
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());
}
});
}
use of com.google.gwt.user.client.ui.PopupPanel.PositionCallback in project rstudio by rstudio.
the class ToolbarButton method addMenuHandlers.
private void addMenuHandlers(final ToolbarPopupMenu popupMenu, final boolean rightAlign) {
menu_ = popupMenu;
/*
* We want clicks on this button to toggle the visibility of the menu,
* as well as having the menu auto-hide itself as it normally does.
* It's necessary to manually track the visibility (menuShowing) because
* in the case where the menu is showing, clicking on this button first
* causes the menu to auto-hide and then our mouseDown handler is called
* (so we can't rely on menu.isShowing(), it'll always be false by the
* time you get into the mousedown handler).
*/
final boolean[] menuShowing = new boolean[1];
addMouseDownHandler(new MouseDownHandler() {
public void onMouseDown(MouseDownEvent event) {
event.preventDefault();
event.stopPropagation();
addStyleName(styles_.toolbarButtonPushed());
// Some menus are rebuilt on every invocation. Ask the menu for
// the most up-to-date version before proceeding.
popupMenu.getDynamicPopupMenu(new ToolbarPopupMenu.DynamicPopupMenuCallback() {
@Override
public void onPopupMenu(final ToolbarPopupMenu menu) {
if (menuShowing[0]) {
removeStyleName(styles_.toolbarButtonPushed());
menu.hide();
} else {
if (rightAlign) {
menu.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
menu.setPopupPosition((rightImageWidget_ != null ? rightImageWidget_.getAbsoluteLeft() : leftImageWidget_.getAbsoluteLeft()) + 20 - offsetWidth, ToolbarButton.this.getAbsoluteTop() + ToolbarButton.this.getOffsetHeight());
}
});
} else {
menu.showRelativeTo(ToolbarButton.this);
}
menuShowing[0] = true;
}
}
});
}
});
popupMenu.addCloseHandler(new CloseHandler<PopupPanel>() {
public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) {
removeStyleName(styles_.toolbarButtonPushed());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
menuShowing[0] = false;
}
});
}
});
}
use of com.google.gwt.user.client.ui.PopupPanel.PositionCallback in project rstudio by rstudio.
the class FilesPane method showDataImportFileChoice.
@Override
public void showDataImportFileChoice(FileSystemItem file, Command onView, Command onImport) {
final ToolbarPopupMenu menu = new ToolbarPopupMenu();
String editLabel = AppCommand.formatMenuLabel(commands_.renameFile().getImageResource(), "View File", null);
String importLabel = AppCommand.formatMenuLabel(new ImageResource2x(StandardIcons.INSTANCE.import_dataset2x()), "Import Dataset...", null);
menu.addItem(new MenuItem(editLabel, true, onView));
menu.addItem(new MenuItem(importLabel, true, onImport));
menu.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
Event event = Event.getCurrentEvent();
PopupPositioner.setPopupPosition(menu, event.getClientX(), event.getClientY());
}
});
}
use of com.google.gwt.user.client.ui.PopupPanel.PositionCallback in project rstudio by rstudio.
the class FilesPane method showHtmlFileChoice.
@Override
public void showHtmlFileChoice(FileSystemItem file, Command onEdit, Command onBrowse) {
final ToolbarPopupMenu menu = new ToolbarPopupMenu();
String editLabel = AppCommand.formatMenuLabel(commands_.renameFile().getImageResource(), "Open in Editor", null);
String openLabel = AppCommand.formatMenuLabel(commands_.openHtmlExternal().getImageResource(), "View in Web Browser", null);
menu.addItem(new MenuItem(editLabel, true, onEdit));
menu.addItem(new MenuItem(openLabel, true, onBrowse));
menu.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
Event event = Event.getCurrentEvent();
PopupPositioner.setPopupPosition(menu, event.getClientX(), event.getClientY());
}
});
}
Aggregations