From b4190e49d67297fc09757b0d81ea11d5ababca10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Mon, 21 Aug 2023 16:47:29 +0200 Subject: [PATCH] tool_windows.md: add TW FAQ section --- .../user_interface_components/notifications.md | 6 ++++-- .../user_interface_components/tool_windows.md | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/topics/user_interface_components/notifications.md b/topics/user_interface_components/notifications.md index 2be06a142..6bf1fe9fa 100644 --- a/topics/user_interface_components/notifications.md +++ b/topics/user_interface_components/notifications.md @@ -1,7 +1,7 @@ - - # Notifications + + Notifying users about errors, action statuses or other events without interrupting their workflow by showing modal message boxes requiring confirmation. @@ -52,6 +52,8 @@ It has two main advantages: For UI reference, see [Balloon](https://jetbrains.design/intellij/controls/balloon/) in the IntelliJ Platform UI Guidelines. +> See [](tool_windows.md#tool-window-notification) for showing balloons on specific tool window. + The specific method used to display a notification is [`Notifications.Bus.notify()`](%gh-ic%/platform/ide-core/src/com/intellij/notification/Notifications.java). If the current Project is known, please use overload with `Project` parameter, so the notification is shown in its associated frame. diff --git a/topics/user_interface_components/tool_windows.md b/topics/user_interface_components/tool_windows.md index dd9899d05..b7a51feb7 100644 --- a/topics/user_interface_components/tool_windows.md +++ b/topics/user_interface_components/tool_windows.md @@ -24,8 +24,6 @@ There are two main scenarios for the use of tool windows in a plugin. Using [declarative setup](#declarative-setup), a tool window button is always visible, and the user can activate it and interact with the plugin functionality at any time. Alternatively, using [programmatic setup](#programmatic-setup), the tool window is created to show the results of a specific operation, and can then be closed after the operation is completed. -Project-level topic [`ToolWindowManagerListener`](%gh-ic%/platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerListener.java) allows listening to tool window (un-)registering/show events (see [](plugin_listeners.md)). - ### Declarative Setup The tool window is registered in [plugin.xml](plugin_configuration_file.md) using the `com.intellij.toolWindow` extension point. @@ -94,11 +92,25 @@ The default value is `false`; calling `setClosable(true)` on `ContentManager` co If closing tabs is enabled in general, a plugin can disable closing of specific tabs by calling [`Content.setCloseable(false)`](%gh-ic%/platform/ide-core/src/com/intellij/ui/content/Content.java). +## Tool Window FAQ + +### Accessing Tool Window + +Use [`ToolWindowManager.getToolWindow()`](%gh-ic%/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.kt) specifying the `id` used for [registration](#declarative-setup). + +### Tool Window Notification + +[`ToolWindowManager.notifyByBalloon()`](%gh-ic%/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.kt) allows showing a notification for the given tool window. + +### Events + +Project-level topic [`ToolWindowManagerListener`](%gh-ic%/platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerListener.java) allows listening to tool window registration/show events (see [](plugin_listeners.md)). + ## Sample Plugin To clarify how to develop plugins that create tool windows, consider the **toolWindow** sample plugin available in the [code samples](%gh-sdk-samples%/tool_window). -See [Code Samples](code_samples.md) on how to set up and run the plugin. +See [](code_samples.md) on how to set up and run the plugin. This plugin creates the Sample Calendar tool window that displays the system date, time and time zone. When opened, this tool window is similar to the following screen: