Search in sources :

Example 1 with AppCommand

use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.

the class RSConnectPublishButton method initialize.

@Inject
public void initialize(RSConnectServerOperations server, RMarkdownServerOperations rmdServer, EventBus events, Commands commands, GlobalDisplay display, Provider<UIPrefs> pUiPrefs, Session session, PlotPublishMRUList plotMru) {
    server_ = server;
    rmdServer_ = rmdServer;
    events_ = events;
    commands_ = commands;
    display_ = display;
    session_ = session;
    pUiPrefs_ = pUiPrefs;
    plotMru_ = plotMru;
    // initialize visibility if requested
    if (boundCommand_ != null) {
        boundCommand_.addVisibleChangedHandler(new VisibleChangedHandler() {

            @Override
            public void onVisibleChanged(AppCommand command) {
                applyVisiblity();
            }
        });
        boundCommand_.addEnabledChangedHandler(new EnabledChangedHandler() {

            @Override
            public void onEnabledChanged(AppCommand command) {
                applyVisiblity();
            }
        });
    }
    events_.addHandler(RSConnectDeploymentCompletedEvent.TYPE, this);
    events_.addHandler(RPubsUploadStatusEvent.TYPE, this);
    events_.addHandler(RmdRenderCompletedEvent.TYPE, this);
    events_.addHandler(HTMLPreviewCompletedEvent.TYPE, this);
}
Also used : AppCommand(org.rstudio.core.client.command.AppCommand) VisibleChangedHandler(org.rstudio.core.client.command.VisibleChangedHandler) EnabledChangedHandler(org.rstudio.core.client.command.EnabledChangedHandler) Inject(com.google.inject.Inject)

Example 2 with AppCommand

use of org.rstudio.core.client.command.AppCommand 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 AppCommand

use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.

the class PaneManager method manageLayoutCommands.

private void manageLayoutCommands() {
    List<AppCommand> layoutCommands = getLayoutCommands();
    AppCommand activeCommand = getLayoutCommandForTab(maximizedTab_);
    for (AppCommand command : layoutCommands) command.setChecked(activeCommand.equals(command));
    // manage console left/right commands
    boolean maximized = maximizedTab_ != null;
    commands_.layoutConsoleOnLeft().setVisible(!maximized);
    commands_.layoutConsoleOnRight().setVisible(!maximized);
    if (!maximized) {
        PaneConfig config = getCurrentConfig();
        commands_.layoutConsoleOnLeft().setChecked(config.getConsoleLeft());
        commands_.layoutConsoleOnRight().setChecked(config.getConsoleRight());
    } else {
        commands_.layoutConsoleOnLeft().setVisible(false);
        commands_.layoutConsoleOnRight().setVisible(false);
    }
}
Also used : AppCommand(org.rstudio.core.client.command.AppCommand)

Example 4 with AppCommand

use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.

the class SatelliteApplication method initialize.

public void initialize(String name, SatelliteApplicationView view, Satellite satellite, Provider<AceThemes> pAceThemes, ApplicationUncaughtExceptionHandler uncaughtExHandler, Commands commands) {
    name_ = name;
    view_ = view;
    satellite_ = satellite;
    pAceThemes_ = pAceThemes;
    uncaughtExHandler_ = uncaughtExHandler;
    commands.showRequestLog().addHandler(new CommandHandler() {

        public void onCommand(AppCommand command) {
            GWT.runAsync(new RunAsyncCallback() {

                public void onFailure(Throwable reason) {
                    Window.alert(reason.toString());
                }

                public void onSuccess() {
                    final RequestLogVisualization viz = new RequestLogVisualization();
                    final RootLayoutPanel root = RootLayoutPanel.get();
                    root.add(viz);
                    root.setWidgetTopBottom(viz, 10, Unit.PX, 10, Unit.PX);
                    root.setWidgetLeftRight(viz, 10, Unit.PX, 10, Unit.PX);
                    viz.addCloseHandler(new CloseHandler<RequestLogVisualization>() {

                        public void onClose(CloseEvent<RequestLogVisualization> event) {
                            root.remove(viz);
                        }
                    });
                }
            });
        }
    });
}
Also used : AppCommand(org.rstudio.core.client.command.AppCommand) RequestLogVisualization(org.rstudio.studio.client.application.ui.RequestLogVisualization) RunAsyncCallback(com.google.gwt.core.client.RunAsyncCallback) CommandHandler(org.rstudio.core.client.command.CommandHandler) RootLayoutPanel(com.google.gwt.user.client.ui.RootLayoutPanel)

Example 5 with AppCommand

use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.

the class ProjectPopupMenu method rebuildMenu.

private void rebuildMenu(final JsArray<SharedProjectDetails> sharedProjects, DynamicPopupMenuCallback callback) {
    // clean out existing entries
    clearItems();
    boolean hasSharedProjects = sharedProjects != null && sharedProjects.length() > 0;
    int maxMruEntries = MAX_MRU_ENTRIES;
    // shared projects are always shown, and count against the MRU limit
    if (hasSharedProjects)
        maxMruEntries -= Math.min(sharedProjects.length(), MAX_SHARED_PROJECTS);
    addItem(commands_.newProject().createMenuItem(false));
    // ensure the menu doesn't get too narrow
    addSeparator(225);
    addItem(commands_.openProject().createMenuItem(false));
    if (Desktop.isDesktop())
        addItem(commands_.openProjectInNewWindow().createMenuItem(false));
    addItem(commands_.closeProject().createMenuItem(false));
    addSeparator();
    addItem(commands_.shareProject().createMenuItem(false));
    if (hasSharedProjects)
        addSeparator("Recent Projects");
    else
        addSeparator();
    // add as many MRU items as is appropriate for our screen size and number
    // of shared projects
    AppCommand[] mruCommands = new AppCommand[] { commands_.projectMru0(), commands_.projectMru1(), commands_.projectMru2(), commands_.projectMru3(), commands_.projectMru4(), commands_.projectMru5(), commands_.projectMru6(), commands_.projectMru7(), commands_.projectMru8(), commands_.projectMru9(), commands_.projectMru10(), commands_.projectMru11(), commands_.projectMru12(), commands_.projectMru13(), commands_.projectMru14() };
    for (int i = 0; i < Math.min(maxMruEntries, mruCommands.length); i++) {
        addItem(mruCommands[i].createMenuItem(false));
    }
    // show shared projects if enabled
    if (hasSharedProjects) {
        addSeparator("Shared with Me");
        for (int i = 0; i < Math.min(sharedProjects.length(), MAX_SHARED_PROJECTS); i++) {
            final SharedProjectDetails details = sharedProjects.get(i);
            String menuHtml = AppCommand.formatMenuLabel(null, details.getName(), false, null, commands_.openHtmlExternal().getImageResource(), ProjectMRUList.NEW_SESSION_DESC);
            addItem(new MenuItem(menuHtml, true, new Scheduler.ScheduledCommand() {

                @Override
                public void execute() {
                    ProjectMRUList.openProjectFromMru(events_, details.getProjectFile());
                }
            }));
        }
        // displayed, offer a link
        if (sharedProjects.length() > MAX_SHARED_PROJECTS) {
            addItem(commands_.openSharedProject().createMenuItem(false));
        }
    }
    addSeparator();
    addItem(commands_.clearRecentProjects().createMenuItem(false));
    addSeparator();
    addItem(commands_.projectOptions().createMenuItem(false));
    callback.onPopupMenu(this);
}
Also used : AppCommand(org.rstudio.core.client.command.AppCommand) SharedProjectDetails(org.rstudio.studio.client.projects.model.SharedProjectDetails) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Aggregations

AppCommand (org.rstudio.core.client.command.AppCommand)10 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 MenuItem (com.google.gwt.user.client.ui.MenuItem)2 VisibleChangedHandler (org.rstudio.core.client.command.VisibleChangedHandler)2 ImageMenuItem (org.rstudio.studio.client.common.ImageMenuItem)2 RunAsyncCallback (com.google.gwt.core.client.RunAsyncCallback)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 AnimationCallback (com.google.gwt.layout.client.Layout.AnimationCallback)1 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 Command (com.google.gwt.user.client.Command)1 RootLayoutPanel (com.google.gwt.user.client.ui.RootLayoutPanel)1 SuggestOracle (com.google.gwt.user.client.ui.SuggestOracle)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 CommandHandler (org.rstudio.core.client.command.CommandHandler)1 EnabledChangedHandler (org.rstudio.core.client.command.EnabledChangedHandler)1 SearchWidget (org.rstudio.core.client.widget.SearchWidget)1