Search in sources :

Example 1 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.

the class TerminalProcessHandler method notifyTextAvailable.

@Override
public void notifyTextAvailable(String text, Key outputType) {
    if (ProcessOutputTypes.SYSTEM.equals(outputType)) {
        super.notifyTextAvailable(text, outputType);
    } else {
        terminalOutputCapturer.onTextAvailable(new ProcessEvent(this, text), outputType);
        text = filterText(text);
        if (!StringUtil.isEmpty(text)) {
            StringBuilder lastLine = getLastLineFor(outputType);
            String currentLine = lastLine.append(text).toString();
            lastLine.setLength(0);
            currentLine = filterCombinedText(currentLine);
            // check if current line presents some interactive output
            boolean handled = handlePrompt(currentLine, outputType);
            if (!handled) {
                notify(currentLine, outputType, lastLine);
            }
        }
    }
}
Also used : ProcessEvent(com.intellij.execution.process.ProcessEvent)

Example 2 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.

the class PydevConsoleRunnerImpl method connect.

private void connect(final String[] statements2execute) {
    if (handshake()) {
        ApplicationManager.getApplication().invokeLater(() -> {
            // Propagate console communication to language console
            final PythonConsoleView consoleView = myConsoleView;
            consoleView.setConsoleCommunication(myPydevConsoleCommunication);
            consoleView.setSdk(mySdk);
            consoleView.setExecutionHandler(myConsoleExecuteActionHandler);
            myProcessHandler.addProcessListener(new ProcessAdapter() {

                @Override
                public void onTextAvailable(ProcessEvent event, Key outputType) {
                    consoleView.print(event.getText(), outputType);
                }
            });
            if (myEnableAfterConnection) {
                enableConsoleExecuteAction();
            }
            for (String statement : statements2execute) {
                consoleView.executeStatement(statement + "\n", ProcessOutputTypes.SYSTEM);
            }
            fireConsoleInitializedEvent(consoleView);
            consoleView.initialized();
        });
    } else {
        myConsoleView.print("Couldn't connect to console process.", ProcessOutputTypes.STDERR);
        myProcessHandler.destroyProcess();
        myConsoleView.setEditable(false);
    }
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) Key(com.intellij.openapi.util.Key)

Example 3 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.

the class PydevConsoleRunnerImpl method initAndRun.

private void initAndRun() throws ExecutionException {
    // Create Server process
    final Process process = createProcess();
    UIUtil.invokeLaterIfNeeded(() -> {
        // Init console view
        myConsoleView = createConsoleView();
        if (myConsoleView != null) {
            ((JComponent) myConsoleView).setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT));
        }
        myProcessHandler = createProcessHandler(process);
        myConsoleExecuteActionHandler = createExecuteActionHandler();
        ProcessTerminatedListener.attach(myProcessHandler);
        PythonConsoleView consoleView = myConsoleView;
        myProcessHandler.addProcessListener(new ProcessAdapter() {

            @Override
            public void processTerminated(ProcessEvent event) {
                consoleView.setEditable(false);
            }
        });
        // Attach to process
        myConsoleView.attachToProcess(myProcessHandler);
        createContentDescriptorAndActions();
        // Run
        myProcessHandler.startNotify();
    });
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) RemoteProcess(com.intellij.remote.RemoteProcess) XDebugProcess(com.intellij.xdebugger.XDebugProcess) SideBorder(com.intellij.ui.SideBorder)

Example 4 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.

the class RestCommandLineState method doCreateProcess.

protected ProcessHandler doCreateProcess(GeneralCommandLine commandLine) throws ExecutionException {
    final Runnable afterTask = getAfterTask();
    ProcessHandler processHandler = PythonProcessRunner.createProcess(commandLine, false);
    if (afterTask != null) {
        processHandler.addProcessListener(new ProcessAdapter() {

            public void processTerminated(ProcessEvent event) {
                SwingUtilities.invokeLater(afterTask);
            }
        });
    }
    return processHandler;
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Example 5 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project intellij-community by JetBrains.

the class PyCCCommandLineState method doCreateProcess.

@Override
protected ProcessHandler doCreateProcess(GeneralCommandLine commandLine) throws ExecutionException {
    ProcessHandler handler = super.doCreateProcess(commandLine);
    handler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            ApplicationManager.getApplication().invokeLater(() -> EduUtils.deleteWindowDescriptions(myTask, myTaskDir));
        }
    });
    return handler;
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Aggregations

ProcessEvent (com.intellij.execution.process.ProcessEvent)90 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)82 Key (com.intellij.openapi.util.Key)34 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)25 NotNull (org.jetbrains.annotations.NotNull)24 ExecutionException (com.intellij.execution.ExecutionException)22 ProcessHandler (com.intellij.execution.process.ProcessHandler)18 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)16 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)12 IOException (java.io.IOException)12 Nullable (org.jetbrains.annotations.Nullable)12 Project (com.intellij.openapi.project.Project)9 File (java.io.File)9 ProcessListener (com.intellij.execution.process.ProcessListener)8 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)7 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)5 ProgramRunner (com.intellij.execution.runners.ProgramRunner)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)4 Disposable (com.intellij.openapi.Disposable)4