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;
}
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;
}
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());
}
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();
}
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;
}
}
Aggregations