use of org.rstudio.core.client.widget.ToolbarPopupMenu in project rstudio by rstudio.
the class PlotsToolbar method installStandardUI.
private void installStandardUI() {
// plot history navigation
addLeftWidget(commands_.previousPlot().createToolbarButton());
addLeftWidget(commands_.nextPlot().createToolbarButton());
addLeftSeparator();
// popout current plot
addLeftWidget(commands_.zoomPlot().createToolbarButton());
addLeftSeparator();
// export commands
ToolbarPopupMenu exportMenu = new ToolbarPopupMenu();
exportMenu.addItem(commands_.savePlotAsImage().createMenuItem(false));
exportMenu.addItem(commands_.savePlotAsPdf().createMenuItem(false));
exportMenu.addSeparator();
exportMenu.addItem(commands_.copyPlotToClipboard().createMenuItem(false));
ToolbarButton exportButton = new ToolbarButton("Export", new ImageResource2x(StandardIcons.INSTANCE.export_menu2x()), exportMenu);
addLeftWidget(exportButton);
addLeftSeparator();
addLeftWidget(commands_.removePlot().createToolbarButton());
addLeftSeparator();
// clear all plots
addLeftWidget(commands_.clearPlots().createToolbarButton());
// publish
addRightWidget(publishButton_);
// refresh
addRightSeparator();
addRightWidget(commands_.refreshPlot().createToolbarButton());
}
use of org.rstudio.core.client.widget.ToolbarPopupMenu in project rstudio by rstudio.
the class RSConnectPublishButton method rebuildPopupMenu.
// rebuilds the popup menu--this can happen when the menu is invoked; it can
// also happen when the button is created if we're aggressively checking
// publish status
private void rebuildPopupMenu(final ToolbarPopupMenu.DynamicPopupMenuCallback callback) {
final ToolbarPopupMenu menu = publishMenu_;
// prevent reentrancy
if (populating_) {
if (callback != null)
callback.onPopupMenu(menu);
return;
}
// handle case where we don't have a content path (i.e. plots)
if (contentPath_ == null) {
setPreviousDeployments(null);
if (callback != null)
callback.onPopupMenu(menu);
return;
}
// (unless we're forcefully repopulating)
if (populatedPath_ != null && populatedPath_.equals(contentPath_)) {
if (callback != null)
callback.onPopupMenu(menu);
return;
}
String contentPath = contentPath_;
boolean parent = false;
// CONTENT_TYPE_APP_SINGLE and their own deployment records)
if (contentType_ == RSConnect.CONTENT_TYPE_APP && StringUtil.getExtension(contentPath_).equalsIgnoreCase("r"))
parent = true;
// if this is a document in a website, use the parent path
if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE)
parent = true;
// apply parent path if needed
if (parent) {
FileSystemItem fsiContent = FileSystemItem.createFile(contentPath_);
contentPath = fsiContent.getParentPathString();
}
populating_ = true;
server_.getRSConnectDeployments(contentPath, outputPath_ == null ? "" : outputPath_, new ServerRequestCallback<JsArray<RSConnectDeploymentRecord>>() {
@Override
public void onResponseReceived(JsArray<RSConnectDeploymentRecord> recs) {
populatedPath_ = contentPath_;
populating_ = false;
// that are static (as we can't update them)
if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE && (docPreview_ == null || StringUtil.isNullOrEmpty(docPreview_.getOutputFile()))) {
JsArray<RSConnectDeploymentRecord> codeRecs = JsArray.createArray().cast();
for (int i = 0; i < recs.length(); i++) {
if (!recs.get(i).getAsStatic())
codeRecs.push(recs.get(i));
}
recs = codeRecs;
}
setPreviousDeployments(recs);
if (callback != null)
callback.onPopupMenu(menu);
}
@Override
public void onError(ServerError error) {
populating_ = false;
if (callback != null)
callback.onPopupMenu(menu);
}
});
}
use of org.rstudio.core.client.widget.ToolbarPopupMenu in project rstudio by rstudio.
the class SVNPane method createMainToolbar.
@Override
protected Toolbar createMainToolbar() {
Toolbar toolbar = new Toolbar();
toolbar.addLeftWidget(commands_.vcsDiff().createToolbarButton());
toolbar.addLeftSeparator();
toolbar.addLeftWidget(commands_.vcsAddFiles().createToolbarButton());
toolbar.addLeftWidget(commands_.vcsRemoveFiles().createToolbarButton());
toolbar.addLeftSeparator();
toolbar.addLeftWidget(commands_.vcsCommit().createToolbarButton());
toolbar.addLeftSeparator();
ToolbarPopupMenu moreMenu = new ToolbarPopupMenu();
moreMenu.addItem(commands_.vcsRevert().createMenuItem(false));
moreMenu.addItem(commands_.vcsIgnore().createMenuItem(false));
moreMenu.addSeparator();
moreMenu.addItem(commands_.vcsResolve().createMenuItem(false));
moreMenu.addSeparator();
moreMenu.addItem(commands_.vcsPull().createMenuItem(false));
moreMenu.addItem(commands_.vcsCleanup().createMenuItem(false));
moreMenu.addSeparator();
moreMenu.addItem(commands_.vcsShowHistory().createMenuItem(false));
moreMenu.addSeparator();
moreMenu.addItem(commands_.showShellDialog().createMenuItem(false));
toolbar.addLeftWidget(new ToolbarButton("More", new ImageResource2x(StandardIcons.INSTANCE.more_actions2x()), moreMenu));
toolbar.addLeftSeparator();
toolbar.addRightWidget(commands_.vcsRefresh().createToolbarButton());
return toolbar;
}
use of org.rstudio.core.client.widget.ToolbarPopupMenu 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);
}
});
}
use of org.rstudio.core.client.widget.ToolbarPopupMenu in project rstudio by rstudio.
the class ConnectionsPane method createMainToolbar.
@Override
protected Toolbar createMainToolbar() {
toolbar_ = new Toolbar();
searchWidget_ = new SearchWidget(new SuggestOracle() {
@Override
public void requestSuggestions(Request request, Callback callback) {
// no suggestions
callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>()));
}
});
backToConnectionsButton_ = new ToolbarButton(commands_.helpBack().getImageResource(), (ClickHandler) null);
backToConnectionsButton_.setTitle("View all connections");
// connect meuu
ToolbarPopupMenu connectMenu = new ToolbarPopupMenu();
connectMenu.addItem(connectMenuItem(commands_.historySendToConsole().getImageResource(), "R Console", ConnectionOptions.CONNECT_R_CONSOLE));
connectMenu.addSeparator();
connectMenu.addItem(connectMenuItem(commands_.newSourceDoc().getImageResource(), "New R Script", ConnectionOptions.CONNECT_NEW_R_SCRIPT));
connectMenu.addItem(connectMenuItem(commands_.newRNotebook().getImageResource(), "New R Notebook", ConnectionOptions.CONNECT_NEW_R_NOTEBOOK));
if (BrowseCap.INSTANCE.canCopyToClipboard()) {
connectMenu.addSeparator();
connectMenu.addItem(connectMenuItem(commands_.copyPlotToClipboard().getImageResource(), "Copy to Clipboard", ConnectionOptions.CONNECT_COPY_TO_CLIPBOARD));
}
connectMenuButton_ = new ToolbarButton("Connect", commands_.newConnection().getImageResource(), connectMenu);
// manage connect menu visibility
connectMenuButton_.setVisible(!commands_.disconnectConnection().isVisible());
commands_.disconnectConnection().addVisibleChangedHandler(new VisibleChangedHandler() {
@Override
public void onVisibleChanged(AppCommand command) {
connectMenuButton_.setVisible(!commands_.disconnectConnection().isVisible());
}
});
installConnectionsToolbar();
return toolbar_;
}
Aggregations