@Override
  public void update(@NotNull AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    presentation.putClientProperty(ExecutorActionStatus.KEY, null); // by default
    Project project = e.getProject();
    if (project == null || !project.isInitialized() || project.isDisposed()) {
      presentation.setEnabled(false);
      return;
    }

    RunManager runManager = RunManager.getInstanceIfCreated(project);
    if (runManager == null) {
      presentation.setEnabled(false);
      return;
    }

    RunnerAndConfigurationSettings selectedSettings = getSelectedConfiguration(e);
    boolean enabled = false;
    ExecutorActionStatus actionStatus = null;
    boolean runConfigAsksToHideDisabledExecutorButtons = false;
    String text;
    if (selectedSettings != null) {
      if (DumbService.isDumb(project) && !selectedSettings.getType().isDumbAware()) {
        presentation.setEnabled(false);
        return;
      }

      actionStatus = setupActionStatus(e, project, selectedSettings, presentation);
      presentation.setIcon(getInformativeIcon(project, selectedSettings, e));
      RunConfiguration configuration = selectedSettings.getConfiguration();
      Ref<Boolean> isStartingTracker = Ref.create(false);
      if (!isSuppressed(project)) {
        enabled = ExecutorRegistryImpl.RunnerHelper.canRun(project, myExecutor, configuration, isStartingTracker);
        if (enabled && isStartingTracker.get() == Boolean.TRUE) {
          enabled = false;
          presentation.putClientProperty(WOULD_BE_ENABLED_BUT_STARTING, true);
        }
      }
      if (!(configuration instanceof CompoundRunConfiguration)) {
        runConfigAsksToHideDisabledExecutorButtons = configuration.hideDisabledExecutorButtons();
      }
      if (enabled) {
        presentation.setDescription(myExecutor.getDescription());
      }

      if (ExperimentalUI.isNewUI() &&
          needRerunPresentation(selectedSettings.getConfiguration(), getRunningDescriptors(project, selectedSettings))) {
        if (myExecutor.getId().equals(DefaultRunExecutor.EXECUTOR_ID)) {
          text = ExecutionBundle.message("run.toolbar.widget.rerun.text", configuration);
        }
        else {
          text = ExecutionBundle.message("run.toolbar.widget.restart.text", myExecutor.getActionName(), configuration.getName());
        }
      }
      else {
        text = myExecutor.getStartActionText(configuration.getName());
      }
    }
    else {
      if (RunConfigurationsComboBoxAction.hasRunCurrentFileItem(project)) {
        // don't compute current file to run if editors are not yet loaded
        if (!project.isDefault() && !StartupManager.getInstance(project).postStartupActivityPassed()) {
          presentation.setEnabled(false);
          return;
        }

        RunCurrentFileActionStatus status = getRunCurrentFileActionStatus(e, false);
        for (RunnerAndConfigurationSettings config : status.myRunConfigs) {
          actionStatus = setupActionStatus(e, project, config, presentation);
          if (actionStatus != ExecutorActionStatus.NORMAL) {
            break;
          }
        }
        enabled = status.enabled;
        text = status.tooltip;
        presentation.setIcon(status.icon);
      }
      else {
        text = getTemplatePresentation().getTextWithMnemonic();
      }
    }

    if (actionStatus != ExecutorActionStatus.LOADING && runConfigAsksToHideDisabledExecutorButtons) {
      presentation.setEnabledAndVisible(enabled);
    }
    else {
      presentation.setEnabled(enabled);
    }

    if (presentation.isVisible()) {
      presentation.setVisible(myExecutor.isApplicable(project));
    }
    presentation.putClientProperty(ExecutorActionStatus.KEY, actionStatus);
    presentation.setText(text);
  }
@Override
  public void update(@NotNull AnActionEvent e)