use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.
the class ConsoleViewImplTest method createConsole.
@NotNull
static ConsoleViewImpl createConsole() {
Project project = getProject();
ConsoleViewImpl console = new ConsoleViewImpl(project, GlobalSearchScope.allScope(project), false, false);
// initConsoleEditor()
console.getComponent();
ProcessHandler processHandler = new NopProcessHandler();
processHandler.startNotify();
console.attachToProcess(processHandler);
return console;
}
use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.
the class RunContentManagerImpl method showRunContent.
private void showRunContent(@NotNull final Executor executor, @NotNull final RunContentDescriptor descriptor, final long executionId) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
return;
}
final ContentManager contentManager = getContentManagerForRunner(executor, descriptor);
RunContentDescriptor oldDescriptor = chooseReuseContentForDescriptor(contentManager, descriptor, executionId, descriptor.getDisplayName());
final Content content;
if (oldDescriptor == null) {
content = createNewContent(descriptor, executor);
} else {
content = oldDescriptor.getAttachedContent();
LOG.assertTrue(content != null);
getSyncPublisher().contentRemoved(oldDescriptor, executor);
// is of the same category, can be reused
Disposer.dispose(oldDescriptor);
}
content.setExecutionId(executionId);
content.setComponent(descriptor.getComponent());
content.setPreferredFocusedComponent(descriptor.getPreferredFocusComputable());
content.putUserData(RunContentDescriptor.DESCRIPTOR_KEY, descriptor);
content.putUserData(EXECUTOR_KEY, executor);
content.setDisplayName(descriptor.getDisplayName());
descriptor.setAttachedContent(content);
String toolWindowId = getToolWindowIdForRunner(executor, descriptor);
final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId);
final ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null) {
final ProcessAdapter processAdapter = new ProcessAdapter() {
@Override
public void startNotified(final ProcessEvent event) {
UIUtil.invokeLaterIfNeeded(() -> {
content.setIcon(ExecutionUtil.getLiveIndicator(descriptor.getIcon()));
toolWindow.setIcon(ExecutionUtil.getLiveIndicator(myToolwindowIdToBaseIconMap.get(toolWindowId)));
});
}
@Override
public void processTerminated(final ProcessEvent event) {
ApplicationManager.getApplication().invokeLater(() -> {
boolean alive = false;
ContentManager manager = myToolwindowIdToContentManagerMap.get(toolWindowId);
if (manager == null)
return;
for (Content content1 : manager.getContents()) {
RunContentDescriptor descriptor1 = getRunContentDescriptorByContent(content1);
if (descriptor1 != null) {
ProcessHandler handler = descriptor1.getProcessHandler();
if (handler != null && !handler.isProcessTerminated()) {
alive = true;
break;
}
}
}
Icon base = myToolwindowIdToBaseIconMap.get(toolWindowId);
toolWindow.setIcon(alive ? ExecutionUtil.getLiveIndicator(base) : base);
Icon icon = descriptor.getIcon();
content.setIcon(icon == null ? executor.getDisabledIcon() : IconLoader.getTransparentIcon(icon));
});
}
};
processHandler.addProcessListener(processAdapter);
final Disposable disposer = content.getDisposer();
if (disposer != null) {
Disposer.register(disposer, new Disposable() {
@Override
public void dispose() {
processHandler.removeProcessListener(processAdapter);
}
});
}
}
if (oldDescriptor == null) {
contentManager.addContent(content);
new CloseListener(content, executor);
}
content.getManager().setSelectedContent(content);
if (!descriptor.isActivateToolWindowWhenAdded()) {
return;
}
ApplicationManager.getApplication().invokeLater(() -> {
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId);
// let's activate tool window, but don't move focus
//
// window.show() isn't valid here, because it will not
// mark the window as "last activated" windows and thus
// some action like navigation up/down in stacktrace wont
// work correctly
descriptor.getPreferredFocusComputable();
window.activate(descriptor.getActivationCallback(), descriptor.isAutoFocusContent(), descriptor.isAutoFocusContent());
}, myProject.getDisposed());
}
use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.
the class RunContentManagerImpl method isTerminated.
public static boolean isTerminated(@NotNull Content content) {
RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
return processHandler == null || processHandler.isProcessTerminated();
}
use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.
the class FakeRerunAction method isEnabled.
protected boolean isEnabled(AnActionEvent event) {
RunContentDescriptor descriptor = getDescriptor(event);
ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
ExecutionEnvironment environment = getEnvironment(event);
return environment != null && !ExecutorRegistry.getInstance().isStarting(environment) && !(processHandler != null && processHandler.isProcessTerminating());
}
use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.
the class RunTab method initLogConsoles.
protected final void initLogConsoles(@NotNull RunProfile runConfiguration, @NotNull RunContentDescriptor contentDescriptor, @Nullable ExecutionConsole console) {
ProcessHandler processHandler = contentDescriptor.getProcessHandler();
if (runConfiguration instanceof RunConfigurationBase) {
RunConfigurationBase configuration = (RunConfigurationBase) runConfiguration;
if (myManager == null) {
myManager = new LogFilesManager(myProject, getLogConsoleManager(), contentDescriptor);
}
myManager.addLogConsoles(configuration, processHandler);
if (processHandler != null) {
OutputFileUtil.attachDumpListener(configuration, processHandler, console);
}
}
}
Aggregations