Search in sources :

Example 1 with ToolbarPopupMenu

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);
        }
    });
}
Also used : ShinyViewerType(org.rstudio.studio.client.shiny.model.ShinyViewerType) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ServerError(org.rstudio.studio.client.server.ServerError)

Example 2 with ToolbarPopupMenu

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());
                    }
                });
            }
        }
    });
}
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 3 with ToolbarPopupMenu

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);
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ScrollableToolbarPopupMenu(org.rstudio.core.client.widget.ScrollableToolbarPopupMenu) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with ToolbarPopupMenu

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;
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback) ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RSConnectPublishButton(org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton) PublishHtmlSource(org.rstudio.studio.client.rsconnect.model.PublishHtmlSource) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) SlideNavigationToolbarMenu(org.rstudio.studio.client.common.presentation.SlideNavigationToolbarMenu) PresentationRPubsSource(org.rstudio.studio.client.workbench.views.presentation.model.PresentationRPubsSource) Toolbar(org.rstudio.core.client.widget.Toolbar)

Example 5 with ToolbarPopupMenu

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));
    }
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ScrollableToolbarPopupMenu(org.rstudio.core.client.widget.ScrollableToolbarPopupMenu) Scheduler(com.google.gwt.core.client.Scheduler) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) MenuItem(com.google.gwt.user.client.ui.MenuItem) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Aggregations

ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)23 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)13 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)10 Toolbar (org.rstudio.core.client.widget.Toolbar)10 PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)6 ServerError (org.rstudio.studio.client.server.ServerError)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 Event (com.google.gwt.user.client.Event)3 MenuItem (com.google.gwt.user.client.ui.MenuItem)3 ArrayList (java.util.ArrayList)3 SecondaryToolbar (org.rstudio.core.client.widget.SecondaryToolbar)3 RSConnectPublishButton (org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton)3 JsArrayString (com.google.gwt.core.client.JsArrayString)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ImageResource (com.google.gwt.resources.client.ImageResource)2 SuggestOracle (com.google.gwt.user.client.ui.SuggestOracle)2 ScrollableToolbarPopupMenu (org.rstudio.core.client.widget.ScrollableToolbarPopupMenu)2 SearchWidget (org.rstudio.core.client.widget.SearchWidget)2 PublishHtmlSource (org.rstudio.studio.client.rsconnect.model.PublishHtmlSource)2 JsArray (com.google.gwt.core.client.JsArray)1