private Icon calcIcon(@Nullable DebugProcessImpl debugProcess) {
    final boolean muted = debugProcess != null && isMuted(debugProcess);
    if (!isEnabled()) {
      return getDisabledIcon(muted);
    }

    myInvalidMessage = "";

    if (!isValid()) {
      return getInvalidIcon(muted);
    }

    if (debugProcess == null) {
      return getSetIcon(muted);
    }

    final RequestManagerImpl requestsManager = debugProcess.getRequestsManager();

    final boolean isVerified = myCachedVerifiedState || requestsManager.isVerified(this);

    final String warning = requestsManager.getWarning(this);
    if (warning != null) {
      myInvalidMessage = warning;
      if (!isVerified) {
        return getInvalidIcon(muted);
      }
      return getVerifiedWarningsIcon(muted);
    }

    if (isVerified) {
      return getVerifiedIcon(muted);
    }

    return getSetIcon(muted);
  }
 public void fireBreakpointChanged(Breakpoint breakpoint) {
   breakpoint.reload();
   breakpoint.updateUI();
   RequestManagerImpl.updateRequests(breakpoint);
   if (myAllowMulticasting) {
     // can be invoked from non-AWT thread
     myAlarm.cancelAllRequests();
     final Runnable runnable =
         new Runnable() {
           @Override
           public void run() {
             myAlarm.addRequest(
                 new Runnable() {
                   @Override
                   public void run() {
                     myDispatcher.getMulticaster().breakpointsChanged();
                   }
                 },
                 100);
           }
         };
     if (ApplicationManager.getApplication().isDispatchThread()) {
       runnable.run();
     } else {
       SwingUtilities.invokeLater(runnable);
     }
   }
 }
 // interaction with RequestManagerImpl
 public void disableBreakpoints(@NotNull final DebugProcessImpl debugProcess) {
   final List<Breakpoint> breakpoints = getBreakpoints();
   if (!breakpoints.isEmpty()) {
     final RequestManagerImpl requestManager = debugProcess.getRequestsManager();
     for (Breakpoint breakpoint : breakpoints) {
       breakpoint.markVerified(requestManager.isVerified(breakpoint));
       requestManager.deleteRequest(breakpoint);
     }
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             updateBreakpointsUI();
           }
         });
   }
 }
  public static List<Pair<Breakpoint, Event>> getEventDescriptors(
      SuspendContextImpl suspendContext) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    if (suspendContext == null || suspendContext.getEventSet() == null) {
      return Collections.emptyList();
    }
    final List<Pair<Breakpoint, Event>> eventDescriptors = new ArrayList<Pair<Breakpoint, Event>>();

    final RequestManagerImpl requestManager = suspendContext.getDebugProcess().getRequestsManager();
    for (final Event event : suspendContext.getEventSet()) {
      Requestor requestor = requestManager.findRequestor(event.request());
      if (requestor instanceof Breakpoint) {
        eventDescriptors.add(new Pair<Breakpoint, Event>((Breakpoint) requestor, event));
      }
    }
    return eventDescriptors;
  }
 // used in Fabrique
 public synchronized void addBreakpoint(@NotNull Breakpoint breakpoint) {
   myBreakpoints.put(breakpoint.myXBreakpoint, breakpoint);
   myBreakpointsListForIteration = null;
   breakpoint.updateUI();
   RequestManagerImpl.createRequests(breakpoint);
   myDispatcher.getMulticaster().breakpointsChanged();
   if (breakpoint instanceof MethodBreakpoint || breakpoint instanceof WildcardMethodBreakpoint) {
     XDebugSessionImpl.NOTIFICATION_GROUP
         .createNotification(
             "Method breakpoints may dramatically slow down debugging", MessageType.WARNING)
         .notify(myProject);
   }
 }
 public void createRequest(DebugProcessImpl debugProcess) {
   DebuggerManagerThreadImpl.assertIsManagerThread();
   if (!ENABLED
       || !debugProcess.isAttached()
       || debugProcess.areBreakpointsMuted()
       || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
     return;
   }
   try {
     RequestManagerImpl requestManager = debugProcess.getRequestsManager();
     if (WATCH_ENTRY) {
       MethodEntryRequest entryRequest =
           (MethodEntryRequest) findRequest(debugProcess, MethodEntryRequest.class);
       if (entryRequest == null) {
         entryRequest = requestManager.createMethodEntryRequest(this);
       } else {
         entryRequest.disable();
       }
       entryRequest.addClassFilter(myClassPattern);
       debugProcess.getRequestsManager().enableRequest(entryRequest);
     }
     if (WATCH_EXIT) {
       MethodExitRequest exitRequest =
           (MethodExitRequest) findRequest(debugProcess, MethodExitRequest.class);
       if (exitRequest == null) {
         exitRequest = requestManager.createMethodExitRequest(this);
       } else {
         exitRequest.disable();
       }
       exitRequest.addClassFilter(myClassPattern);
       debugProcess.getRequestsManager().enableRequest(exitRequest);
     }
   } catch (Exception e) {
     LOG.debug(e);
   }
 }
  private synchronized void onBreakpointRemoved(@Nullable final XBreakpoint xBreakpoint) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (xBreakpoint == null) {
      return;
    }

    Breakpoint breakpoint = myBreakpoints.remove(xBreakpoint);
    if (breakpoint != null) {
      // updateBreakpointRules(breakpoint);
      myBreakpointsListForIteration = null;
      // we delete breakpoints inside release, so gutter will not fire events to deleted breakpoints
      breakpoint.delete();

      RequestManagerImpl.deleteRequests(breakpoint);
      myDispatcher.getMulticaster().breakpointsChanged();
    }
  }
  public void applyThreadFilter(
      @NotNull final DebugProcessImpl debugProcess, @Nullable ThreadReference newFilterThread) {
    final RequestManagerImpl requestManager = debugProcess.getRequestsManager();
    final ThreadReference oldFilterThread = requestManager.getFilterThread();
    if (Comparing.equal(newFilterThread, oldFilterThread)) {
      // the filter already added
      return;
    }
    requestManager.setFilterThread(newFilterThread);
    if (newFilterThread == null || oldFilterThread != null) {
      final List<Breakpoint> breakpoints = getBreakpoints();
      for (Breakpoint breakpoint : breakpoints) {
        if (LineBreakpoint.CATEGORY.equals(breakpoint.getCategory())
            || MethodBreakpoint.CATEGORY.equals(breakpoint.getCategory())) {
          requestManager.deleteRequest(breakpoint);
          breakpoint.createRequest(debugProcess);
        }
      }
    } else {
      // important! need to add filter to _existing_ requests, otherwise Requestor->Request mapping
      // will be lost
      // and debugger trees will not be restored to original state
      abstract class FilterSetter<T extends EventRequest> {
        void applyFilter(@NotNull final List<T> requests, final ThreadReference thread) {
          for (T request : requests) {
            try {
              final boolean wasEnabled = request.isEnabled();
              if (wasEnabled) {
                request.disable();
              }
              addFilter(request, thread);
              if (wasEnabled) {
                request.enable();
              }
            } catch (InternalException e) {
              LOG.info(e);
            }
          }
        }

        protected abstract void addFilter(final T request, final ThreadReference thread);
      }

      final EventRequestManager eventRequestManager = requestManager.getVMRequestManager();

      new FilterSetter<BreakpointRequest>() {
        @Override
        protected void addFilter(
            @NotNull final BreakpointRequest request, final ThreadReference thread) {
          request.addThreadFilter(thread);
        }
      }.applyFilter(eventRequestManager.breakpointRequests(), newFilterThread);

      new FilterSetter<MethodEntryRequest>() {
        @Override
        protected void addFilter(
            @NotNull final MethodEntryRequest request, final ThreadReference thread) {
          request.addThreadFilter(thread);
        }
      }.applyFilter(eventRequestManager.methodEntryRequests(), newFilterThread);

      new FilterSetter<MethodExitRequest>() {
        @Override
        protected void addFilter(
            @NotNull final MethodExitRequest request, final ThreadReference thread) {
          request.addThreadFilter(thread);
        }
      }.applyFilter(eventRequestManager.methodExitRequests(), newFilterThread);
    }
  }
 public void delete() {
   RequestManagerImpl.deleteRequests(this);
 }