Giter Site home page Giter Site logo

tatulund / filesystemdataprovider Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 3.0 57 KB

FilesystemDataProvider for Vaadin 8 does what FilesystemContainer did in Vaadin 7

License: Apache License 2.0

Java 96.63% CSS 3.37%
vaadin data-structures datastructures datamodel dataprovider vaadin8 tree treegrid filesystem java

filesystemdataprovider's People

Contributors

binbalenci avatar tatulund avatar

Watchers

 avatar  avatar  avatar

filesystemdataprovider's Issues

FilenameFilter not used at root level

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.

Add empty constructor to simplify inheritance

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.

Error when first root Element has no children

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.