Tool windows are child windows of IntelliJ IDEA used to display information.
Tool windows generally have their own toolbars (referred to as tool window bars) along the outer edges of the main window containing one or more tool window buttons. For detailed information about tool windows, see IntelliJ IDEA Web Help .
How to Create a Tool Window?
The IntelliJ IDEA core provides the toolWindow extension point that you can use to create and configure your custom tool windows. This extension point is declared using the ToolWindowEP bean class.
To create a tool window, you should develop a plugin that declares an extension to the toolWindow extension point.
Creation of Plugin
To create a plugin that displays a custom tool window, perform the following principal steps:
- In your plugin project, create a Java class that implements the ToolWindowFactory interface.
- In this class, override the
This method specifies the content for your tool window.
- In the plugin configuration file plugin.xml, create the <extensions defaultExtensionNs="com.intellij"> </extensions> section.
- To this section, add the <toolWindow> element, and for this element, set the following attributes declared in the
- id (required): specifies the tool window caption.
- anchor (required): specifies the tool window bar where the tool window button will be displayed. Possible values: "left", "right", "top", "bottom."
- secondary (optional): when
true, the tool window button will be shown on the lower part of the tool window bar. Default value is
- factoryClass (required): specifies the Java class implementing the
ToolWindowFactoryinterface (see Step 1).
- icon (optional): specifies path to the icon that identifies the tool window, if any.
- conditionClass (optional): specifies a Java class that implements the
com.intellij.openapi.util.Conditioninterface. Using this class, you can define conditions to be met to display tool window button. In the
Conditionclass, you should override the
valuemethod: if this method returns
false, the tool window button is not displayed on tool window bar.
To clarify the above procedure, consider the following fragment of the plugin.xml file:
<extensions defaultExtensionNs="com.intellij"> <toolWindow id="My Sample Tool Window" icon="/myPackage/icon.png" anchor="right" factoryClass="myPackage.MyToolWindowFactory"> </toolWindow> </extensions>
To clarify how to develop your plugins that create tool windows, consider the toolWindow sample plugin available in the <%IDEA Community Edition source code%>/samples/toolWindow> directory. This plugin creates the Sample Calendar tool window that displays the system date, time and time zone.
To run toolWindow plugin
- Start IntelliJ IDEA and open the toolWindow project saved into the samples/toolWindow directory in the IntelliJ IDEA Community Edition source code.
- Ensure that the project settings are valid for your environment. If necessary, modify the project settings.
To view or modify the project settings, on the toolbar, click , and then complete the Project Structure dialog box that opens.
- Run the plugin by choosing the Run | Run on the main menu.
If necessary, change the Run/Debug Configurations .
The plugin creates the Sample Calendar tool window. When opened, this tool window is similar to the following screen: