How I can find JTree node by VirtualFile and move node inside another.

I wanna find *.css files and move as child in *.styl. Like File Watcher do it.

In first step I:

Collection<VirtualFile> stylFile = FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, "file.styl", GlobalSearchScope.allScope(project));
Collection<VirtualFile> cssFile = FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, "file.css", GlobalSearchScope.allScope(project));

P.S. Project have one styl and css file now.

ProjectView projectView = ProjectView.getInstance(project); AbstractProjectViewPane projectViewPane = projectView.getCurrentProjectViewPane(); if (projectViewPane == null) return; JTree tree = projectViewPane.getTree();
TreeModel model = tree.getModel();

I don't now now how to find files and move it inside. And may be you know another right way.


1 comment
Comment actions Permalink

You cannot directly modify the tree structure of the project view; it's built and updated dynamically. Instead, you need to implement a TreeStructureProvider extension, which allows you to modify the structure of the project view as it is built.


Please sign in to leave a comment.