blob: 893ddb320aabf02a46d2b7785847f545c2216b39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package com.intellij.execution.testframework.autotest;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunContentManager;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.Project;
/**
* @author yole
*/
public class ToggleAutoTestAction extends ToggleAction {
public ToggleAutoTestAction(ExecutionEnvironment environment) {
super("Toggle auto-test", "Toggle automatic rerun of tests on code changes",
AllIcons.Actions.SwapPanels);
environment.putUserData(AutoTestManager.AUTOTESTABLE, true);
}
@Override
public boolean isSelected(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
RunContentDescriptor descriptor = e.getData(RunContentManager.RUN_CONTENT_DESCRIPTOR);
return !(project == null || descriptor == null) && AutoTestManager.getInstance(project).isAutoTestEnabled(descriptor);
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
Project project = e.getData(CommonDataKeys.PROJECT);
RunContentDescriptor descriptor = e.getData(RunContentManager.RUN_CONTENT_DESCRIPTOR);
if (project != null && descriptor != null) {
AutoTestManager.getInstance(project).setAutoTestEnabled(descriptor, state);
}
}
}
|