use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class OpenFileDialog method shouldAccept.
@Override
public boolean shouldAccept() {
if (canChooseDirectories_) {
FileSystemItem item = browser_.getSelectedItem();
String fileInput = browser_.getFilename().trim();
// directory as an RStudio project
if (item == null && fileInput.isEmpty())
return true;
// navigate into that directory
if (item != null && item.isDirectory()) {
cd(item.getPath());
return false;
}
}
return super.shouldAccept();
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class PathBreadcrumbWidget method browse.
private void browse() {
if (Desktop.isDesktop()) {
FileSystemContext tempContext = RStudioGinjector.INSTANCE.getRemoteFileSystemContext();
RStudioGinjector.INSTANCE.getFileDialogs().chooseFolder("Go To Folder", tempContext, null, new ProgressOperationWithInput<FileSystemItem>() {
public void execute(FileSystemItem input, ProgressIndicator indicator) {
if (input == null)
return;
context_.cd(input.getPath());
indicator.onCompleted();
}
});
} else {
context_.messageDisplay().promptForText("Go To Folder", "Path to folder (use ~ for home directory):", "", new OperationWithInput<String>() {
@Override
public void execute(String input) {
if (input == null)
return;
context_.cd(input);
}
});
}
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class ChooseFolderDialog method ls.
@Override
public FileSystemItem[] ls() {
FileSystemItem[] items = super.ls();
ArrayList<FileSystemItem> dirs = new ArrayList<FileSystemItem>();
for (FileSystemItem item : items) if (item.isDirectory())
dirs.add(item);
return dirs.toArray(new FileSystemItem[0]);
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class ChooseFolderDialog method getEffectiveDirectoryWithValidation.
private String getEffectiveDirectoryWithValidation() {
browser_.setFilename(browser_.getFilename().trim());
String name = browser_.getFilename();
// This handles the special case of "~"
if (context_.isAbsolute(name))
return name;
if (name.length() == 0)
return context_.pwd();
if (name.contains("/"))
return context_.combine(context_.pwd(), name);
// If an item is selected (highlighted) in the browse control, then
// only use it IF it is the same as the name in the name textbox. The
// name textbox takes precedence.
FileSystemItem selectedItem = browser_.getSelectedItem();
if (selectedItem != null && selectedItem.getName().equals(name))
return selectedItem.getPath();
if (name.equals(context_.pwdItem().getName())) {
// The identity condition
return context_.pwd();
}
FileSystemItem item = context_.itemForName(name, true, false);
if (item == null) {
onError("The folder does not exist.");
return null;
}
return item.getPath();
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class DirectoryContentsWidget method onBackspace.
private void onBackspace() {
if (!items_.containsKey(".."))
return;
FileSystemItem item = items_.get("..");
commitSelection(item);
}
Aggregations