1 /* 2 * RSConnectPublishInput.java 3 * 4 * Copyright (C) 2021 by RStudio, PBC 5 * 6 * Unless you have received this program directly from RStudio pursuant 7 * to the terms of a commercial license agreement with RStudio, then 8 * this program is licensed to you under the terms of version 3 of the 9 * GNU Affero General Public License. This program is distributed WITHOUT 10 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, 11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the 12 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. 13 * 14 */ 15 16 package org.rstudio.studio.client.rsconnect.model; 17 18 import org.rstudio.core.client.StringUtil; 19 import org.rstudio.core.client.files.FileSystemItem; 20 import org.rstudio.studio.client.rsconnect.RSConnect; 21 import org.rstudio.studio.client.rsconnect.events.RSConnectActionEvent; 22 23 public class RSConnectPublishInput 24 { RSConnectPublishInput(RSConnectActionEvent originatingEvent)25 public RSConnectPublishInput(RSConnectActionEvent originatingEvent) 26 { 27 originatingEvent_ = originatingEvent; 28 } 29 isShiny()30 public boolean isShiny() 31 { 32 return isShiny_; 33 } 34 setIsShiny(boolean isShiny)35 public void setIsShiny(boolean isShiny) 36 { 37 isShiny_ = isShiny; 38 } 39 getSourceRmd()40 public FileSystemItem getSourceRmd() 41 { 42 return sourceRmd_; 43 } 44 setSourceRmd(FileSystemItem sourceRmd)45 public void setSourceRmd(FileSystemItem sourceRmd) 46 { 47 sourceRmd_ = sourceRmd; 48 } 49 isConnectUIEnabled()50 public boolean isConnectUIEnabled() 51 { 52 return isConnectUIEnabled_; 53 } 54 hasConnectAccount()55 public boolean hasConnectAccount() 56 { 57 return hasConnectAccount_; 58 } 59 setHasConnectAccount(boolean hasAccount)60 public void setHasConnectAccount(boolean hasAccount) 61 { 62 hasConnectAccount_ = hasAccount; 63 } 64 setConnectUIEnabled(boolean enabled)65 public void setConnectUIEnabled(boolean enabled) 66 { 67 isConnectUIEnabled_ = enabled; 68 } 69 isExternalUIEnabled()70 public boolean isExternalUIEnabled() 71 { 72 return isExternalUIEnabled_; 73 } 74 hasDocOutput()75 public boolean hasDocOutput() 76 { 77 return originatingEvent_ != null && 78 originatingEvent_.getFromPreview() != null && 79 !StringUtil.isNullOrEmpty( 80 originatingEvent_.getFromPreview().getOutputFile()); 81 } 82 getDocOutput()83 public String getDocOutput() 84 { 85 if (!hasDocOutput()) 86 return null; 87 return originatingEvent_.getFromPreview().getOutputFile(); 88 } 89 setExternalUIEnabled(boolean enabled)90 public void setExternalUIEnabled(boolean enabled) 91 { 92 isExternalUIEnabled_ = enabled; 93 } 94 isMultiRmd()95 public boolean isMultiRmd() 96 { 97 return isMultiRmd_; 98 } 99 setIsMultiRmd(boolean isMulti)100 public void setIsMultiRmd(boolean isMulti) 101 { 102 isMultiRmd_ = isMulti; 103 } 104 isSelfContained()105 public boolean isSelfContained() 106 { 107 return isSelfContained_; 108 } 109 setIsSelfContained(boolean selfContained)110 public void setIsSelfContained(boolean selfContained) 111 { 112 isSelfContained_ = selfContained; 113 } 114 setDescription(String description)115 public void setDescription(String description) 116 { 117 description_ = description; 118 } 119 getDescription()120 public String getDescription() 121 { 122 return description_; 123 } 124 getContentType()125 public int getContentType() 126 { 127 return getOriginatingEvent().getContentType(); 128 } 129 isWebsiteContentType()130 public boolean isWebsiteContentType() 131 { 132 return getContentType() == RSConnect.CONTENT_TYPE_WEBSITE || 133 getContentType() == RSConnect.CONTENT_TYPE_QUARTO_WEBSITE; 134 } 135 getOriginatingEvent()136 public RSConnectActionEvent getOriginatingEvent() 137 { 138 return originatingEvent_; 139 } 140 getWebsiteDir()141 public String getWebsiteDir() 142 { 143 return websiteDir_; 144 } 145 setWebsiteDir(String dir)146 public void setWebsiteDir(String dir) 147 { 148 websiteDir_ = dir; 149 } 150 isWebsiteRmd()151 public boolean isWebsiteRmd() 152 { 153 return !StringUtil.isNullOrEmpty(websiteDir_); 154 } 155 getWebsiteOutputDir()156 public String getWebsiteOutputDir() 157 { 158 return websiteOutputDir_; 159 } 160 setWebsiteOutputDir(String dir)161 public void setWebsiteOutputDir(String dir) 162 { 163 websiteOutputDir_ = dir; 164 } 165 isQuarto()166 public boolean isQuarto() 167 { 168 return isQuarto_; 169 } 170 setIsQuarto(boolean quarto)171 public void setIsQuarto(boolean quarto) 172 { 173 isQuarto_ = quarto; 174 } 175 isStaticDocInput()176 public boolean isStaticDocInput() 177 { 178 // plots and presentations are always static 179 if (getContentType() == RSConnect.CONTENT_TYPE_PLOT || 180 getContentType() == RSConnect.CONTENT_TYPE_PRES || 181 getContentType() == RSConnect.CONTENT_TYPE_HTML) 182 return true; 183 if (getContentType() != RSConnect.CONTENT_TYPE_DOCUMENT) 184 return false; 185 if (getSourceRmd() == null) 186 return true; 187 final String ext = getSourceRmd().getExtension().toLowerCase(); 188 return ext == ".html" || ext == ".md"; 189 } 190 191 private boolean isShiny_; 192 private boolean isConnectUIEnabled_; 193 private boolean isExternalUIEnabled_; 194 private boolean isMultiRmd_; 195 private boolean isSelfContained_; 196 private boolean hasConnectAccount_; 197 private boolean isQuarto_; 198 private FileSystemItem sourceRmd_; 199 private RSConnectActionEvent originatingEvent_; 200 private String description_ = null; 201 private String websiteDir_; 202 private String websiteOutputDir_; 203 } 204