Search in sources :

Example 1 with RSConnectPublishSource

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

the class RSConnect method publishAsCode.

private void publishAsCode(RSConnectActionEvent event, String websiteDir, boolean isShiny) {
    RSConnectPublishSource source = null;
    if (event.getContentType() == CONTENT_TYPE_APP || event.getContentType() == CONTENT_TYPE_APP_SINGLE) {
        if (StringUtil.getExtension(event.getPath()).equalsIgnoreCase("r")) {
            FileSystemItem rFile = FileSystemItem.createFile(event.getPath());
            // use the directory for the deployment record when publishing 
            // directory-based apps; use the file itself when publishing 
            // single-file apps
            source = new RSConnectPublishSource(rFile.getParentPathString(), event.getContentType() == CONTENT_TYPE_APP ? rFile.getParentPathString() : rFile.getName());
        } else {
            source = new RSConnectPublishSource(event.getPath(), event.getPath());
        }
    } else {
        source = new RSConnectPublishSource(event.getPath(), websiteDir, false, false, isShiny, null, event.getContentType());
    }
    publishAsFiles(event, source);
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) RSConnectPublishSource(org.rstudio.studio.client.rsconnect.model.RSConnectPublishSource)

Example 2 with RSConnectPublishSource

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

the class RSConnect method deployToRSConnect.

private void deployToRSConnect(String sourceFile, String deployDir, String deployFile, String websiteDir, String description, JsArrayString deployFiles, JsArrayString additionalFiles, JsArrayString ignoredFiles, boolean isSelfContained, boolean isShiny, boolean asMultiple, boolean asStatic, boolean launch, JavaScriptObject jsoRecord) {
    // front if we can
    if (Desktop.isDesktop())
        Desktop.getFrame().bringMainFrameToFront();
    else
        WindowEx.get().focus();
    ArrayList<String> deployFilesList = JsArrayUtil.fromJsArrayString(deployFiles);
    ArrayList<String> additionalFilesList = JsArrayUtil.fromJsArrayString(additionalFiles);
    ArrayList<String> ignoredFilesList = JsArrayUtil.fromJsArrayString(ignoredFiles);
    RSConnectDeploymentRecord record = jsoRecord.cast();
    events_.fireEvent(new RSConnectDeployInitiatedEvent(new RSConnectPublishSource(sourceFile, deployDir, deployFile, websiteDir, isSelfContained, asStatic, isShiny, description), new RSConnectPublishSettings(deployFilesList, additionalFilesList, ignoredFilesList, asMultiple, asStatic), launch, record));
}
Also used : RSConnectPublishSettings(org.rstudio.studio.client.rsconnect.model.RSConnectPublishSettings) RSConnectDeployInitiatedEvent(org.rstudio.studio.client.rsconnect.events.RSConnectDeployInitiatedEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord) RSConnectPublishSource(org.rstudio.studio.client.rsconnect.model.RSConnectPublishSource)

Example 3 with RSConnectPublishSource

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

the class RSConnect method publishAsStatic.

private void publishAsStatic(RSConnectPublishInput input) {
    RSConnectPublishSource source = null;
    if (input.getContentType() == RSConnect.CONTENT_TYPE_DOCUMENT || input.getContentType() == RSConnect.CONTENT_TYPE_WEBSITE) {
        source = new RSConnectPublishSource(input.getOriginatingEvent().getFromPreview(), input.getWebsiteDir(), input.isSelfContained(), true, input.isShiny(), input.getDescription());
    } else {
        source = new RSConnectPublishSource(input.getOriginatingEvent().getHtmlFile(), input.getWebsiteDir(), input.isSelfContained(), true, input.isShiny(), input.getDescription(), input.getContentType());
    }
    publishAsFiles(input.getOriginatingEvent(), source);
}
Also used : RSConnectPublishSource(org.rstudio.studio.client.rsconnect.model.RSConnectPublishSource)

Example 4 with RSConnectPublishSource

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

the class RSConnect method showPublishUI.

private void showPublishUI(final RSConnectActionEvent event) {
    final RSConnectPublishInput input = new RSConnectPublishInput(event);
    // set these inside the wizard input so we don't need to pass around
    // session/prefs
    input.setConnectUIEnabled(pUiPrefs_.get().enableRStudioConnect().getGlobalValue());
    input.setExternalUIEnabled(session_.getSessionInfo().getAllowExternalPublish());
    input.setDescription(event.getDescription());
    if (event.getFromPrevious() != null) {
        switch(event.getContentType()) {
            case CONTENT_TYPE_APP:
            case CONTENT_TYPE_APP_SINGLE:
                publishAsCode(event, null, true);
                break;
            case CONTENT_TYPE_PRES:
            case CONTENT_TYPE_PLOT:
            case CONTENT_TYPE_HTML:
            case CONTENT_TYPE_DOCUMENT:
            case CONTENT_TYPE_WEBSITE:
                if (event.getFromPrevious().getServer().equals("rpubs.com")) {
                    publishAsRPubs(event);
                } else {
                    fillInputFromDoc(input, event.getPath(), new CommandWithArg<RSConnectPublishInput>() {

                        @Override
                        public void execute(RSConnectPublishInput arg) {
                            if (arg == null)
                                return;
                            if (event.getFromPrevious().getAsStatic())
                                publishAsFiles(event, new RSConnectPublishSource(event.getPath(), event.getHtmlFile(), arg.getWebsiteDir(), arg.isSelfContained(), true, arg.isShiny(), arg.getDescription(), event.getContentType()));
                            else
                                publishAsCode(event, arg.getWebsiteDir(), arg.isShiny());
                        }
                    });
                }
                break;
        }
    } else {
        // plots and HTML are implicitly self-contained
        if (event.getContentType() == CONTENT_TYPE_PLOT || event.getContentType() == CONTENT_TYPE_HTML || event.getContentType() == CONTENT_TYPE_PRES) {
            input.setIsSelfContained(true);
        }
        // if R Markdown, get info on what we're publishing from the server
        if (event.getFromPreview() != null) {
            input.setSourceRmd(FileSystemItem.createFile(event.getFromPreview().getSourceFile()));
            fillInputFromDoc(input, event.getFromPreview().getSourceFile(), new CommandWithArg<RSConnectPublishInput>() {

                @Override
                public void execute(RSConnectPublishInput arg) {
                    showPublishUI(arg);
                }
            });
        } else {
            showPublishUI(input);
        }
    }
}
Also used : RSConnectPublishInput(org.rstudio.studio.client.rsconnect.model.RSConnectPublishInput) RSConnectPublishSource(org.rstudio.studio.client.rsconnect.model.RSConnectPublishSource)

Aggregations

RSConnectPublishSource (org.rstudio.studio.client.rsconnect.model.RSConnectPublishSource)4 JsArrayString (com.google.gwt.core.client.JsArrayString)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 RSConnectDeployInitiatedEvent (org.rstudio.studio.client.rsconnect.events.RSConnectDeployInitiatedEvent)1 RSConnectDeploymentRecord (org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)1 RSConnectPublishInput (org.rstudio.studio.client.rsconnect.model.RSConnectPublishInput)1 RSConnectPublishSettings (org.rstudio.studio.client.rsconnect.model.RSConnectPublishSettings)1