void (@NotNull AnActionEvent e) { Presentation presentation = e.getPresentation(); Project project = e.getProject(); if (project == null || !project.isInitialized() || project.isDisposed()) { presentation.setEnabled(false); return; } RunnerAndConfigurationSettings selectedSettings = getSelectedConfiguration(e); boolean enabled = false; boolean isLoading = false; boolean runConfigAsksToHideDisabledExecutorButtons = false; String text; if (selectedSettings != null) { if (DumbService.isDumb(project) && !selectedSettings.getType().isDumbAware()) { presentation.setEnabled(false); return; } // We can consider to add spinning to the inlined run actions. But there is a problem with redrawing if (ActionPlaces.NEW_UI_RUN_TOOLBAR.equals(e.getPlace())) { RunStatusHistory startHistory = RunStatusHistory.getInstance(project); isLoading = startHistory.firstOrNull(selectedSettings, it -> (it.getExecutorId().equals(myExecutor.getId()) && it.getState() == RunState.SCHEDULED) ) != null; if (isLoading) { presentation.putClientProperty(ExecutorActionStatus.KEY, ExecutorActionStatus.LOADING); SpinningProgressIcon spinningIcon = presentation.getClientProperty(spinningIconKey); if (spinningIcon == null) { spinningIcon = new SpinningProgressIcon(); spinningIcon.setIconColor(JBUI.CurrentTheme.RunWidget.ICON_COLOR); presentation.putClientProperty(spinningIconKey, spinningIcon); } presentation.setDisabledIcon(spinningIcon); } else { if (!getRunningDescriptors(project, selectedSettings).isEmpty()) { presentation.putClientProperty(ExecutorActionStatus.KEY, ExecutorActionStatus.RUNNING); } else { presentation.putClientProperty(ExecutorActionStatus.KEY, ExecutorActionStatus.NORMAL); } presentation.putClientProperty(spinningIconKey, null); presentation.setDisabledIcon(null); } } presentation.setIcon(getInformativeIcon(project, selectedSettings, e)); RunConfiguration configuration = selectedSettings.getConfiguration(); if (!isSuppressed(project)) { enabled = RunnerHelper.canRun(project, myExecutor, configuration); } 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)) { RunCurrentFileActionStatus status = getRunCurrentFileActionStatus(e, false); enabled = status.myEnabled; text = status.myTooltip; presentation.setIcon(status.myIcon); } else { text = getTemplatePresentation().getTextWithMnemonic(); } } if (!isLoading && (runConfigAsksToHideDisabledExecutorButtons || hideDisabledExecutorButtons())) { presentation.setEnabledAndVisible(enabled); } else { presentation.setEnabled(enabled); } if (presentation.isVisible()) { presentation.setVisible(myExecutor.isApplicable(project)); } presentation.setText(text); }