Search in sources :

Example 1 with Entry

use of org.rstudio.studio.client.rsconnect.model.PlotPublishMRUList.Entry in project rstudio by rstudio.

the class RSConnectPublishButton method setPreviousDeployments.

private void setPreviousDeployments(JsArray<RSConnectDeploymentRecord> recs) {
    // clear existing deployment menu, if any
    publishMenu_.clearItems();
    defaultRec_ = null;
    // republish
    if (recs != null && recs.length() > 0) {
        applyCaption("Republish");
        // pass 
        for (int i = 0; i < recs.length(); i++) {
            final RSConnectDeploymentRecord rec = recs.get(i);
            if (rec == null)
                continue;
            if (defaultRec_ == null || defaultRec_.getWhen() < rec.getWhen()) {
                defaultRec_ = rec;
            }
        }
        // build the deployment menu
        for (int i = 0; i < recs.length(); i++) {
            final RSConnectDeploymentRecord rec = recs.get(i);
            final DeploymentMenuItem menuItem = new DeploymentMenuItem(rec, rec == defaultRec_, new Command() {

                @Override
                public void execute() {
                    onPublishRecordClick(rec);
                }
            });
            publishMenu_.addItem(menuItem);
        }
        publishMenu_.addSeparator();
        publishMenu_.addItem(new MenuItem(AppCommand.formatMenuLabel(commands_.rsconnectDeploy().getImageResource(), "Other Destination...", null), true, new Scheduler.ScheduledCommand() {

            @Override
            public void execute() {
                onPublishRecordClick(null);
            }
        }));
    } else {
        // show first-time publish button caption
        applyCaption("Publish");
        // no existing deployments to redeploy to, so just offer to make a new
        // one
        publishMenu_.addItem(new MenuItem(AppCommand.formatMenuLabel(commands_.rsconnectDeploy().getImageResource(), "Publish " + RSConnect.contentTypeDesc(contentType_) + "...", null), true, new Scheduler.ScheduledCommand() {

            @Override
            public void execute() {
                onPublishRecordClick(defaultRec_);
            }
        }));
    }
    // if it's a plot, show an MRU of recently deployed plot "names"
    if (contentType_ == RSConnect.CONTENT_TYPE_PLOT) {
        plotMru_.addPlotMruEntries(publishMenu_, new OperationWithInput<PlotPublishMRUList.Entry>() {

            @Override
            public void execute(Entry plot) {
                republishPlot(plot);
            }
        });
    }
    publishMenu_.addSeparator();
    publishMenu_.addItem(commands_.rsconnectManageAccounts().createMenuItem(false));
}
Also used : Entry(org.rstudio.studio.client.rsconnect.model.PlotPublishMRUList.Entry) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) MenuItem(com.google.gwt.user.client.ui.MenuItem) RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)

Aggregations

Command (com.google.gwt.user.client.Command)1 MenuItem (com.google.gwt.user.client.ui.MenuItem)1 AppCommand (org.rstudio.core.client.command.AppCommand)1 Entry (org.rstudio.studio.client.rsconnect.model.PlotPublishMRUList.Entry)1 RSConnectDeploymentRecord (org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)1