mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
+5
-5
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.process;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class ProcessHandlerFactory {
|
||||
|
||||
public static ProcessHandlerFactory getInstance() {
|
||||
return ServiceManager.getService(ProcessHandlerFactory.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of the {@link OSProcessHandler}.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract OSProcessHandler createProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException;
|
||||
|
||||
/**
|
||||
* Returns a new instance of the {@link OSProcessHandler} which is aware of ANSI coloring output.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract OSProcessHandler createColoredProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException;
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.process;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ProcessHandlerFactoryImpl extends ProcessHandlerFactory {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OSProcessHandler createProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
|
||||
return new OSProcessHandler(commandLine);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public OSProcessHandler createColoredProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
|
||||
return new ColoredProcessHandler(commandLine);
|
||||
}
|
||||
}
|
||||
@@ -215,6 +215,9 @@
|
||||
|
||||
<applicationService serviceInterface="com.intellij.ide.UiActivityMonitor" serviceImplementation="com.intellij.ide.UiActivityMonitorImpl"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.execution.process.ProcessHandlerFactory"
|
||||
serviceImplementation="com.intellij.execution.process.ProcessHandlerFactoryImpl" />
|
||||
|
||||
<projectService serviceInterface="com.intellij.openapi.vfs.ReadonlyStatusHandler"
|
||||
serviceImplementation="com.intellij.openapi.vcs.readOnlyHandler.ReadonlyStatusHandlerImpl"/>
|
||||
<projectService serviceInterface="com.intellij.openapi.startup.StartupManager"
|
||||
|
||||
Reference in New Issue
Block a user