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.
Thanks!
请先登录再写评论。
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.
https://github.com/JetBrains/intellij-community/blob/master/platform/structure-view-api/src/com/intellij/ide/projectView/TreeStructureProvider.java