HTML link in com.intellij.notification.NotificationGroup#createNotification

I must be doing a simple mistake. How can I insert a link in a notification that can be opened by clicking? When I use e.g.

<a href="https://github.com/halirutan/Mathematica-IntelliJ-Plugin/issues/78">Created issue #78</a>

it is correctly rendered as link, but clicking on doesn't do anything. Other links like the ones I have in my documentation popups do work.

Cheers
Patrick

0
2 comments

It doesn't automatically open the browser - you can use the links to do any action, eg open dialogs or whatever. This is how I do it (although possibly I'm completely wrong):

def notification = notificationGroup.createNotification("...", message,
NotificationType.INFORMATION, new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
if (e.description == "mac") {
BrowserLauncher.getInstance().open("https://someurl")
} else if (e.description == "attach-source") {
...
}
}
})

The e.description is the href of the link.

There is probably an existing NotificationListener that does what you would expect, but not at my machine atm so can't look for it.

1
Avatar
Permanently deleted user

Hey Jamie,

thank you for the pointer! There is indeed and existing listener. This here

  ReportMessages.GROUP.createNotification(
ReportMessages.ERROR_REPORT,
reportInfo.getLinkText(),
NotificationType.INFORMATION,
NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(myProject);

works like a charm.

Thanks again
Patrick

1

Please sign in to leave a comment.