diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java b/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java index 71dd853d0722..7eaf9c1754d5 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java @@ -102,7 +102,7 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab properties, TestConsoleProperties.OPEN_FAILURE_LINE)).setAsSecondary(true); actionGroup.addAction(new ShowStatisticsAction(properties)).setAsSecondary(true); - actionGroup.addAction(new AdjustAutotestDelayActionGroup(environment)).setAsSecondary(true); + actionGroup.addAction(new AdjustAutotestDelayActionGroup(environment.getProject(), parent)).setAsSecondary(true); for (ToggleModelActionProvider actionProvider : Extensions.getExtensions(ToggleModelActionProvider.EP_NAME)) { final ToggleModelAction toggleModelAction = actionProvider.createToggleModelAction(properties); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AdjustAutotestDelayActionGroup.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AdjustAutotestDelayActionGroup.java index c6536cdb0f61..4b8a2ffa75ec 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AdjustAutotestDelayActionGroup.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AdjustAutotestDelayActionGroup.java @@ -15,30 +15,42 @@ */ package com.intellij.execution.testframework.autotest; -import com.intellij.execution.runners.ExecutionEnvironment; -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.execution.ui.RunContentDescriptor; +import com.intellij.ide.DataManager; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; + /** * @author Dennis.Ushakov */ public class AdjustAutotestDelayActionGroup extends ActionGroup { public static final int MAX_DELAY = 10; - private final ExecutionEnvironment myEnvironment; + private final Project myProject; + private final DataContext myDataContext; - public AdjustAutotestDelayActionGroup(ExecutionEnvironment environment) { + public AdjustAutotestDelayActionGroup(@NotNull Project project, @NotNull JComponent parent) { super("Set AutoTest Delay", true); - myEnvironment = environment; + myProject = project; + myDataContext = DataManager.getInstance().getDataContext(parent); } @Override public void update(AnActionEvent e) { - e.getPresentation().setVisible(Boolean.TRUE == myEnvironment.getUserData(AutoTestManager.AUTOTESTABLE)); + RunContentDescriptor descriptor = LangDataKeys.RUN_CONTENT_DESCRIPTOR.getData(myDataContext); + boolean visible = false; + if (descriptor != null) { + for (AnAction action : descriptor.getRestartActions()) { + if (action instanceof ToggleAutoTestAction) { + visible = true; + break; + } + } + } + e.getPresentation().setVisible(visible); } @NotNull @@ -46,7 +58,7 @@ public class AdjustAutotestDelayActionGroup extends ActionGroup { public AnAction[] getChildren(@Nullable AnActionEvent e) { final AnAction[] actions = new AnAction[MAX_DELAY]; for (int i = 0; i < MAX_DELAY; i++) { - actions[i] = new SetAutoTestDelayAction(myEnvironment.getProject(), i + 1); + actions[i] = new SetAutoTestDelayAction(myProject, i + 1); } return actions; } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java index b02adb8c0c67..cb7cc00f0276 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java @@ -47,7 +47,6 @@ import javax.swing.*; * @author yole */ public class AutoTestManager { - static final Key AUTOTESTABLE = Key.create("auto.test.manager.supported"); private static final String AUTO_TEST_MANAGER_DELAY = "auto.test.manager.delay"; private static final Key ON_TERMINATION_RESTARTER_KEY = Key.create("auto.test.manager.on.termination.restarter"); private static final Key EXECUTION_ENVIRONMENT_KEY = Key.create("auto.test.manager.execution.environment"); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java index 8338625e34ec..1031ed63644e 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java @@ -13,10 +13,19 @@ import com.intellij.openapi.project.Project; * @author yole */ public class ToggleAutoTestAction extends ToggleAction { + /** + * @deprecated use default constructor instead + * @param environment + * To be removed in IDEA 16 + */ + @Deprecated public ToggleAutoTestAction(ExecutionEnvironment environment) { + this(); + } + + public ToggleAutoTestAction() { super("Toggle auto-test", "Toggle automatic rerun of tests on code changes", AllIcons.Actions.SwapPanels); - environment.putUserData(AutoTestManager.AUTOTESTABLE, true); } @Override