Search in sources :

Example 6 with ToolbarPopupMenu

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());
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 7 with ToolbarPopupMenu

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);
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)

Example 8 with ToolbarPopupMenu

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;
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Toolbar(org.rstudio.core.client.widget.Toolbar)

Example 9 with ToolbarPopupMenu

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);
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback)

Example 10 with ToolbarPopupMenu

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_;
}
Also used : SearchWidget(org.rstudio.core.client.widget.SearchWidget) ArrayList(java.util.ArrayList) VisibleChangedHandler(org.rstudio.core.client.command.VisibleChangedHandler) ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) AppCommand(org.rstudio.core.client.command.AppCommand) AnimationCallback(com.google.gwt.layout.client.Layout.AnimationCallback) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) SuggestOracle(com.google.gwt.user.client.ui.SuggestOracle) Toolbar(org.rstudio.core.client.widget.Toolbar) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar)

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