Display project tree in settings

I am new in IDEA plugins dev. Maybe my question was discussed many of times but I can't find directly answer.
I need to display project tree at my settings panel
Tree must be thomething like tree.JPG
Is there something standart way to display project tree (I need only folders without files)? Maybe some API classes that build tree according to project object.
Or I need to get project structure and manually create JTree?

Links to examples would be great!.

Comment actions Permalink

com.intellij.openapi.fileChooser.FileSystemTreeFactory#createFileSystemTree should work for this. You can limit display to folders only via FileChooserDescriptor.

Comment actions Permalink

Thanks Yann! It is working. But i can't understand how to display only project tree, not all my file system.     

  FileSystemTreeFactory treeFactory = new FileSystemTreeFactoryImpl();
  FileSystemTree tree = treeFactory.createFileSystemTree(settings.getProject(), new FileChooserDescriptor(false, true, false, false,false,false));

Is there any approach to limit this tree to show only project structure?

Comment actions Permalink

I didn't try it myself, but com.intellij.openapi.fileChooser.FileChooserDescriptor#getRoots looks like it should work

Comment actions Permalink

Yann, thanks. It's works!

        FileSystemTreeFactory treeFactory = new FileSystemTreeFactoryImpl();         FileChooserDescriptor descriptor =  new FileChooserDescriptor(false, true, false, false,false,false);         descriptor.setIsTreeRootVisible(true);         descriptor.setRoots(settings.getProject().getBaseDir());         FileSystemTree tree = treeFactory.createFileSystemTree(settings.getProject(), descriptor);         add(tree.getTree());


Please sign in to leave a comment.