Introduce a factory to create various ProcessHandlers

To be able to move implementations from api to impl,
in particular the ColoredProcessHandler.
This commit is contained in:
Kirill Likhodedov
2016-10-20 20:18:32 +03:00
parent bc3380370a
commit 5b6df18bd2
4 changed files with 84 additions and 5 deletions
@@ -16,14 +16,11 @@
package com.intellij.execution.configurations;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.process.ColoredProcessHandler;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.process.ProcessHandlerFactory;
import com.intellij.execution.process.ProcessTerminatedListener;
import org.jetbrains.annotations.NotNull;
/**
* @author spleaner
*/
public class JavaCommandLineStateUtil {
private JavaCommandLineStateUtil() { }
@@ -34,7 +31,10 @@ public class JavaCommandLineStateUtil {
@NotNull
public static OSProcessHandler startProcess(@NotNull GeneralCommandLine commandLine, boolean ansiColoring) throws ExecutionException {
OSProcessHandler processHandler = ansiColoring ? new ColoredProcessHandler(commandLine) : new OSProcessHandler(commandLine);
ProcessHandlerFactory factory = ProcessHandlerFactory.getInstance();
OSProcessHandler processHandler = ansiColoring ?
factory.createColoredProcessHandler(commandLine) :
factory.createProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}