Expand non psi-based ProjectViewTree nodes
Answered
I use the custom project tree in a plugin. I wish to expand the second nesting level of the tree, but these nodes are not psi-based and extend ProjectViewNode<String>, so I can’t select a PsiElement for this purpose.
Is there any way to expand the node on creation or set the expanded state by default?
Please sign in to leave a comment.
Why `com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane#select` is not good?
Because these nodes are just children of ProjectViewNode<String>, they do not have VirtualFile to select.
The node whose children I want to expand looks like this:
ProjectView was designed to work with PsiElements or VirtualFiles.
In your case you could use the following method to expand top nodes:
```com.intellij.util.ui.tree.TreeUtil#promiseExpand(javax.swing.JTree, int)```
where depth level should be set to 2.
I hope your SomeSection class implements contains(VirtualFile) method correctly to support searching of containing files.
What are these nodes, if it's not a secret?
Thanks, TreeUtil#promiseExpand works for me.
Yes, my custom nodes implements contains(VirtualFile) method.
For example
This node aggregate all gradle scripts from the project