Search in sources :

Example 6 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class DuplicateHelper method getPathLabels.

/**
    * Use Mac OS X style prettifying of paths. Display the filename,
    * and if there are multiple entries with the same filename, append
    * a disambiguating folder to those filenames.
    */
public static ArrayList<String> getPathLabels(ArrayList<String> paths, boolean includeExtension) {
    ArrayList<String> labels = new ArrayList<String>();
    for (String entry : paths) {
        if (includeExtension)
            labels.add(FileSystemItem.getNameFromPath(entry));
        else
            labels.add(FileSystemItem.createFile(entry).getStem());
    }
    DuplicationInfo<String> dupeInfo = DuplicateHelper.detectDupes(labels, new CaseInsensitiveStringComparator());
    for (ArrayList<Integer> dupeList : dupeInfo.dupes()) {
        fixupDupes(paths, dupeList, labels);
    }
    dupeInfo = DuplicateHelper.detectDupes(labels, new CaseInsensitiveStringComparator());
    // ~/bar/README
    for (ArrayList<Integer> dupeList : dupeInfo.dupes()) {
        for (Integer index : dupeList) {
            FileSystemItem fsi = FileSystemItem.createFile(paths.get(index));
            String name = includeExtension ? fsi.getName() : fsi.getStem();
            labels.set(index, disambiguate(name, fsi.getParentPathString()));
        }
    }
    return labels;
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem)

Example 7 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class FileDialog method navigateIfDirectory.

private boolean navigateIfDirectory() {
    FileSystemItem item = context_.itemForName(browser_.getFilename(), true, false);
    if (item != null && item.isDirectory()) {
        browser_.setFilename("");
        cd(item.getName());
        return true;
    }
    return false;
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem)

Example 8 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class FileDialog method onSelection.

@Override
public void onSelection(SelectionEvent<FileSystemItem> event) {
    super.onSelection(event);
    FileSystemItem item = event.getSelectedItem();
    if (item != null && !item.isDirectory())
        browser_.setFilename(item.getName());
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem)

Example 9 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class PathBreadcrumbWidget method setDirectory.

public void setDirectory(FileSystemItem[] pathElements, String lastBrowseable) {
    pathPanel_.clear();
    maybeAddProjectIcon();
    if (linkUp_ != null)
        linkUp_.setVisible(pathElements.length > 1);
    Widget lastAnchor = null;
    for (FileSystemItem item : pathElements) {
        boolean browseable = true;
        if (lastBrowseable != null)
            browseable = item.getPath().startsWith(lastBrowseable);
        lastAnchor = addAnchor(item, browseable);
    }
    if (lastAnchor != null)
        lastAnchor.addStyleName(RES.styles().last());
    onWidthsChanged();
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem)

Example 10 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class PathBreadcrumbWidget method maybeAddProjectIcon.

private void maybeAddProjectIcon() {
    if (projectIconsAdded_)
        return;
    if (pSession_ == null || pSession_.get() == null)
        return;
    final FileSystemItem projDir = pSession_.get().getSessionInfo().getActiveProjectDir();
    if (projDir != null) {
        Image projIcon = new Image(new ImageResource2x(RES.projectImage2x()));
        projIcon.addStyleName(ThemeResources.INSTANCE.themeStyles().handCursor());
        projIcon.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                SelectionCommitEvent.fire(PathBreadcrumbWidget.this, projDir);
            }
        });
        projIcon.addStyleName(RES.styles().project());
        projIcon.setTitle("Go to project directory");
        eastFrame_.insert(projIcon, 0);
        // TODO: infer from contents
        double width = 42;
        frame_.setWidgetSize(eastFrame_, width);
        projectIconsAdded_ = true;
    }
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

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