Search in sources :

Example 1 with ToolbarButton

use of org.rstudio.core.client.widget.ToolbarButton in project rstudio by rstudio.

the class ConnectionsPane method installConnectionExplorerToolbar.

private void installConnectionExplorerToolbar(final Connection connection) {
    toolbar_.removeAllWidgets();
    toolbar_.addLeftWidget(backToConnectionsButton_);
    toolbar_.addLeftSeparator();
    toolbar_.addLeftWidget(connectMenuButton_);
    toolbar_.addLeftSeparator();
    if (isConnected(connection.getId()) && connection.getActions() != null) {
        // if we have any actions, create a toolbar button for each one
        for (int i = 0; i < connection.getActions().length(); i++) {
            final ConnectionAction action = connection.getActions().get(i);
            // use the supplied base64 icon data if it was provided
            Image icon = StringUtil.isNullOrEmpty(action.getIconData()) ? null : new Image(action.getIconData());
            // force to 20x18
            if (icon != null) {
                icon.setWidth("20px");
                icon.setHeight("18px");
            }
            ToolbarButton button = new ToolbarButton(action.getName(), // left image
            icon, // right image
            null, // invoke the action when the button is clicked
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    fireEvent(new ExecuteConnectionActionEvent(connection.getId(), action.getName()));
                }
            });
            // none was supplied
            if (StringUtil.isNullOrEmpty(action.getIconData()))
                button.getElement().getStyle().setMarginTop(-5, Unit.PX);
            toolbar_.addLeftWidget(button);
            toolbar_.addLeftSeparator();
        }
    }
    toolbar_.addLeftWidget(commands_.disconnectConnection().createToolbarButton());
    toolbar_.addRightWidget(commands_.removeConnection().createToolbarButton());
    toolbar_.addRightWidget(commands_.refreshConnection().createToolbarButton());
    connectionName_.setText(connection.getDisplayName());
    setSecondaryToolbarVisible(true);
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExecuteConnectionActionEvent(org.rstudio.studio.client.workbench.views.connections.events.ExecuteConnectionActionEvent) ConnectionAction(org.rstudio.studio.client.workbench.views.connections.model.ConnectionAction) Image(com.google.gwt.user.client.ui.Image)

Example 2 with ToolbarButton

use of org.rstudio.core.client.widget.ToolbarButton 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)

Example 3 with ToolbarButton

use of org.rstudio.core.client.widget.ToolbarButton in project rstudio by rstudio.

the class BuildPane method createMainToolbar.

@Override
protected Toolbar createMainToolbar() {
    Toolbar toolbar = new Toolbar();
    SessionInfo sessionInfo = session_.getSessionInfo();
    String type = sessionInfo.getBuildToolsType();
    boolean pkg = type.equals(SessionInfo.BUILD_TOOLS_PACKAGE);
    boolean makefile = type.equals(SessionInfo.BUILD_TOOLS_MAKEFILE);
    boolean website = type.equals(SessionInfo.BUILD_TOOLS_WEBSITE);
    // always include build all
    ToolbarButton buildAllButton = commands_.buildAll().createToolbarButton();
    if (website) {
        if (sessionInfo.getBuildToolsBookdownWebsite()) {
            buildAllButton.setText("Build Book");
        } else {
            buildAllButton.setText("Build Website");
        }
    }
    toolbar.addLeftWidget(buildAllButton);
    // book build menu
    if (sessionInfo.getBuildToolsBookdownWebsite()) {
        BookdownBuildPopupMenu buildPopupMenu = new BookdownBuildPopupMenu();
        ToolbarButton buildMenuButton = new ToolbarButton(buildPopupMenu, true);
        toolbar.addLeftWidget(buildMenuButton);
    }
    toolbar.addLeftSeparator();
    // packages get check package
    if (pkg) {
        toolbar.addLeftWidget(commands_.checkPackage().createToolbarButton());
        toolbar.addLeftSeparator();
    }
    // create more menu
    if (makefile || website || pkg) {
        ToolbarPopupMenu moreMenu = new ToolbarPopupMenu();
        if (makefile || website) {
            if (makefile)
                moreMenu.addItem(commands_.rebuildAll().createMenuItem(false));
            moreMenu.addItem(commands_.cleanAll().createMenuItem(false));
            moreMenu.addSeparator();
        } else // packages get additional commands 
        if (pkg) {
            moreMenu.addItem(commands_.devtoolsLoadAll().createMenuItem(false));
            moreMenu.addItem(commands_.rebuildAll().createMenuItem(false));
            moreMenu.addSeparator();
            moreMenu.addItem(commands_.testPackage().createMenuItem(false));
            moreMenu.addSeparator();
            moreMenu.addItem(commands_.checkPackage().createMenuItem(false));
            moreMenu.addSeparator();
            moreMenu.addItem(commands_.buildSourcePackage().createMenuItem(false));
            moreMenu.addItem(commands_.buildBinaryPackage().createMenuItem(false));
            moreMenu.addSeparator();
            moreMenu.addItem(commands_.roxygenizePackage().createMenuItem(false));
            moreMenu.addSeparator();
        }
        moreMenu.addItem(commands_.buildToolsProjectSetup().createMenuItem(false));
        // add more menu
        ToolbarButton moreButton = new ToolbarButton("More", new ImageResource2x(StandardIcons.INSTANCE.more_actions2x()), moreMenu);
        toolbar.addLeftWidget(moreButton);
    }
    // connect compile panel
    compilePanel_.connectToolbar(toolbar);
    return toolbar;
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) JsArrayString(com.google.gwt.core.client.JsArrayString) Toolbar(org.rstudio.core.client.widget.Toolbar)

Example 4 with ToolbarButton

use of org.rstudio.core.client.widget.ToolbarButton in project rstudio by rstudio.

the class EnvironmentPane method createImportMenu.

private Widget createImportMenu() {
    ToolbarPopupMenu menu = new ToolbarPopupMenu();
    menu.setAutoOpen(true);
    menu.addItem(commands_.importDatasetFromFile().createMenuItem(false));
    menu.addItem(commands_.importDatasetFromURL().createMenuItem(false));
    menu.addItem(commands_.importDatasetFromCsvUsingBase().createMenuItem(false));
    menu.addItem(commands_.importDatasetFromCsvUsingReadr().createMenuItem(false));
    menu.addSeparator();
    menu.addItem(commands_.importDatasetFromXLS().createMenuItem(false));
    menu.addSeparator();
    menu.addItem(commands_.importDatasetFromSAV().createMenuItem(false));
    menu.addItem(commands_.importDatasetFromSAS().createMenuItem(false));
    menu.addItem(commands_.importDatasetFromStata().createMenuItem(false));
    menu.addSeparator();
    menu.addItem(commands_.importDatasetFromXML().createMenuItem(false));
    menu.addItem(commands_.importDatasetFromJSON().createMenuItem(false));
    menu.addSeparator();
    menu.addItem(commands_.importDatasetFromJDBC().createMenuItem(false));
    menu.addItem(commands_.importDatasetFromODBC().createMenuItem(false));
    menu.addSeparator();
    menu.addItem(commands_.importDatasetFromMongo().createMenuItem(false));
    dataImportButton_ = new ToolbarButton("Import Dataset", new ImageResource2x(StandardIcons.INSTANCE.import_dataset2x()), menu);
    return dataImportButton_;
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 5 with ToolbarButton

use of org.rstudio.core.client.widget.ToolbarButton in project rstudio by rstudio.

the class EnvironmentPane method createSecondaryToolbar.

@Override
protected SecondaryToolbar createSecondaryToolbar() {
    SecondaryToolbar toolbar = new SecondaryToolbar();
    environmentMenu_ = new EnvironmentPopupMenu();
    environmentButton_ = new ToolbarButton(friendlyEnvironmentName(), imageOfEnvironment(environmentName_, environmentIsLocal_), environmentMenu_);
    toolbar.addLeftWidget(environmentButton_);
    SearchWidget searchWidget = new SearchWidget(new SuggestOracle() {

        @Override
        public void requestSuggestions(Request request, Callback callback) {
            // no suggestions
            callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>()));
        }
    });
    searchWidget.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            objects_.setFilterText(event.getValue());
        }
    });
    searchWidget.getElement().getStyle().setMarginTop(1, Unit.PX);
    toolbar.addRightWidget(searchWidget);
    return toolbar;
}
Also used : SearchWidget(org.rstudio.core.client.widget.SearchWidget) JsArrayString(com.google.gwt.core.client.JsArrayString) ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) SuggestOracle(com.google.gwt.user.client.ui.SuggestOracle) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar)

Aggregations

ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)24 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)13 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)11 Toolbar (org.rstudio.core.client.widget.Toolbar)10 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)8 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 RSConnectPublishButton (org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton)5 SecondaryToolbar (org.rstudio.core.client.widget.SecondaryToolbar)4 ImageResource (com.google.gwt.resources.client.ImageResource)3 SuggestOracle (com.google.gwt.user.client.ui.SuggestOracle)3 SearchWidget (org.rstudio.core.client.widget.SearchWidget)3 ToolbarLabel (org.rstudio.core.client.widget.ToolbarLabel)3 JsArrayString (com.google.gwt.core.client.JsArrayString)2 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)2 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)2 ArrayList (java.util.ArrayList)2 WindowEx (org.rstudio.core.client.dom.WindowEx)2 CanFocus (org.rstudio.core.client.widget.CanFocus)2 FindTextBox (org.rstudio.core.client.widget.FindTextBox)2 SlideNavigationToolbarMenu (org.rstudio.studio.client.common.presentation.SlideNavigationToolbarMenu)2