Ability to prevent execution of run configuration with special key

com.intellij.execution.ExecutorRegistryImpl.EXECUTION_TEMPORARY_DISABLED

GitOrigin-RevId: 8c110f1499de19e2b946284638486c590bfe5505
This commit is contained in:
Vassiliy.Kudryashov
2019-11-21 15:11:54 +00:00
committed by intellij-monorepo-bot
parent e5b37153d2
commit 78aef36ed7
@@ -24,6 +24,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.*;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Trinity;
import com.intellij.util.IconUtil;
import com.intellij.util.containers.ContainerUtil;
@@ -43,6 +44,9 @@ public final class ExecutorRegistryImpl extends ExecutorRegistry implements Disp
public static final String RUNNERS_GROUP = "RunnerActions";
public static final String RUN_CONTEXT_GROUP = "RunContextGroupInner";
// Usage: project.putUserData(EXECUTION_TEMPORARY_DISABLED, Boolean.TRUE) when there is some 'external' reason that prevents execution
public static final Key<Boolean> EXECUTION_TEMPORARY_DISABLED = Key.create("EXECUTION_TEMPORARY_DISABLED");
private List<Executor> myExecutors = new ArrayList<>();
private final Map<String, Executor> myIdToExecutor = new THashMap<>();
private final Set<String> myContextActionIdSet = new THashSet<>();
@@ -248,8 +252,11 @@ public final class ExecutorRegistryImpl extends ExecutorRegistry implements Disp
public void update(@NotNull final AnActionEvent e) {
final Presentation presentation = e.getPresentation();
final Project project = e.getProject();
if (project == null || !project.isInitialized() || project.isDisposed()) {
if (project != null) {
boolean b = (System.currentTimeMillis() % 10000) > 5000;
project.putUserData(EXECUTION_TEMPORARY_DISABLED, b ? Boolean.TRUE : null);
}
if (project == null || !project.isInitialized() || project.isDisposed() || EXECUTION_TEMPORARY_DISABLED.get(project) == Boolean.TRUE) {
presentation.setEnabled(false);
return;
}