(六)IntelliJ 插件开发—— Notifications

2020-03-05  本文已影响0人  秋水畏寒

官方文档

https://www.jetbrains.org/intellij/sdk/docs/user_interface_components/notifications.html
https://www.jetbrains.org/intellij/sdk/docs/tutorials/editor_basics/working_with_text.html

Github

https://github.com/kungyutucheng/my_gradle_plugin

运行环境

macOS 10.14.5
IntelliJ idea 2019.2.4

1、Dialogs

对话框式通知,请移步(四)IntelliJ 插件开发——Dialog(对话框)中的“校验不通过”图片


2、Editor Hints

这块比较简单,直接上代码

showErrorHint

showErrorHint
HintManager.getInstance().showErrorHint(CommonDataKeys.EDITOR.getData(e.getDataContext()),"错误信息");

showQuestionHint

showQuestionHint
HintManager.getInstance().showQuestionHint(CommonDataKeys.EDITOR.getData(e.getDataContext()), "questionAction", 0, 0, () -> {
    Messages.showMessageDialog("question", "Question", Messages.getInformationIcon());
    return true;
});
showInformationHint
showInformationHint
HintManager.getInstance().showInformationHint(CommonDataKeys.EDITOR.getData(e.getDataContext()),"information");

3、Top-Level Notifications

这是最常用的用于非模态框式通知方式
主要有以下俩个优势:

notification
event log 设置通知展示方式
NotificationGroup notificationGroup = new NotificationGroup("notificationGroup", NotificationDisplayType.BALLOON, true);
Notification notification = notificationGroup.createNotification("notification",NotificationType.ERROR);
Notifications.Bus.notify(notification);

其中,NotificationGroup构造方法如下:

public NotificationGroup(@NotNull String displayId, @NotNull NotificationDisplayType defaultDisplayType, boolean logByDefault) {
    this(displayId, defaultDisplayType, logByDefault, null);
 }

其中,NotificationDisplayType可以是以下几种:

上一篇 下一篇

猜你喜欢

热点阅读