答案 0 :(得分:2)
要显示这样的弹出窗口,请使用ToolWindowManager.getInstance(project).notifyByBalloon()
。
答案 1 :(得分:1)
如果您想了解VcsNotifier.java
插件中的工作原理,可以检查git4idea
。
以下是通知操作的示例,但是如果您有权访问project
,则可以在任何地方使用此代码:
NotificationExample.java
public class NotificationExample extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
ServiceManager.getService(project, NotificationExample.class).notify(project);
}
private void notify(Project project) {
NotificationGroup notificationGroup = NotificationGroup.toolWindowGroup(
"IdMessages", ChangesViewContentManager.TOOLWINDOW_ID);
Notification notification = notificationGroup.createNotification("Title", "Message", NotificationType.INFORMATION, null);
notification.notify(project);
}
}
plugin.xml
<extensions defaultExtensionNs="com.intellij">
<projectService serviceImplementation="your.package.NotificationExample"/>
</extensions>