本文整理匯總了Java中com.intellij.execution.process.ProcessHandler類的典型用法代碼示例。如果您正苦於以下問題:Java ProcessHandler類的具體用法?Java ProcessHandler怎麽用?Java ProcessHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ProcessHandler類屬於com.intellij.execution.process包,在下文中一共展示了ProcessHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showHelperProcessRunContent
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
public static final ConsoleView showHelperProcessRunContent(String header, OSProcessHandler runHandler, Project project, Executor defaultExecutor) {
ProcessTerminatedListener.attach(runHandler);
ConsoleViewImpl consoleView = new ConsoleViewImpl(project, true);
DefaultActionGroup toolbarActions = new DefaultActionGroup();
JPanel panel = new JPanel((LayoutManager) new BorderLayout());
panel.add((Component) consoleView.getComponent(), "Center");
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("unknown", (ActionGroup) toolbarActions, false);
toolbar.setTargetComponent(consoleView.getComponent());
panel.add((Component) toolbar.getComponent(), "West");
RunContentDescriptor runDescriptor = new RunContentDescriptor((ExecutionConsole) consoleView,
(ProcessHandler) runHandler, (JComponent) panel, header, AllIcons.RunConfigurations.Application);
AnAction[]
consoleActions = consoleView.createConsoleActions();
toolbarActions.addAll((AnAction[]) Arrays.copyOf(consoleActions, consoleActions.length));
toolbarActions.add((AnAction) new StopProcessAction("Stop process", "Stop process", (ProcessHandler) runHandler));
toolbarActions.add((AnAction) new CloseAction(defaultExecutor, runDescriptor, project));
consoleView.attachToProcess((ProcessHandler) runHandler);
// ExecutionManager.getInstance(environment.getProject()).getContentManager().showRunContent(environment.getExecutor(), runDescriptor);
showConsole(project, defaultExecutor, runDescriptor);
return (ConsoleView) consoleView;
}
示例2: createToolWindowContent
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow toolWindow) {
SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
BsConsole console = new BsConsole(project);
panel.setContent(console.getComponent());
ActionToolbar toolbar = console.createToolbar();
panel.setToolbar(toolbar.getComponent());
Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true);
toolWindow.getContentManager().addContent(content);
// Start compiler
BsCompiler bsc = BucklescriptProjectComponent.getInstance(project).getCompiler();
if (bsc != null) {
bsc.addListener(new BsOutputListener(project));
ProcessHandler handler = bsc.getHandler();
if (handler == null) {
console.print("Bsb not found, check the event logs.", ERROR_OUTPUT);
} else {
console.attachToProcess(handler);
}
bsc.startNotify();
}
}
示例3: createAdditionalTabComponents
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@Override
public void createAdditionalTabComponents(final AdditionalTabComponentManager manager, ProcessHandler startedProcess) {
if (myOutputType == OutputType.CONSOLE) {
final HighlightingOutputConsole console = new HighlightingOutputConsole(getProject(), myFileType);
XsltCommandLineState state = startedProcess.getUserData(XsltCommandLineState.STATE);
boolean debug = state != null && state.isDebugger();
boolean consoleTabAdded = false;
for (XsltRunnerExtension extension : XsltRunnerExtension.getExtensions(this, debug)) {
if (extension.createTabs(getProject(), manager, console, startedProcess)) {
consoleTabAdded = true;
}
}
if (!consoleTabAdded) {
manager.addAdditionalTabComponent(console, console.getTabTitle()); // TODO: verify parameter
}
final OutputTabAdapter listener = new OutputTabAdapter(startedProcess, console);
if (startedProcess.isStartNotified()) {
listener.startNotified(new ProcessEvent(startedProcess));
}
else {
startedProcess.addProcessListener(listener);
}
}
}
示例4: createListener
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
private void createListener(@NotNull RunContentDescriptor descriptor, Integer descriptorHashCode) {
DebugSessionInfo sessionInfo = new DebugSessionInfo("run/debug");
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null) {
ExecutionConsole console = descriptor.getExecutionConsole();
if (console instanceof ConsoleView) {
ConsoleViewImpl impl = extractConsoleImpl((ConsoleView) console);
if (impl != null) {
new ConsoleWatcher(myProject, impl, sessionInfo);
}
}
final LogScannerFactory scannerFactory = new StackTraceMatcherFactory(myProject, sessionInfo);
RunDebugAdapter listener = new RunDebugAdapter(scannerFactory);
listeners.put(descriptorHashCode, listener);
debugSessionIds.put(descriptorHashCode, sessionInfo);
processHandler.addProcessListener(listener);
TrackingService.trace(IdeaRawEvent.debugStart(myProject, sessionInfo));
}
}
示例5: tryToCloseOldSessions
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
private static void tryToCloseOldSessions(final Executor executor, Project project) {
final ExecutionManager manager = ExecutionManager.getInstance(project);
ProcessHandler[] processes = manager.getRunningProcesses();
for (ProcessHandler process : processes) {
final AndroidSessionInfo info = process.getUserData(ANDROID_SESSION_INFO);
if (info != null) {
process.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
manager.getContentManager().removeRunContent(executor, info.getDescriptor());
}
});
}
});
process.detachProcess();
}
}
}
示例6: getCopyOfCompilerManifestFile
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@Nullable
protected static Pair<File, String> getCopyOfCompilerManifestFile(@NotNull AndroidFacet facet, @Nullable ProcessHandler processHandler) {
final VirtualFile manifestFile = AndroidRootUtil.getCustomManifestFileForCompiler(facet);
if (manifestFile == null) {
return null;
}
File tmpDir = null;
try {
tmpDir = FileUtil.createTempDirectory("android_manifest_file_for_execution", "tmp");
final File manifestCopy = new File(tmpDir, manifestFile.getName());
FileUtil.copy(new File(manifestFile.getPath()), manifestCopy);
//noinspection ConstantConditions
return Pair.create(manifestCopy, PathUtil.getLocalPath(manifestFile));
}
catch (IOException e) {
if (processHandler != null) {
processHandler.notifyTextAvailable("I/O error: " + e.getMessage(), ProcessOutputTypes.STDERR);
}
LOG.info(e);
if (tmpDir != null) {
FileUtil.delete(tmpDir);
}
return null;
}
}
示例7: stopProcess
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
public static void stopProcess(@Nullable ProcessHandler processHandler) {
if (processHandler instanceof KillableProcess && processHandler.isProcessTerminating()) {
// process termination was requested, but it's still alive
// in this case 'force quit' will be performed
((KillableProcess)processHandler).killProcess();
return;
}
if (processHandler != null) {
if (processHandler.detachIsDefault()) {
processHandler.detachProcess();
}
else {
processHandler.destroyProcess();
}
}
}
示例8: createDebugProcess
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@NotNull
@Override
protected PyDebugProcess createDebugProcess(@NotNull XDebugSession session,
ServerSocket serverSocket,
ExecutionResult result,
PythonCommandLineState pyState) {
ExecutionConsole executionConsole = result.getExecutionConsole();
ProcessHandler processHandler = result.getProcessHandler();
boolean isMultiProcess = pyState.isMultiprocessDebug();
String scriptName = getScriptName(pyState);
if (scriptName != null) {
VirtualFile file = VfsUtil.findFileByIoFile(new File(scriptName), true);
if (file != null) {
int line = getBreakpointLineNumber(file, session.getProject());
if (line != NO_LINE) {
return new PyEduDebugProcess(session, serverSocket,
executionConsole, processHandler,
isMultiProcess, scriptName, line + 1);
}
}
}
LOG.info("Failed to create PyEduDebugProcess. PyDebugProcess created instead.");
return new PyDebugProcess(session, serverSocket, executionConsole,
processHandler, isMultiProcess);
}
示例9: restartRunProfile
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@Override
public void restartRunProfile(@NotNull Project project,
@NotNull Executor executor,
@NotNull ExecutionTarget target,
@Nullable RunnerAndConfigurationSettings configuration,
@Nullable ProcessHandler processHandler) {
ExecutionEnvironmentBuilder builder = createEnvironmentBuilder(project, executor, configuration);
if (processHandler != null) {
for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) {
if (descriptor.getProcessHandler() == processHandler) {
builder.contentToReuse(descriptor);
break;
}
}
}
restartRunProfile(builder.target(target).build());
}
示例10: actionPerformed
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
RunContentDescriptor descriptor = StopAction.getRecentlyStartedContentDescriptor(e.getDataContext());
ProcessHandler activeProcessHandler = descriptor != null ? descriptor.getProcessHandler() : null;
if (activeProcessHandler == null || activeProcessHandler.isProcessTerminated()) return;
try {
OutputStream input = activeProcessHandler.getProcessInput();
if (input != null) {
ConsoleView console = e.getData(LangDataKeys.CONSOLE_VIEW);
if (console != null) {
console.print("^D\n", ConsoleViewContentType.SYSTEM_OUTPUT);
}
input.close();
}
}
catch (IOException ignored) {
}
}
示例11: disposeDebugProcess
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@Override
protected void disposeDebugProcess() throws InterruptedException {
if (myDebugProcess != null) {
ProcessHandler processHandler = myDebugProcess.getProcessHandler();
myDebugProcess.stop();
waitFor(processHandler);
if (!processHandler.isProcessTerminated()) {
killDebugProcess();
if (!waitFor(processHandler)) {
new Throwable("Cannot stop debugger process").printStackTrace();
}
}
}
}
示例12: startRemoteProcess
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
public ProcessHandler startRemoteProcess(@NotNull Sdk sdk,
@NotNull GeneralCommandLine commandLine,
@Nullable Project project,
@Nullable PyRemotePathMapper pathMapper)
throws ExecutionException {
PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
if (manager != null) {
PyRemoteProcessHandlerBase processHandler;
try {
processHandler = doStartRemoteProcess(sdk, commandLine, manager, project, pathMapper);
}
catch (ExecutionException e) {
final Application application = ApplicationManager.getApplication();
if (application != null && (application.isUnitTestMode() || application.isHeadlessEnvironment())) {
throw new RuntimeException(e);
}
throw new ExecutionException("Can't run remote python interpreter: " + e.getMessage(), e);
}
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
else {
throw new PythonRemoteInterpreterManager.PyRemoteInterpreterExecutionException();
}
}
示例13: setAutoTestEnabled
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
public void setAutoTestEnabled(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment, boolean enabled) {
Content content = descriptor.getAttachedContent();
if (content != null) {
if (enabled) {
EXECUTION_ENVIRONMENT_KEY.set(content, environment);
myDocumentWatcher.activate();
}
else {
EXECUTION_ENVIRONMENT_KEY.set(content, null);
if (!hasEnabledAutoTests()) {
myDocumentWatcher.deactivate();
}
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null) {
clearRestarterListener(processHandler);
}
}
}
}
示例14: startProcess
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
// here just run one command: python freeline.py
GeneralCommandLine commandLine = new GeneralCommandLine();
ExecutionEnvironment environment = getEnvironment();
commandLine.setWorkDirectory(environment.getProject().getBasePath());
commandLine.setExePath("npm");
commandLine.addParameters("list");
return new OSProcessHandler(commandLine);
}
示例15: startProcess
import com.intellij.execution.process.ProcessHandler; //導入依賴的package包/類
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
String scriptPath = runConfiguration.getScriptPath();
String scriptParameters = runConfiguration.getScriptParameters();
String scriptOptions = runConfiguration.getScriptOptions();
scriptPath = scriptPath == null ? "" : scriptPath;//todo change this (and add validator to run config)
final List<String> commandString = new ArrayList<>();
commandString.add("/usr/bin/osascript");
if (!StringUtil.isEmpty(scriptOptions)) {
String[] options = scriptOptions.split(" ");
commandString.addAll(Arrays.asList(options));
}
commandString.add(scriptPath);
if (!StringUtil.isEmpty(scriptParameters)) {
Pattern regex = Pattern.compile("\"([^\"]*)\"|(\\w+)");
final ArrayList<String> matchedParams = new ArrayList<>();
Matcher matcher = regex.matcher(scriptParameters);
while (matcher.find()) {
for (int i = 1; i <= matcher.groupCount(); i++) {
try {
String p = matcher.group(i);
if (!StringUtil.isEmpty(p)) matchedParams.add(p);
} catch (IllegalStateException | IndexOutOfBoundsException e) {
LOG.warn("Error parsing script parameters: " + e.getMessage());
}
}
}
commandString.addAll(matchedParams);
}
final GeneralCommandLine commandLine = new GeneralCommandLine(commandString);
if (runConfiguration.isShowAppleEvents()) {
commandLine.withEnvironment("AEDebugSends", "1");
commandLine.withEnvironment("AEDebugReceives", "1");
}
return new AppleScriptProcessHandler(commandLine);
}