Folks, I need some guidance on how to go about a custom tool window. Ultimately I would like to reuse as much as possible of an existing code. Here's what I'm trying to do. I want to implement a custom ToolWindow which will only be available in projects with a certain facet. I have a class MyFacet and in its initFacet method I have the following code:
ToolWindow toolWindow = ToolWindowManager.getInstance(this.getModule().getProject()).registerToolWindow("MyCustomToolWindow", true, ToolWindowAnchor.LEFT, false);
toolWindow.getContentManager().addContent(new ContentImpl(new MyCustomToolWindowPanel(this.getModule().getProject()), "", true));
So far so good. Now the question is how do I implement the custom tool window panel. Its behavior should be similar to the Structure or a Project view - i.e. it should display a tree with some Xml files and certain tags inside those files, and upon double-clicking the file or a tag it should open the corresponding file in the editor and highlight that tag.
1) If I create my own tree from scratch, which objects should I populate it with? PsiElements? PsiReferences?
2) How do I open the file in editor and scroll to the position when user clicks the element in the tool window tree?
3) How do I make sure that the tree in my tool window has fonts and colors that are matching the default intellij theme? I tried creating a sample tree, just to see what it looks like, and I used the DnDAwareTree class, but the tree has a gray background color, instead of white or the dark one from the Darcula theme.
4) I did review the tool_window example from the SDK docs, but unfortunately it's not enough. Are there any more advanced examples?