While True
While True

Reputation: 423

Tree from tree paths

In my project I have a lot of data, that can be structured in some way. To simplify, let's pretend that that data is a bunch of file paths:

/user/homefolder/Folder1/file1.jpg
/user/homefolder/Folder1/file2.jpg
/user/homefolder/Folder2/file3.jpg
/user/homefolder/Folder2/file4.jpg
/user/homefolder/Folder3/file5.jpg

So, I have actually tree-paths and I do can group these paths by first three folders or more if there are.

I have this values in a array of arrays. And I don't want to create a duplicate tree-model.

I use JFace TreeViewer in SWT.VIRTUAL style and the ILazyTreeContentProvider doesn't seem to be made to work with this kind of data.

How should I do to be able to create proper tree?

Upvotes: 0

Views: 95

Answers (1)

baliman
baliman

Reputation: 620

Have a look at

https://github.com/johandb/JTree

You can implement your own node

Example

Tree<String> root = new Tree<String>();
Tree<String> folder1 = root.add("Folder1");
folder1.add("file1.jpg");
folder1.add("file2.jpg");
Tree<String> folder2 = root.add("Folder2");
folder2.add("file3.jpg");
folder2.add("file4.jpg");

etc etc

Regards

Johan

Upvotes: 0

Related Questions