Giter Site home page Giter Site logo

tatulund / filesystem-dataprovider-flow Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 2.0 67 KB

FilesystemDataProvider is a data model add-on for 14 and 23 (Flow) providing hierarchical data of the ftp and filesystem, including File select components.

License: Other

Java 100.00%
vaadin vaadin14 filesystem flow tree hierarchical-data treegrid-components dataprovider select fileselect field java ftp ftp-client vaadin23

filesystem-dataprovider-flow's Introduction

FilesystemDataProvider

FilesystemDataProvider is a data model add-on for Vaadin 23(Flow) providing hierarchical data of the filesystem, and it can be used to supply it to Tree and TreeGrid components. This is fully server side add-on.

The inspiration of this add-on is to provide similar functionality than Vaadin 7's built in FilesystemContainer had. Hence it is useful for Vaadin 7 -> Vaadin 23 migration projects.

Components

  • FilesystemDataProvider: Data provider wrapper of the filesystem

  • FileSelect: Field UI component that allows selecting a single file, value is File

  • MultiFileSelect: Field UI component that allows selecting multiple files, value is Set

  • FtpDataProvider: Data provider wrapper of the FTP client, uses appache commons ftp

  • FtpSelect: Field UI component that acts as FTP client, value is FtpFile

  • FtpFile: Extended FTPFile, that implements Comparable, so that it works with Vaadin's DataProvider API's.

Development instructions

Starting the test/demo server:

  1. Run mvn jetty:run.
  2. Open http://localhost:8080 in the browser.

Publishing to Vaadin Directory

You can create the zip package needed for Vaadin Directory using

mvn versions:set -DnewVersion=1.0.0 # You cannot publish snapshot versions 
mvn install -Pdirectory

The package is created as target/filesystemdataprovider-1.0.0.zip

For more information or to upload the package, visit https://vaadin.com/directory/my-components?uploadNewComponent

History

Version 3.1.0

  • Fixed icons to be compatible with Vaadin 21 and newer

Version 3.0.0

  • Build against Vaadin 18

Version 2.1.0

  • Add FTP variants

Version 2.0.0

  • First release for Vaadin 10+

filesystem-dataprovider-flow's People

Contributors

tatulund avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

filesystem-dataprovider-flow's Issues

Remove jrebel.xml from JAR

The JAR file contains a jrebel.xml in the root which produces warnings when using JRebel:

[2023-01-19 14:15:29] Invalid rebel.xml: Invalid 'dir' defined in class path of rebel.xml (jar:file:/C:/Users/simon/.m2/repository/org/vaadin/filesystemdataprovider/filesystemdataprovider/3.2.0/filesystemdataprovider-3.2.0.jar!/rebel.xml): Directory 'C:/Projects/filesystem-dataprovider-flow/target/classes' does not exist

Please exclude jrebel.xml from the build

Add SMB support [discussion]

Hi, thanks for the nice addon. I have written a TreeData and DataProvider to support the browsing and handling of SMB sources. Lazy loading is supported. My implementation is based on https://github.com/hierynomus/smbj. I would like to know if there is interest to merge it into this project. Some polishment would be needed if it is desired.

Vaadin 23.1.0beta1 + Filters and non-recursive exception

Hi,

First of all, congrats for such a great extension!!

I found an issue when I configure the FileSystemDataProvider as non-recursive and with some filters to hide Thumbs.db and .DS_Store files.

        FilesystemData root = new FilesystemData(directory, false); //Setting to true, avoids exception
        FilesystemDataProvider fileSystem = new FilesystemDataProvider(root);
        fileSystem.addFilter(file -> !file.getName().endsWith(".db")); //Remove Thumbs.db
        fileSystem.addFilter(file -> !file.getName().equals(".DS_Store")); //Remove DS_Store
        Tree<File> tree = new Tree<>();
        tree.setDataProvider(fileSystem);
        tree.addHierarchyColumn(File::getName, FileTypeResolver::getIcon, this::getFileDescription)
                .setAutoWidth(true).setResizable(true).setHeader("File");
        tree.expand(directory); //Open root directory

The exception happens when I expand a directory on the second level order that has something filtered. I'm not really sure if the exception happens because of the deeper implementation of Vaadin TreeDataProvider

// When I expanded the directory, it has 4 items,and one of them is filtered.
java.lang.IndexOutOfBoundsException: Index 3 out of bounds for length 3
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[na:na]
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[na:na]
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[na:na]
	at java.base/java.util.Objects.checkIndex(Objects.java:359) ~[na:na]
	at java.base/java.util.ArrayList.get(ArrayList.java:427) ~[na:na]
	at com.vaadin.flow.data.provider.hierarchy.HierarchicalCommunicationController.lambda$getJsonItems$5(HierarchicalCommunicationController.java:323) ~[flow-data-23.1.0.beta1.jar:23.1.0.beta1]
	at java.base/java.util.stream.IntPipeline$1$1.accept(IntPipeline.java:180) ~[na:na]
	at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104) ~[na:na]
	at java.base/java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:711) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
	at com.vaadin.flow.data.provider.hierarchy.HierarchicalCommunicationController.getJsonItems(HierarchicalCommunicationController.java:325) ~[flow-data-23.1.0.beta1.jar:23.1.0.beta1]
	at com.vaadin.flow.data.provider.hierarchy.HierarchicalCommunicationController.set(HierarchicalCommunicationController.java:208) ~[flow-data-23.1.0.beta1.jar:23.1.0.beta1]
	at com.vaadin.flow.data.provider.hierarchy.HierarchicalCommunicationController.collectChangesToSend(HierarchicalCommunicationController.java:177) ~[flow-data-23.1.0.beta1.jar:23.1.0.beta1]

Regards,
Alex

Browse directory on remote server

Hi,
There is a way to authenticate on remote server with your component?

My vaadin application is running on Ubuntu server, and I needs to browse files on different server (Windows server).

Normally using C# or Python I can impersonate a user and login to the remote server, and browse for files and folders.

Here my code:

Button browse= new Button("browse", ev -> {
        		if(SessionUtils.getLoggedUser().getTenant().getBasePath() == null || SessionUtils.getLoggedUser().getTenant().getBasePath().length() == 0)
        			return;
        	
        		Dialog dialog = new Dialog();
        		
        		VerticalLayout layout = new VerticalLayout();
        		
                        //SessionUtils.getLoggedUser().getTenant().getBasePath() = \\ip\folder\
        		File rootFile3 = new File(SessionUtils.getLoggedUser().getTenant().getBasePath());
            	FileSelect fileSelect = new FileSelect(rootFile3);
            	fileSelect.addValueChangeListener(event -> {
                	File file = fileSelect.getValue();
            		Date date = new Date(file.lastModified());
                	if (!file.isDirectory()) {
                		Notification.show(file.getPath() + ", " + date + ", " + file.length());        		
                	} else {
                		Notification.show(file.getPath() + ", " + date);
                	}
            	});
            	fileSelect.setWidth("500px");
            	fileSelect.setHeight("500px");
            	layout.setSizeFull();
            	layout.setAlignItems(Alignment.CENTER);
            	layout.setJustifyContentMode(JustifyContentMode.CENTER);
            	fileSelect.setLabel("Select file");
            	layout.add(fileSelect);
            	
            	Button closeBtn = new Button("Chiudi", e -> dialog.close());
            	
            	layout.add(closeBtn);
            	
            	dialog.add(layout);
                
                dialog.setCloseOnEsc(true);
                
                dialog.open();

        	});

With this code, and a local path on the ubuntu server I can browse files, but not on the remote server that requires login.

I needs to impersonate the user to respect the permissions assigned.

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.