use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.
the class GroovyScriptRunConfiguration method getState.
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
final VirtualFile scriptFile = ScriptFileUtil.findScriptFileByPath(getScriptPath());
if (scriptFile == null)
return null;
final GroovyScriptRunner scriptRunner = getScriptRunner();
if (scriptRunner == null)
return null;
return new JavaCommandLineState(environment) {
@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler handler = super.startProcess();
handler.setShouldDestroyProcessRecursively(true);
if (scriptRunner.shouldRefreshAfterFinish()) {
handler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
if (!ApplicationManager.getApplication().isDisposed()) {
VirtualFileManager.getInstance().asyncRefresh(null);
}
}
});
}
return handler;
}
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
final Module module = getModule();
final boolean tests = ProjectRootManager.getInstance(getProject()).getFileIndex().isInTestSourceContent(scriptFile);
String jrePath = isAlternativeJrePathEnabled() ? getAlternativeJrePath() : null;
JavaParameters params = new JavaParameters();
params.setUseClasspathJar(true);
params.setDefaultCharset(getProject());
params.setJdk(module == null ? JavaParametersUtil.createProjectJdk(getProject(), jrePath) : JavaParametersUtil.createModuleJdk(module, !tests, jrePath));
configureConfiguration(params, new CommonProgramRunConfigurationParametersDelegate(GroovyScriptRunConfiguration.this) {
@Nullable
@Override
public String getProgramParameters() {
return null;
}
});
scriptRunner.configureCommandLine(params, module, tests, scriptFile, GroovyScriptRunConfiguration.this);
return params;
}
};
}
use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.
the class AbstractAutoTestManager method scheduleRestartOnTermination.
private void scheduleRestartOnTermination(@NotNull final RunContentDescriptor descriptor, @NotNull final ProcessHandler processHandler, final int modificationStamp, @NotNull final AutoTestWatcher watcher) {
ProcessListener restarterListener = ON_TERMINATION_RESTARTER_KEY.get(processHandler);
if (restarterListener != null) {
clearRestarterListener(processHandler);
}
restarterListener = new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
clearRestarterListener(processHandler);
ApplicationManager.getApplication().invokeLater(() -> {
if (isAutoTestEnabledForDescriptor(descriptor) && watcher.isUpToDate(modificationStamp)) {
restart(descriptor);
}
}, ModalityState.any());
}
};
ON_TERMINATION_RESTARTER_KEY.set(processHandler, restarterListener);
processHandler.addProcessListener(restarterListener);
}
use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.
the class MavenExecutionTest method execute.
private void execute(final MavenRunnerParameters params) {
final Semaphore sema = new Semaphore();
sema.down();
UIUtil.invokeLaterIfNeeded(() -> MavenRunConfigurationType.runConfiguration(myProject, params, getMavenGeneralSettings(), new MavenRunnerSettings(), new ProgramRunner.Callback() {
@Override
public void processStarted(final RunContentDescriptor descriptor) {
descriptor.getProcessHandler().addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
sema.up();
UIUtil.invokeLaterIfNeeded(() -> Disposer.dispose(descriptor));
}
});
}
}));
sema.waitFor();
}
use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.
the class SnapShooterConfigurationExtension method attachToProcess.
@Override
public void attachToProcess(@NotNull final RunConfigurationBase configuration, @NotNull final ProcessHandler handler, RunnerSettings runnerSettings) {
SnapShooterConfigurationSettings settings = configuration.getUserData(SnapShooterConfigurationSettings.SNAP_SHOOTER_KEY);
if (settings != null) {
final Runnable runnable = settings.getNotifyRunnable();
if (runnable != null) {
settings.setNotifyRunnable(null);
handler.addProcessListener(new ProcessAdapter() {
@Override
public void startNotified(final ProcessEvent event) {
runnable.run();
}
});
}
}
}
use of com.intellij.execution.process.ProcessEvent 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;
}
Aggregations