use of org.rstudio.core.client.widget.ToolbarPopupMenu in project rstudio by rstudio.
the class ShinyViewerTypePopupMenu method getDynamicPopupMenu.
@Override
public void getDynamicPopupMenu(final ToolbarPopupMenu.DynamicPopupMenuCallback callback) {
final ToolbarPopupMenu menu = this;
server_.getShinyViewerType(new ServerRequestCallback<ShinyViewerType>() {
@Override
public void onResponseReceived(ShinyViewerType response) {
int viewerType = response.getViewerType();
commands_.shinyRunInPane().setChecked(false);
commands_.shinyRunInViewer().setChecked(false);
commands_.shinyRunInBrowser().setChecked(false);
if (ShinyViewerType.SHINY_VIEWER_PANE == viewerType)
commands_.shinyRunInPane().setChecked(true);
if (ShinyViewerType.SHINY_VIEWER_WINDOW == viewerType)
commands_.shinyRunInViewer().setChecked(true);
if (ShinyViewerType.SHINY_VIEWER_BROWSER == viewerType)
commands_.shinyRunInBrowser().setChecked(true);
callback.onPopupMenu(menu);
}
@Override
public void onError(ServerError error) {
callback.onPopupMenu(menu);
}
});
}
use of org.rstudio.core.client.widget.ToolbarPopupMenu 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());
}
});
}
}
});
}
use of org.rstudio.core.client.widget.ToolbarPopupMenu in project rstudio by rstudio.
the class BranchToolbarButton method onVcsRefresh.
@Override
public void onVcsRefresh(VcsRefreshEvent event) {
ToolbarPopupMenu rootMenu = getMenu();
rootMenu.setAutoHideRedundantSeparators(false);
rootMenu.clearItems();
JsArrayString branches = pVcsState_.get().getBranchInfo().getBranches();
// separate branches based on remote name
Map<String, List<String>> branchMap = new LinkedHashMap<String, List<String>>();
List<String> localBranches = new ArrayList<String>();
branchMap.put(LOCAL_BRANCHES, localBranches);
for (String branch : JsUtil.asIterable(branches)) {
if (branch.startsWith("remotes/")) {
JsArrayString parts = StringUtil.split(branch, "/");
if (parts.length() > 2) {
String remote = parts.get(1);
if (!branchMap.containsKey(remote))
branchMap.put(remote, new ArrayList<String>());
List<String> remoteBranches = branchMap.get(remote);
remoteBranches.add(branch);
}
} else {
localBranches.add(branch);
}
}
onBeforePopulateMenu(rootMenu);
populateMenu(rootMenu, branchMap);
}
use of org.rstudio.core.client.widget.ToolbarPopupMenu in project rstudio by rstudio.
the class PresentationPane method createMainToolbar.
@Override
protected Toolbar createMainToolbar() {
boolean isTutorial = session_.getSessionInfo().getPresentationState().isTutorial();
Toolbar toolbar = new Toolbar();
slideNavigationMenu_ = new SlideNavigationToolbarMenu(toolbar);
slideNavigationMenu_.setEditButtonVisible(!isTutorial);
toolbar.addLeftSeparator();
toolbar.addLeftWidget(commands_.presentationFullscreen().createToolbarButton());
// More
if (!isTutorial) {
ToolbarPopupMenu moreMenu = new ToolbarPopupMenu();
moreMenu.addItem(commands_.clearPresentationCache().createMenuItem(false));
moreMenu.addSeparator();
moreMenu.addItem(commands_.presentationViewInBrowser().createMenuItem(false));
moreMenu.addItem(commands_.presentationSaveAsStandalone().createMenuItem(false));
ToolbarButton moreButton = new ToolbarButton("More", new ImageResource2x(StandardIcons.INSTANCE.more_actions2x()), moreMenu);
toolbar.addRightWidget(moreButton);
// Create the publish button and wire it to our HTML generator
publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_PRES, false, null);
publishButton_.setPublishHtmlSource(new PublishHtmlSource() {
@Override
public void generatePublishHtml(final CommandWithArg<String> onCompleted) {
server_.createPresentationRPubsSource(new SimpleRequestCallback<PresentationRPubsSource>() {
@Override
public void onResponseReceived(PresentationRPubsSource source) {
onCompleted.execute(source.getSourceFilePath());
}
@Override
public void onError(ServerError error) {
display_.showErrorMessage("Error Saving Presentation", Presentation.getErrorMessage(error));
}
});
}
@Override
public String getTitle() {
return "Presentation:\n" + getPresentationTitle();
}
});
toolbar.addRightSeparator();
toolbar.addRightWidget(publishButton_);
} else {
toolbar.addRightWidget(commands_.tutorialFeedback().createToolbarButton());
}
toolbar.addRightSeparator();
toolbar.addRightWidget(refreshButton_ = commands_.refreshPresentation().createToolbarButton());
progressButton_ = new ToolbarButton(CoreResources.INSTANCE.progress_gray(), new ClickHandler() {
@Override
public void onClick(ClickEvent e) {
}
});
toolbar.addRightWidget(progressButton_);
progressButton_.setVisible(false);
return toolbar;
}
use of org.rstudio.core.client.widget.ToolbarPopupMenu in project rstudio by rstudio.
the class MarkerSetsToolbarButton method updateAvailableMarkerSets.
public void updateAvailableMarkerSets(String[] sets) {
ToolbarPopupMenu menu = getMenu();
menu.clearItems();
for (final String set : sets) {
// command for selection
Scheduler.ScheduledCommand cmd = new Scheduler.ScheduledCommand() {
@Override
public void execute() {
ValueChangeEvent.fire(MarkerSetsToolbarButton.this, set);
}
};
SafeHtml menuHTML = new SafeHtmlBuilder().appendHtmlConstant(set).toSafeHtml();
menu.addItem(new MenuItem(menuHTML, cmd));
}
}
Aggregations