tatulund / filesystemdataprovider Goto Github PK
View Code? Open in Web Editor NEWFilesystemDataProvider for Vaadin 8 does what FilesystemContainer did in Vaadin 7
License: Apache License 2.0
FilesystemDataProvider for Vaadin 8 does what FilesystemContainer did in Vaadin 7
License: Apache License 2.0
I have a FilenameFilter to exclude Unix dot files (ie files that start with .), but I have to use setFilter to add it, and by then the root directory has been looked at, so dot files are added at that point.
Need an extra constructor that can take a FilenameFilter, analogous to the constructor that takes the the file extension filter.
I wanted to create a subclass of your FileSystemData but your constructors all construct the whole tree data. This is not very practical if you want for example to change the filtering or how the items are added. Therefore it would be nice to have an empty constructor to call in the subclass constructor without constructing the whole file tree.
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);
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.