notifications: Only propagate ACTIVATE events to HyperlinkListener
authorEldar Abusalimov <eldar.abusalimov@jetbrains.com>
Thu, 17 Nov 2016 12:16:43 +0000 (15:16 +0300)
committerEldar Abusalimov <eldar.abusalimov@jetbrains.com>
Thu, 17 Nov 2016 12:37:37 +0000 (15:37 +0300)
Don't react to hover events (ENTERED/EXITED) since this is hardly
desired behaviour for a hyperlink inside an error balloon, not to say
it is error prone.

platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java

index f31feeb120491434b98e7934a18ca6dfaa953f69..9da721f92bb3c35c89065cbdf6cb6057114dfbd8 100644 (file)
@@ -23,7 +23,6 @@ import com.intellij.execution.process.ProcessNotCreatedException;
 import com.intellij.execution.ui.RunContentDescriptor;
 import com.intellij.ide.DataManager;
 import com.intellij.ide.util.PropertiesComponent;
-import com.intellij.notification.Notification;
 import com.intellij.notification.NotificationGroup;
 import com.intellij.notification.NotificationListener;
 import com.intellij.notification.NotificationType;
@@ -130,9 +129,8 @@ public class ExecutionUtil {
       else {
         Messages.showErrorDialog(project, UIUtil.toHtml(fullMessage), "");
       }
-      NotificationListener notificationListener = finalListener == null ? null : new NotificationListener() {
-        @Override
-        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
+      NotificationListener notificationListener = finalListener == null ? null : (notification, event) -> {
+        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
           finalListener.hyperlinkUpdate(event);
         }
       };
index 23d98a492b9bbb4781d237ebc69c902316d87c59..05f0dfb59792a46819bdd72dba80fecd9e9e66a0 100644 (file)
@@ -73,6 +73,7 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -935,7 +936,11 @@ public class XDebugSessionImpl implements XDebugSession {
 
   @Override
   public void reportMessage(@NotNull final String message, @NotNull final MessageType type, @Nullable final HyperlinkListener listener) {
-    NotificationListener notificationListener = listener == null ? null : (notification, event) -> listener.hyperlinkUpdate(event);
+    NotificationListener notificationListener = listener == null ? null : (notification, event) -> {
+      if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+        listener.hyperlinkUpdate(event);
+      }
+    };
     NOTIFICATION_GROUP.createNotification("", message, type.toNotificationType(), notificationListener).notify(myProject);
   }