void (Notification notification, @Nullable Project project) { if (LOG.isDebugEnabled()) LOG.debug("incoming: " + notification + ", project=" + project); if (myEarlyNotifications != null) { myEarlyNotifications.add(new Pair<>(notification, project)); return; } String groupId = notification.getGroupId(); NotificationSettings settings = NotificationsConfigurationImpl.getSettings(groupId); NotificationDisplayType type = settings.getDisplayType(); String toolWindowId = notification.getToolWindowId(); if (toolWindowId == null) { toolWindowId = NotificationsConfigurationImpl.getInstanceImpl().getToolWindowId(groupId); } if (type == NotificationDisplayType.TOOL_WINDOW && (toolWindowId == null || project == null || !ToolWindowManager.getInstance(project).canShowNotification(toolWindowId))) { type = NotificationDisplayType.BALLOON; } if (notification.isShowingPopupSuppressed()) { type = NotificationDisplayType.NONE; if (LOG.isDebugEnabled()) LOG.debug("showing popup is suppressed for the notification"); } switch (type) { case NONE -> { if (LOG.isDebugEnabled()) LOG.debug("not shown (type=NONE): " + notification); } case STICKY_BALLOON, BALLOON -> { Balloon balloon = notifyByBalloon(notification, type, project); if (balloon == null && LOG.isDebugEnabled()) LOG.debug("not shown (no balloon): " + notification); if (project != null && !project.isDefault() && (!settings.isShouldLog() || type == NotificationDisplayType.STICKY_BALLOON)) { if (balloon == null) { notification.expire(); } else { balloon.addListener(new JBPopupListener() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { if (!event.isOk()) { notification.expire(); } } }); } } } case TOOL_WINDOW -> { MessageType messageType = notification.getType() == NotificationType.ERROR ? MessageType.ERROR : notification.getType() == NotificationType.WARNING ? MessageType.WARNING : MessageType.INFO; String messageBody = notification.getTitle(); HyperlinkListener listener = null; String content = notification.getContent(); if (!content.isEmpty()) { if (!messageBody.isEmpty()) messageBody += HtmlChunk.br(); messageBody += content; } List<AnAction> actions = notification.getActions(); Map<String, AnAction> actionListeners = new HashMap<>(); if (!actions.isEmpty()) { messageBody += HtmlChunk.br(); for (int index = 0; index < actions.size(); index++) { AnAction action = actions.get(index); String text = action.getTemplatePresentation().getText(); if (text != null) { String linkTarget = "notification-action-" + index + "for-tool-window-" + System.identityHashCode(notification); actionListeners.put(linkTarget, action); //noinspection StringConcatenationInLoop messageBody += HtmlChunk.link(linkTarget, text); messageBody += ' '; } } } Window window = findWindowForBalloon(project); if (window instanceof IdeFrame) { BalloonLayout layout = ((IdeFrame)window).getBalloonLayout(); if (layout != null) { ((BalloonLayoutImpl)layout).remove(notification); } } NotificationListener notificationListener = notification.getListener(); if (notificationListener != null || !actionListeners.isEmpty()) { listener = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { AnAction action = actionListeners.get(e.getDescription()); if (action != null) { Object source = e.getSource(); DataContext context = source instanceof Component ? DataManager.getInstance().getDataContext((Component)source) : null; if (source instanceof JComponent component) { Notification.setDataProvider(notification, component); } Notification.fire(notification, action, context); NotificationCollector.getInstance() .logNotificationActionInvoked(project, notification, action, NotificationCollector.NotificationPlace.TOOL_WINDOW); return; } } if (notificationListener != null) { notificationListener.hyperlinkUpdate(notification, e); } } }; } //noinspection SSBasedInspection ToolWindowManager.getInstance(Objects.requireNonNull(project)) .notifyByBalloon(toolWindowId, messageType, messageBody, notification.getIcon(), listener); NotificationCollector.getInstance().logToolWindowNotificationShown(project, notification); } } }