Search in sources :

Example 51 with FileSystemItem

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();
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem)

Example 52 with FileSystemItem

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);
            }
        });
    }
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) FileSystemContext(org.rstudio.core.client.files.FileSystemContext)

Example 53 with FileSystemItem

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]);
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ArrayList(java.util.ArrayList)

Example 54 with FileSystemItem

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();
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem)

Example 55 with FileSystemItem

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);
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem)

Aggregations

FileSystemItem (org.rstudio.core.client.files.FileSystemItem)89 ServerError (org.rstudio.studio.client.server.ServerError)18 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)16 JsArrayString (com.google.gwt.core.client.JsArrayString)14 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)10 Handler (org.rstudio.core.client.command.Handler)10 Command (com.google.gwt.user.client.Command)9 ArrayList (java.util.ArrayList)7 AppCommand (org.rstudio.core.client.command.AppCommand)7 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)6 TextFileType (org.rstudio.studio.client.common.filetypes.TextFileType)5 JsArray (com.google.gwt.core.client.JsArray)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 JSONString (com.google.gwt.json.client.JSONString)4 FilePosition (org.rstudio.core.client.FilePosition)4 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)4 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)4 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)4 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)4 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)4