js debugger: show error message if breakpoint is set inside html event handler
authornik <Nikolay.Chashnikov@jetbrains.com>
Wed, 10 Mar 2010 12:24:56 +0000 (15:24 +0300)
committernik <Nikolay.Chashnikov@jetbrains.com>
Wed, 10 Mar 2010 12:25:44 +0000 (15:25 +0300)
platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XBreakpointManager.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java

index 116e6bf01ce32f098544253aef917e6ec6ecc3ab..75b8e47bf94bcb871303a1d60a70d0ba6ee2e9b8 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
 import java.util.Collection;
 
 /**
@@ -62,4 +63,6 @@ public interface XBreakpointManager {
   void addBreakpointListener(@NotNull XBreakpointListener<XBreakpoint<?>> listener);
   void removeBreakpointListener(@NotNull XBreakpointListener<XBreakpoint<?>> listener);
   void addBreakpointListener(@NotNull XBreakpointListener<XBreakpoint<?>> listener, @NotNull Disposable parentDisposable);
+
+  void updateBreakpointPresentation(@NotNull XLineBreakpoint<?> breakpoint, @Nullable Icon icon, @Nullable String errorMessage);
 }
index c1c257f9307d078f8a97a57a3d2135d154a82875..ccae800efd12846930b3e6823b2ef8a05d04a48c 100644 (file)
@@ -34,6 +34,7 @@ import com.intellij.xdebugger.impl.XDebuggerManagerImpl;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
 import java.util.*;
 
 /**
@@ -230,6 +231,14 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
     myAllBreakpointsDispatcher.addListener(listener, parentDisposable);
   }
 
+  public void updateBreakpointPresentation(@NotNull XLineBreakpoint<?> breakpoint, @Nullable Icon icon, @Nullable String errorMessage) {
+    final CustomizedBreakpointPresentation presentation = new CustomizedBreakpointPresentation();
+    presentation.setErrorMessage(errorMessage);
+    presentation.setIcon(icon);
+    ((XLineBreakpointImpl)breakpoint).setCustomizedPresentation(presentation);
+    myLineBreakpointManager.queueBreakpointUpdate(breakpoint);
+  }
+
   public BreakpointManagerState getState() {
     myDependentBreakpointManager.saveState();
     BreakpointManagerState state = new BreakpointManagerState();
index c22575755bfcf769c329d2cdee79d4a952865f49..72460c7fff04f0f4412a1bff58a17bb8351d9a1b 100644 (file)
@@ -58,6 +58,7 @@ public class XLineBreakpointImpl<P extends XBreakpointProperties> extends XBreak
   private XSourcePosition mySourcePosition;
   @NonNls private static final String BR_NBSP = "<br>&nbsp;";
   private boolean myDisposed;
+  private CustomizedBreakpointPresentation myCustomizedPresentation;
 
   public XLineBreakpointImpl(final XLineBreakpointType<P> type, XBreakpointManagerImpl breakpointManager, String url, int line, final @Nullable P properties) {
     super(type, breakpointManager, properties, new LineBreakpointState<P>(true, type.getId(), url, line));
@@ -141,15 +142,15 @@ public class XLineBreakpointImpl<P extends XBreakpointProperties> extends XBreak
         }
       }
     }
+    if (myCustomizedPresentation != null) {
+      final Icon icon = myCustomizedPresentation.getIcon();
+      if (icon != null) {
+        return icon;
+      }
+    }
     return myType.getEnabledIcon();
   }
 
-  @Nullable
-  private CustomizedBreakpointPresentation getCustomizedPresentation() {
-    final XDebugSessionImpl currentSession = getBreakpointManager().getDebuggerManager().getCurrentSession();
-    return currentSession != null ? currentSession.getBreakpointPresentation(this) : null;
-  }
-
   public int getLine() {
     return myState.getLine();
   }
@@ -270,8 +271,15 @@ public class XLineBreakpointImpl<P extends XBreakpointProperties> extends XBreak
 
   @Nullable
   private String getErrorMessage() {
-    CustomizedBreakpointPresentation presentation = getCustomizedPresentation();
-    return presentation != null ? presentation.getErrorMessage() : null;
+    final XDebugSessionImpl currentSession = getBreakpointManager().getDebuggerManager().getCurrentSession();
+    if (currentSession != null) {
+      CustomizedBreakpointPresentation presentation = currentSession.getBreakpointPresentation(this);
+      if (presentation != null) {
+        final String message = presentation.getErrorMessage();
+        if (message != null) return message;
+      }
+    }
+    return myCustomizedPresentation != null ? myCustomizedPresentation.getErrorMessage() : null;
   }
 
   public void updatePosition() {
@@ -289,6 +297,10 @@ public class XLineBreakpointImpl<P extends XBreakpointProperties> extends XBreak
     }
   }
 
+  public void setCustomizedPresentation(CustomizedBreakpointPresentation presentation) {
+    myCustomizedPresentation = presentation;
+  }
+
   @Tag("line-breakpoint")
   public static class LineBreakpointState<P extends XBreakpointProperties> extends XBreakpointBase.BreakpointState<XLineBreakpoint<P>, P, XLineBreakpointType<P>> {
     private String myFileUrl;