Expand node in project view
I've created a directory and a file in it like this:
PsiFile classFile = PsiFileFactory.getInstance(project).createFileFromText("Test.java", "class Test{}");
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(newModuleRoot); directory.add(classFile);
But the directory in the project view is collapsed.
Can I expand the directory programmatically?
Please sign in to leave a comment.
Try following:
For some reason I just don't have access to ProjectView. When I type "ProjectView.getInstance(project)" I get "Can't resolve symbol 'ProjectView'".
It is located in idea.jar. Just add it to your SDK classpath.
Yeah, thanks. I wonder why IDEA didn't include it in Plugin SDK when I created Plugin SDK from IDEA installation home dir.
I tried
It didn't work.
My guess is it's because UI doesn't know yet that tree structure changed, cause I've just added new module. I tried doing
It didn't help either.
This thread may be of help: http://devnet.jetbrains.net/message/5244183
Thank you. The problem indeed was that I was using created PsiFIle while I should have used the one returned by the add() method. That was a tricky one, I must say.
selectPsiElement() serves fine for my purpose, so my code became something like this: