use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class AbstractRerunFailedTestsAction method execute.
void execute(@NotNull AnActionEvent e, @NotNull ExecutionEnvironment environment) {
MyRunProfile profile = getRunProfile(environment);
if (profile == null) {
return;
}
final ExecutionEnvironmentBuilder environmentBuilder = new ExecutionEnvironmentBuilder(environment).runProfile(profile);
final InputEvent event = e.getInputEvent();
if (!(event instanceof MouseEvent) || !event.isShiftDown()) {
performAction(environmentBuilder);
return;
}
final LinkedHashMap<Executor, ProgramRunner> availableRunners = new LinkedHashMap<>();
for (Executor ex : new Executor[] { DefaultRunExecutor.getRunExecutorInstance(), DefaultDebugExecutor.getDebugExecutorInstance() }) {
final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(ex.getId(), profile);
if (runner != null) {
availableRunners.put(ex, runner);
}
}
if (availableRunners.isEmpty()) {
LOG.error(environment.getExecutor().getActionName() + " is not available now");
} else if (availableRunners.size() == 1) {
//noinspection ConstantConditions
performAction(environmentBuilder.runner(availableRunners.get(environment.getExecutor())));
} else {
final JBList list = new JBList(availableRunners.keySet());
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setSelectedValue(environment.getExecutor(), true);
list.setCellRenderer(new DefaultListCellRenderer() {
@NotNull
@Override
public Component getListCellRendererComponent(@NotNull JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Executor) {
setText(UIUtil.removeMnemonic(((Executor) value).getStartActionText()));
setIcon(((Executor) value).getIcon());
}
return component;
}
});
//noinspection ConstantConditions
JBPopupFactory.getInstance().createListPopupBuilder(list).setTitle("Restart Failed Tests").setMovable(false).setResizable(false).setRequestFocus(true).setItemChoosenCallback(() -> {
final Object value = list.getSelectedValue();
if (value instanceof Executor) {
//noinspection ConstantConditions
performAction(environmentBuilder.runner(availableRunners.get(value)).executor((Executor) value));
}
}).createPopup().showUnderneathOf(event.getComponent());
}
}
use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class MavenRunConfiguration method getState.
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
JavaCommandLineState state = new JavaCommandLineState(env) {
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
return MavenRunConfiguration.this.createJavaParameters(env.getProject());
}
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
DefaultExecutionResult res = (DefaultExecutionResult) super.execute(executor, runner);
if (executor.getId().equals(ToolWindowId.RUN) && MavenResumeAction.isApplicable(env.getProject(), getJavaParameters(), MavenRunConfiguration.this)) {
MavenResumeAction resumeAction = new MavenResumeAction(res.getProcessHandler(), runner, env);
res.setRestartActions(resumeAction);
}
return res;
}
@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
OSProcessHandler result = super.startProcess();
result.setShouldDestroyProcessRecursively(true);
result.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
updateProjectsFolders();
}
});
return result;
}
};
state.setConsoleBuilder(MavenConsoleImpl.createConsoleBuilder(getProject()));
return state;
}
use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class MavenRunConfigurationType method runConfiguration.
public static void runConfiguration(Project project, @NotNull MavenRunnerParameters params, @Nullable MavenGeneralSettings settings, @Nullable MavenRunnerSettings runnerSettings, @Nullable ProgramRunner.Callback callback) {
RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(settings, runnerSettings, params, project);
ProgramRunner runner = DefaultJavaProgramRunner.getInstance();
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
try {
runner.execute(new ExecutionEnvironment(executor, runner, configSettings, project), callback);
} catch (ExecutionException e) {
MavenUtil.showError(project, "Failed to execute Maven goal", e);
}
}
use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class ExternalSystemUtil method createExecutionEnvironment.
@Nullable
public static ExecutionEnvironment createExecutionEnvironment(@NotNull Project project, @NotNull ProjectSystemId externalSystemId, @NotNull ExternalSystemTaskExecutionSettings taskSettings, @NotNull String executorId) {
Executor executor = ExecutorRegistry.getInstance().getExecutorById(executorId);
if (executor == null)
return null;
String runnerId = getRunnerId(executorId);
if (runnerId == null)
return null;
ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(runnerId);
if (runner == null)
return null;
RunnerAndConfigurationSettings settings = createExternalSystemRunnerAndConfigurationSettings(taskSettings, project, externalSystemId);
if (settings == null)
return null;
return new ExecutionEnvironment(executor, runner, settings, project);
}
use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class SearchEverywhereAction method findExecutor.
@Nullable
public Executor findExecutor(@NotNull RunnerAndConfigurationSettings settings) {
final Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();
final Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);
Executor executor = ourShiftIsPressed.get() ? runExecutor : debugExecutor;
RunConfiguration runConf = settings.getConfiguration();
if (executor == null || runConf == null) {
return null;
}
ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), runConf);
if (runner == null) {
executor = runExecutor == executor ? debugExecutor : runExecutor;
}
return executor;
}
Aggregations