@Override
  public void update(final @NotNull AnActionEvent e) {
    boolean enable = false;
    Icon icon = getActionIcon(e);
    String description = getTemplatePresentation().getDescription();
    Presentation presentation = e.getPresentation();
    if (isPlaceGlobal(e)) {
      List<RunContentDescriptor> stoppableDescriptors = getActiveStoppableDescriptors(e.getProject());
      int stopCount = stoppableDescriptors.size();
      enable = stopCount >= 1;

      if (!enable && e.getPlace().equals(ActionPlaces.NEW_UI_RUN_TOOLBAR)) {
        presentation.setEnabledAndVisible(false);
        return;
      }

      if (stopCount > 1) {
        presentation.setText(getTemplatePresentation().getText() + "...");
        String text = RunToolbarPopupKt.runCounterToString(e, stopCount);
        icon = IconUtil.addText(icon, text);
      }
      else if (stopCount == 1) {
          presentation.setText(ExecutionBundle.messagePointer("stop.configuration.action.name",
                                                       StringUtil.escapeMnemonics(
                                                         StringUtil.notNullize(stoppableDescriptors.get(0).getDisplayName()))));
      }
    }
    else {
      RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
      ProcessHandler processHandler = contentDescriptor == null ? null : contentDescriptor.getProcessHandler();
      if (processHandler != null && !processHandler.isProcessTerminated()) {
        if (!processHandler.isProcessTerminating()) {
          enable = true;
        }
        else if (processHandler instanceof KillableProcess && ((KillableProcess)processHandler).canKillProcess()) {
          enable = true;
          icon = AllIcons.Debugger.KillProcess;
          description = ExecutionBundle.message("action.terminating.process.progress.kill.description");
        }
      }

      RunProfile runProfile = e.getData(LangDataKeys.RUN_PROFILE);
      if (runProfile == null && contentDescriptor == null) {
        presentation.setText(getTemplatePresentation().getText());
      }
      else {
        presentation.setText(ExecutionBundle.messagePointer("stop.configuration.action.name",
                                                     StringUtil.escapeMnemonics(runProfile == null
                                                                                ? StringUtil.notNullize(contentDescriptor.getDisplayName())
                                                                                : runProfile.getName())));
      }
    }

    presentation.setEnabled(enable);
    presentation.setIcon(icon);
    presentation.setDescription(description);
  }
@Override
  public void update(final @NotNull AnActionEvent e)