Notifications
One of the leading design principles is avoiding the use of modal message boxes for notifying the user about errors and other situations that may warrant the user's attention. As a replacement, the IntelliJ Platform provides multiple non-modal notification UI options.
Dialogs
When working in a dialog, do not check the validity of the input and notify the user about invalid data with a modal dialog when the OK button is pressed. Instead, use DialogWrapper.doValidate()
described in the Dialogs section.
Editor Hints
For actions invoked from the editor (such as refactorings, navigation actions, and different code insight features), the best way to notify the user about the inability to perform an action is to use the HintManager
class.
Its method showErrorHint()
displays a floating popup above the editor which is automatically hidden when the user starts performing another action in the editor. Other HintManager
methods can be used for displaying other kinds of non-modal notification hints over an editor.
Editor Banner
Notifications that appear at the top of the file editor are a great way to ask the user to take an important action that would otherwise impede their experience if ignored (e.g., missing SDK, setup/project configuration requiring user input).
Register an implementation of EditorNotificationProvider
using com.intellij.editorNotificationProvider
extension point. If access to indexes is not required, it can be marked dumb-aware.
A commonly used UI implementation is EditorNotificationPanel
.
"Got It" Notification
Use to highlight important new/changed features via GotItTooltip
.
Top-Level Notifications (Balloons)
The most general way to display non-modal notifications is to use the Notifications
class.
It has two main advantages:
The user can control the way each notification type is displayed under
All displayed notifications are gathered in the Notifications tool window and can be reviewed later
The specific method used to display a notification is Notifications.Bus.notify()
. If the current Project is known, please use overload with the Project
parameter, so the notification is shown in its associated frame.
The text of the notification can include HTML tags for presentation purposes. Use Notification.addAction(AnAction)
to add links below the content, use NotificationAction
for convenience.
The groupId
parameter of the Notification
constructor specifies a notification type. The user can choose the display type corresponding to each notification type under .
To specify the preferred display type, you need to use NotificationGroup
to create notifications.
Please see the following steps for setup, depending on the target platform version.
NotificationGroup
is registered in plugin.xml using the com.intellij.notificationGroup
extension point. Use key
to provide a localized group display name.
Registered instances can then be obtained via their id
.
NotificationGroup
is registered in code.