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);
}
}
}
}
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);
}
}
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();
});
}
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;
}
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;
}
Aggregations