use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class PydevConsoleRunnerImpl method showErrorsInConsole.
private void showErrorsInConsole(Exception e) {
DefaultActionGroup actionGroup = new DefaultActionGroup(createRerunAction());
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, false);
// Runner creating
final JPanel panel = new JPanel(new BorderLayout());
panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
NewErrorTreeViewPanel errorViewPanel = new NewErrorTreeViewPanel(myProject, null, false, false, null);
String[] messages = StringUtil.isNotEmpty(e.getMessage()) ? StringUtil.splitByLines(e.getMessage()) : ArrayUtil.EMPTY_STRING_ARRAY;
if (messages.length == 0) {
messages = new String[] { "Unknown error" };
}
errorViewPanel.addMessage(MessageCategory.ERROR, messages, null, -1, -1, null);
panel.add(errorViewPanel, BorderLayout.CENTER);
final RunContentDescriptor contentDescriptor = new RunContentDescriptor(null, myProcessHandler, panel, "Error running console");
actionGroup.add(createCloseAction(contentDescriptor));
showContentDescriptor(contentDescriptor);
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class PythonConsoleToolWindow method resetContent.
private static void resetContent(RunContentDescriptor contentDescriptor, SimpleToolWindowPanel panel, Content content) {
RunContentDescriptor oldDescriptor = content.getDisposer() instanceof RunContentDescriptor ? (RunContentDescriptor) content.getDisposer() : null;
if (oldDescriptor != null)
Disposer.dispose(oldDescriptor);
panel.setContent(contentDescriptor.getComponent());
content.setComponent(panel);
content.setDisposer(contentDescriptor);
content.setPreferredFocusableComponent(contentDescriptor.getComponent());
content.putUserData(CONTENT_DESCRIPTOR, contentDescriptor);
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class ConfigurationBasedProcessRunner method runProcess.
@Override
final void runProcess(@NotNull final String sdkPath, @NotNull final Project project, @NotNull final ProcessListener processListener, @NotNull final String tempWorkingPath) throws ExecutionException {
ensureConsoleOk(myConsole);
// Do not create new environment from factory, if child provided environment to rerun
final ExecutionEnvironment executionEnvironment = // TODO: RENAME
(myRerunExecutionEnvironment != null ? myRerunExecutionEnvironment : createExecutionEnvironment(sdkPath, project, tempWorkingPath));
// Engine to be run after process end to post process console
final ProcessListener consolePostprocessor = new ProcessAdapter() {
@Override
public void processTerminated(final ProcessEvent event) {
super.processTerminated(event);
ApplicationManager.getApplication().invokeAndWait(() -> prepareConsoleAfterProcessEnd(), ModalityState.NON_MODAL);
}
};
/// Find all available runners to report them to the test
myAvailableRunnersForLastRun.clear();
for (final ProgramRunner<?> runner : ProgramRunner.PROGRAM_RUNNER_EP.getExtensions()) {
for (final Executor executor : Executor.EXECUTOR_EXTENSION_NAME.getExtensions()) {
if (runner.canRun(executor.getId(), executionEnvironment.getRunProfile())) {
myAvailableRunnersForLastRun.add(runner);
}
}
}
executionEnvironment.getRunner().execute(executionEnvironment, new ProgramRunner.Callback() {
@Override
public void processStarted(final RunContentDescriptor descriptor) {
final ProcessHandler handler = descriptor.getProcessHandler();
assert handler != null : "No process handler";
handler.addProcessListener(consolePostprocessor);
handler.addProcessListener(processListener);
myConsole = null;
fetchConsoleAndSetToField(descriptor);
assert myConsole != null : "fetchConsoleAndSetToField did not set console!";
// Console does not work with out of this method
final JComponent component = myConsole.getComponent();
assert component != null;
myLastProcessDescriptor = descriptor;
}
});
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class PyExecuteSelectionAction method startConsole.
private static void startConsole(final Project project, final Consumer<PyCodeExecutor> consumer, Module context) {
final PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(project);
if (toolWindow != null && toolWindow.getConsoleContentDescriptors().size() > 0) {
toolWindow.activate(() -> {
List<RunContentDescriptor> descs = toolWindow.getConsoleContentDescriptors();
RunContentDescriptor descriptor = descs.get(0);
if (descriptor != null && descriptor.getExecutionConsole() instanceof PyCodeExecutor) {
consumer.consume((PyCodeExecutor) descriptor.getExecutionConsole());
}
});
} else {
PythonConsoleRunnerFactory consoleRunnerFactory = PythonConsoleRunnerFactory.getInstance();
PydevConsoleRunner runner = consoleRunnerFactory.createConsoleRunner(project, null);
runner.addConsoleListener(new PydevConsoleRunner.ConsoleListener() {
@Override
public void handleConsoleInitialized(LanguageConsoleView consoleView) {
if (consoleView instanceof PyCodeExecutor) {
consumer.consume((PyCodeExecutor) consoleView);
if (toolWindow != null) {
toolWindow.getToolWindow().show(null);
}
}
}
});
runner.run();
}
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class PyExecuteSelectionAction method getConsoles.
private static Collection<RunContentDescriptor> getConsoles(Project project) {
PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(project);
if (toolWindow != null && toolWindow.getToolWindow().isVisible()) {
RunContentDescriptor selectedContentDescriptor = toolWindow.getSelectedContentDescriptor();
return selectedContentDescriptor != null ? Lists.newArrayList(selectedContentDescriptor) : Lists.newArrayList();
}
Collection<RunContentDescriptor> descriptors = ExecutionHelper.findRunningConsole(project, dom -> dom.getExecutionConsole() instanceof PyCodeExecutor && isAlive(dom));
if (descriptors.isEmpty() && toolWindow != null) {
return toolWindow.getConsoleContentDescriptors();
} else {
return descriptors;
}
}
Aggregations