How to create a panel (something like the Inspection Results)
Hello,
I want to create a panel for my plugin, something like the Inspection Results. Is there a tutorial or an example how to create something like this? I also need the TreeView and Buttons as show in the Inspections Results.
regards
Chris
请先登录再写评论。
See https://www.jetbrains.org/intellij/sdk/docs/user_interface_components/tool_windows.html
Thank you, that is a good start. But how can I control the ToolWindow from my Action.
I want to hide the ToolWindow first and when a click the Button of my Plugin the ToolWindow should be displayed.
How can I do this?
You can register your tool window in plugin.xml like this:
<toolWindow id="ID" anchor="right" secondary="false" icon="..."
factoryClass="path.to.YourToolWindowFactory"
conditionClass="path.to.YourToolWindowFactory"/>
In this case your YourToolWindowFactory is responsible for:
- tool window content creation
- availability for a certain kind of project (Project can be irrelevant for your plugin if it doesn't have some specific frameworks/files/modules. For this purpose your factory implements Condition<Project> but you can omit it as well as conditionClass parameter in plugin.xml)
-it can override default behavior of method shouldBeAvailable() to false and button won't be visible at the startup
Later 'when a click the Button' you just call toolWindow.show() or ToolWindowManager.getInstance(...).getToolWindow(ID).show()
Thanks for the reply,
but the Method ToolWindowManager.getInstance(...).getToolWindow(ID).show() requires a Runnable. But first the ID from the plugin.xml is not avaible, I get a null for the getToolWindow(ID). :(
Ok I solved this myself. If the Condition returns false in the value() Method I get a null if I try to get the ToolWindow with getToolWindow(ID). First I thought the value method in the Condition is responsible if the Toolwindow is visible or not.