use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.
the class PlotPublishMRUList method addPlotMruEntries.
public void addPlotMruEntries(ToolbarPopupMenu menu, final OperationWithInput<Entry> onSelected) {
for (String entry : plotMruList_) {
final Entry mruEntry = Entry.fromText(entry);
if (entry == null)
continue;
// format the display name: pick title if specified, name if not
String displayName = StringUtil.isNullOrEmpty(mruEntry.title) ? mruEntry.name : mruEntry.title;
displayName += " (" + mruEntry.server + ")";
menu.addItem(new MenuItem(AppCommand.formatMenuLabel(RSConnectResources.INSTANCE.republishPlot2x(), displayName, null), true, new Command() {
@Override
public void execute() {
onSelected.execute(mruEntry);
}
}));
}
}
use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.
the class RSConnectPublishButton method setPreviousDeployments.
private void setPreviousDeployments(JsArray<RSConnectDeploymentRecord> recs) {
// clear existing deployment menu, if any
publishMenu_.clearItems();
defaultRec_ = null;
// republish
if (recs != null && recs.length() > 0) {
applyCaption("Republish");
// pass
for (int i = 0; i < recs.length(); i++) {
final RSConnectDeploymentRecord rec = recs.get(i);
if (rec == null)
continue;
if (defaultRec_ == null || defaultRec_.getWhen() < rec.getWhen()) {
defaultRec_ = rec;
}
}
// build the deployment menu
for (int i = 0; i < recs.length(); i++) {
final RSConnectDeploymentRecord rec = recs.get(i);
final DeploymentMenuItem menuItem = new DeploymentMenuItem(rec, rec == defaultRec_, new Command() {
@Override
public void execute() {
onPublishRecordClick(rec);
}
});
publishMenu_.addItem(menuItem);
}
publishMenu_.addSeparator();
publishMenu_.addItem(new MenuItem(AppCommand.formatMenuLabel(commands_.rsconnectDeploy().getImageResource(), "Other Destination...", null), true, new Scheduler.ScheduledCommand() {
@Override
public void execute() {
onPublishRecordClick(null);
}
}));
} else {
// show first-time publish button caption
applyCaption("Publish");
// no existing deployments to redeploy to, so just offer to make a new
// one
publishMenu_.addItem(new MenuItem(AppCommand.formatMenuLabel(commands_.rsconnectDeploy().getImageResource(), "Publish " + RSConnect.contentTypeDesc(contentType_) + "...", null), true, new Scheduler.ScheduledCommand() {
@Override
public void execute() {
onPublishRecordClick(defaultRec_);
}
}));
}
// if it's a plot, show an MRU of recently deployed plot "names"
if (contentType_ == RSConnect.CONTENT_TYPE_PLOT) {
plotMru_.addPlotMruEntries(publishMenu_, new OperationWithInput<PlotPublishMRUList.Entry>() {
@Override
public void execute(Entry plot) {
republishPlot(plot);
}
});
}
publishMenu_.addSeparator();
publishMenu_.addItem(commands_.rsconnectManageAccounts().createMenuItem(false));
}
use of com.google.gwt.user.client.ui.MenuItem 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.MenuItem 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());
}
});
}
use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.
the class TextEditingTarget method showStatusBarPopupMenu.
private void showStatusBarPopupMenu(StatusBarPopupRequest popupRequest) {
final StatusBarPopupMenu menu = popupRequest.getMenu();
MenuItem defaultItem = popupRequest.getDefaultMenuItem();
if (defaultItem != null) {
menu.selectItem(defaultItem);
Scheduler.get().scheduleFinally(new RepeatingCommand() {
public boolean execute() {
menu.ensureSelectedIsVisible();
return false;
}
});
}
menu.showRelativeToUpward((UIObject) statusBar_.getScope(), false);
}
Aggregations