use of com.intellij.execution.filters.TextConsoleBuilder in project intellij-community by JetBrains.
the class ToolRunProfile method getState.
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) {
final Project project = env.getProject();
if (myCommandLine == null) {
// can return null if creation of cmd line has been cancelled
return null;
}
final CommandLineState commandLineState = new CommandLineState(env) {
GeneralCommandLine createCommandLine() {
return myCommandLine;
}
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final GeneralCommandLine commandLine = createCommandLine();
final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
@Override
@NotNull
public ExecutionResult execute(@NotNull final Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final ExecutionResult result = super.execute(executor, runner);
final ProcessHandler processHandler = result.getProcessHandler();
if (processHandler != null) {
processHandler.addProcessListener(new ToolProcessAdapter(project, myTool.synchronizeAfterExecution(), getName()));
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if ((outputType == ProcessOutputTypes.STDOUT && myTool.isShowConsoleOnStdOut()) || (outputType == ProcessOutputTypes.STDERR && myTool.isShowConsoleOnStdErr())) {
ExecutionManager.getInstance(project).getContentManager().toFrontRunContent(executor, processHandler);
}
}
});
}
return result;
}
};
TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
final FilterInfo[] outputFilters = myTool.getOutputFilters();
for (FilterInfo outputFilter : outputFilters) {
builder.addFilter(new RegexpFilter(project, outputFilter.getRegExp()));
}
commandLineState.setConsoleBuilder(builder);
return commandLineState;
}
use of com.intellij.execution.filters.TextConsoleBuilder in project intellij-community by JetBrains.
the class RunContentExecutor method createConsole.
private ConsoleView createConsole() {
TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(myProject);
consoleBuilder.filters(myFilterList);
final ConsoleView console = consoleBuilder.getConsole();
if (myHelpId != null) {
console.setHelpId(myHelpId);
}
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
DefaultActionGroup actions = new DefaultActionGroup();
final JComponent consolePanel = createConsolePanel(console, actions);
RunContentDescriptor descriptor = new RunContentDescriptor(console, myProcess, consolePanel, myTitle);
Disposer.register(descriptor, this);
Disposer.register(descriptor, console);
actions.add(new RerunAction(consolePanel));
actions.add(new StopAction());
actions.add(new CloseAction(executor, descriptor, myProject));
ExecutionManager.getInstance(myProject).getContentManager().showRunContent(executor, descriptor);
if (myActivateToolWindow) {
activateToolWindow();
}
return console;
}
use of com.intellij.execution.filters.TextConsoleBuilder in project intellij-community by JetBrains.
the class AnalyzeStacktraceUtil method addConsole.
public static RunContentDescriptor addConsole(Project project, @Nullable ConsoleFactory consoleFactory, final String tabTitle, String text, @Nullable Icon icon) {
final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
builder.filters(Extensions.getExtensions(EP_NAME, project));
final ConsoleView consoleView = builder.getConsole();
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
JComponent consoleComponent = consoleFactory != null ? consoleFactory.createConsoleComponent(consoleView, toolbarActions) : new MyConsolePanel(consoleView, toolbarActions);
final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, null, consoleComponent, tabTitle, icon) {
@Override
public boolean isContentReuseProhibited() {
return true;
}
};
final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
for (AnAction action : consoleView.createConsoleActions()) {
toolbarActions.add(action);
}
final ConsoleViewImpl console = (ConsoleViewImpl) consoleView;
ConsoleViewUtil.enableReplaceActionForConsoleViewEditor(console.getEditor());
console.getEditor().getSettings().setCaretRowShown(true);
toolbarActions.add(new AnnotateStackTraceAction(console.getEditor(), console.getHyperlinks()));
toolbarActions.add(new CloseAction(executor, descriptor, project));
ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor);
consoleView.allowHeavyFilters();
if (consoleFactory == null) {
printStacktrace(consoleView, text);
}
return descriptor;
}
use of com.intellij.execution.filters.TextConsoleBuilder in project intellij-plugins by JetBrains.
the class DartPubActionBase method createConsole.
@NotNull
private static ConsoleView createConsole(@NotNull final Project project, @NotNull final VirtualFile pubspecYamlFile) {
final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
consoleBuilder.setViewer(true);
consoleBuilder.addFilter(new DartConsoleFilter(project, pubspecYamlFile));
consoleBuilder.addFilter(new DartRelativePathsConsoleFilter(project, pubspecYamlFile.getParent().getPath()));
consoleBuilder.addFilter(new UrlFilter());
return consoleBuilder.getConsole();
}
use of com.intellij.execution.filters.TextConsoleBuilder in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoTestRunningState method execute.
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
ProcessHandler processHandler = startProcess();
TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(myConfiguration.getProject());
setConsoleBuilder(consoleBuilder);
GoTestConsoleProperties consoleProperties = new GoTestConsoleProperties(myConfiguration, executor);
String frameworkName = myConfiguration.getTestFramework().getName();
ConsoleView consoleView = SMTestRunnerConnectionUtil.createAndAttachConsole(frameworkName, processHandler, consoleProperties);
consoleView.addMessageFilter(new GoConsoleFilter(myConfiguration.getProject(), myModule, myConfiguration.getWorkingDirectoryUrl()));
ProcessTerminatedListener.attach(processHandler);
DefaultExecutionResult executionResult = new DefaultExecutionResult(consoleView, processHandler);
AbstractRerunFailedTestsAction rerunFailedTestsAction = consoleProperties.createRerunFailedTestsAction(consoleView);
if (rerunFailedTestsAction != null) {
rerunFailedTestsAction.setModelProvider(((SMTRunnerConsoleView) consoleView)::getResultsViewer);
executionResult.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction());
} else {
executionResult.setRestartActions(new ToggleAutoTestAction());
}
return executionResult;
}
Aggregations