use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class ExportPlotUtils method composeTargetPath.
public static FileSystemItem composeTargetPath(String ext, TextBox fileNameTextBox, FileSystemItem directory) {
// get the filename
String filename = fileNameTextBox.getText().trim();
if (filename.length() == 0)
return null;
// compute the target path
FileSystemItem targetPath = FileSystemItem.createFile(directory.completePath(filename));
// if the extension isn't already correct then append it
if (!targetPath.getExtension().equalsIgnoreCase(ext))
targetPath = FileSystemItem.createFile(targetPath.getPath() + ext);
// return the path
return targetPath;
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class SavePlotAsImageDialog method attemptSavePlot.
private void attemptSavePlot(boolean overwrite, final Operation onCompleted) {
// get plot format
final String format = saveAsTarget_.getFormat();
// validate path
FileSystemItem targetPath = saveAsTarget_.getTargetPath();
if (targetPath == null) {
globalDisplay_.showErrorMessage("File Name Required", "You must provide a file name for the plot image.", saveAsTarget_);
return;
}
saveOperation_.attemptSave(progressIndicator_, targetPath, format, getSizeEditor(), overwrite, viewAfterSaveCheckBox_.getValue(), onCompleted);
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class RemoteFileSystemContext method cd.
public void cd(String relativeOrAbsolutePath) {
final String newPath = combine(workingDir_, relativeOrAbsolutePath);
final FileSystemItem newPathEntry = FileSystemItem.createDir(newPath);
final ArrayList<FileSystemItem> fsi = new ArrayList<FileSystemItem>();
server_.listFiles(newPathEntry, // since this is used for the file dialog don't
false, // cause the call to reset the server monitoring state
new ServerRequestCallback<DirectoryListing>() {
@Override
public void onError(ServerError error) {
if (callbacks_ != null)
callbacks_.onError(error.getUserMessage());
}
@Override
public void onResponseReceived(final DirectoryListing response) {
final JsArray<FileSystemItem> files = response.getFiles();
for (int i = 0; i < files.length(); i++) fsi.add(files.get(i));
workingDir_ = newPath;
contents_ = fsi.toArray(new FileSystemItem[0]);
if (callbacks_ != null)
callbacks_.onNavigated();
}
});
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class RemoteFileSystemContext method mkdir.
public void mkdir(final String directoryName, final ProgressIndicator progress) {
String error;
if (null != (error = validatePathElement(directoryName, true))) {
progress.onError(error);
return;
}
final String baseDir = workingDir_;
String newPath = combine(baseDir, directoryName);
final FileSystemItem newFolder = FileSystemItem.createDir(newPath);
server_.createFolder(newFolder, new ServerRequestCallback<org.rstudio.studio.client.server.Void>() {
@Override
public void onError(ServerError error) {
progress.onError(error.getUserMessage());
}
@Override
public void onResponseReceived(Void response) {
if (baseDir.equals(workingDir_)) {
progress.onCompleted();
if (callbacks_ != null)
callbacks_.onDirectoryCreated(newFolder);
}
}
});
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class PackageLibraryUtils method typeOfLibrary.
public static PackageLibraryType typeOfLibrary(Session session, String library) {
FileSystemItem projectDir = null;
SessionInfo sessionInfo = session.getSessionInfo();
if (sessionInfo != null)
projectDir = sessionInfo.getActiveProjectDir();
// belongs in the project library
if (StringUtil.isNullOrEmpty(library) || (projectDir != null && library.startsWith(projectDir.getPath()))) {
return PackageLibraryType.Project;
} else if (library.startsWith(FileSystemItem.HOME_PATH)) {
return PackageLibraryType.User;
} else {
return PackageLibraryType.System;
}
}
Aggregations