use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class SavePlotAsPdfDialog method attemptSavePdf.
private void attemptSavePdf(boolean overwrite, final Operation onCompleted) {
// validate file name
FileSystemItem targetPath = getTargetPath();
if (targetPath == null) {
globalDisplay_.showErrorMessage("File Name Required", "You must provide a file name for the plot pdf.", fileNameTextBox_);
return;
}
// invoke handler
SavePlotAsHandler handler = createSavePlotAsHandler();
handler.attemptSave(targetPath, overwrite, viewAfterSaveCheckBox_.getValue(), onCompleted);
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class FilesPane method onBeforeSelected.
@Override
public void onBeforeSelected() {
if (needsInit) {
needsInit = false;
FileSystemItem home = FileSystemItem.home();
observer_.onFileNavigation(home);
} else {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
filesList_.redraw();
}
});
}
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class FilesList method updateWithAction.
public void updateWithAction(FileChange viewAction) {
final FileSystemItem file = viewAction.getFile();
final List<FileSystemItem> files = getFiles();
switch(viewAction.getType()) {
case FileChange.ADD:
if (file.getParentPath().equalTo(containingPath_)) {
int row = rowForFile(file);
if (row == -1) {
files.add(file);
filesDataGrid_.setPageSize(files.size() + 1);
} else {
// since we eagerly perform renames at the client UI
// layer then sometimes an "added" file is really just
// a rename. in this case the file already exists due
// to the eager rename in the client but still needs its
// metadata updated
files.set(row, file);
}
}
break;
case FileChange.MODIFIED:
{
int row = rowForFile(file);
if (row != -1)
files.set(row, file);
}
break;
case FileChange.DELETE:
{
int row = rowForFile(file);
if (row != -1) {
files.remove(row);
// if a file is deleted and then re-added within the same
// event loop (as occurs when gedit saves a text file) the
// table doesn't always update correctly (it has a duplicate
// of the item deleted / re-added). the call to flush overcomes
// this issue
dataProvider_.flush();
}
}
break;
default:
Debug.log("Unexpected file change type: " + viewAction.getType());
break;
}
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class HelpPane method getDocTitle.
private String getDocTitle(Document doc) {
String docUrl = StringUtil.notNull(doc.getURL());
String docTitle = doc.getTitle();
String previewPrefix = new String("/help/preview?file=");
int previewLoc = docUrl.indexOf(previewPrefix);
if (previewLoc != -1) {
String file = docUrl.substring(previewLoc + previewPrefix.length());
file = URL.decodeQueryString(file);
FileSystemItem fsi = FileSystemItem.createFile(file);
docTitle = fsi.getName();
} else if (StringUtil.isNullOrEmpty(docTitle)) {
String url = new String(docUrl);
url = url.split("\\?")[0];
url = url.split("#")[0];
String[] chunks = url.split("/");
docTitle = chunks[chunks.length - 1];
}
return docTitle;
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class RSConnectDeploy method populateDeploymentFiles.
private void populateDeploymentFiles(final ProgressIndicator indicator) {
if (source_ == null)
return;
// dependencies; just inject it directly into the list.
if (source_.isSelfContained() && source_.isStatic() && !source_.isWebsiteRmd()) {
ArrayList<String> files = new ArrayList<String>();
FileSystemItem selfContained = FileSystemItem.createFile(source_.getDeployFile());
files.add(selfContained.getName());
setFileList(files, null, null);
setPrimaryFile(selfContained.getName());
return;
}
// ternery operator maps to appropriate files to list for deployment:
// website code - website code directory
// static website - website build directory
// document - R Markdown document
// non-document - Shiny app directory
final String fileSource = source_.isDocument() ? source_.isWebsiteRmd() ? source_.isStatic() ? source_.getDeployDir() : source_.getWebsiteDir() : source_.getDeployFile() : source_.getDeployDir();
indicator.onProgress("Collecting files...");
server_.getDeploymentFiles(fileSource, asMultipleRmd_, new ServerRequestCallback<RSConnectDeploymentFiles>() {
@Override
public void onResponseReceived(RSConnectDeploymentFiles files) {
if (files.getDirSize() > files.getMaxSize()) {
indicator.onError("The item to be deployed (" + fileSource + ") " + "exceeds the maximum deployment size, which is " + StringUtil.formatFileSize(files.getMaxSize()) + "." + " Consider creating a new directory containing " + "only the content you wish to deploy.");
} else {
if (files.getDirList() == null || files.getDirList().length() == 0) {
indicator.onError("Could not determine the list of " + "files to deploy.");
indicator.onCompleted();
}
setFileList(JsArrayUtil.fromJsArrayString(files.getDirList()), fromPrevious_ != null ? fromPrevious_.getAdditionalFiles() : null, fromPrevious_ != null ? fromPrevious_.getIgnoredFiles() : null);
if (!source_.isWebsiteRmd())
setPrimaryFile(FileSystemItem.createFile(source_.getDeployFile()).getName());
}
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
indicator.clearProgress();
}
});
}
@Override
public void onError(ServerError error) {
// we need to have a list of files to deploy to proceed
indicator.onError("Could not find files to deploy: \n\n" + error.getMessage());
indicator.onCompleted();
}
});
}
Aggregations