You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the first root item (lexicographically ordered) has no children (empty folder or file) than nothing is shown.
The problem is that the FilesystemDataProvider treats the first query (parent == null) as if the first root item was the parent. If this is a file or an empty folder than nothing is return. The correct way is to return the root items.
Workaround/Fix:
public class FixedFilesystemDataProvider extends FilesystemDataProvider {
private static final long serialVersionUID = 6219944935877634942L;
public FixedFilesystemDataProvider(FilesystemData treeData) {
super(treeData);
}
@Override
public int getChildCount(HierarchicalQuery<File, SerializablePredicate<File>> query) {
if(query.getParentOptional().isPresent()) {
return (int) fetchChildren(query).count();
} else {
return getTreeData().getRootItems().size();
}
}
@Override
public Stream<File> fetchChildren(HierarchicalQuery<File, SerializablePredicate<File>> query) {
if (!isInMemory()) {
Optional<File> optParent = query.getParentOptional();
if (optParent.isPresent()) {
File parent = optParent.get();
if (getTreeData().getChildren(parent).isEmpty()) {
List<File> files = ((FilesystemData) getTreeData()).getChildrenFromFilesystem(parent);
getTreeData().addItems(parent, files);
return files.stream();
} else {
return super.fetchChildren(query);
}
} else {
return getTreeData().getRootItems().stream().sorted(getSortComparator());
}
} else {
return super.fetchChildren(query);
}
}
}
The text was updated successfully, but these errors were encountered:
When the first root item (lexicographically ordered) has no children (empty folder or file) than nothing is shown.
The problem is that the FilesystemDataProvider treats the first query (parent == null) as if the first root item was the parent. If this is a file or an empty folder than nothing is return. The correct way is to return the root items.
Workaround/Fix:
The text was updated successfully, but these errors were encountered: