Search in sources :

Example 1 with TextConsoleBuilder

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;
}
Also used : RegexpFilter(com.intellij.execution.filters.RegexpFilter) ExecutionResult(com.intellij.execution.ExecutionResult) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) Executor(com.intellij.execution.Executor) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) CommandLineState(com.intellij.execution.configurations.CommandLineState) ProgramRunner(com.intellij.execution.runners.ProgramRunner) Key(com.intellij.openapi.util.Key)

Example 2 with TextConsoleBuilder

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;
}
Also used : DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) ConsoleView(com.intellij.execution.ui.ConsoleView) CloseAction(com.intellij.execution.ui.actions.CloseAction)

Example 3 with TextConsoleBuilder

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;
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) Executor(com.intellij.execution.Executor) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) ConsoleView(com.intellij.execution.ui.ConsoleView) CloseAction(com.intellij.execution.ui.actions.CloseAction) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl)

Example 4 with TextConsoleBuilder

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();
}
Also used : DartRelativePathsConsoleFilter(com.jetbrains.lang.dart.ide.runner.DartRelativePathsConsoleFilter) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) DartConsoleFilter(com.jetbrains.lang.dart.ide.runner.DartConsoleFilter) UrlFilter(com.intellij.execution.filters.UrlFilter) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with TextConsoleBuilder

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;
}
Also used : GoConsoleFilter(com.goide.runconfig.GoConsoleFilter) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler) AbstractRerunFailedTestsAction(com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction) ToggleAutoTestAction(com.intellij.execution.testframework.autotest.ToggleAutoTestAction) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TextConsoleBuilder (com.intellij.execution.filters.TextConsoleBuilder)11 ConsoleView (com.intellij.execution.ui.ConsoleView)6 NotNull (org.jetbrains.annotations.NotNull)5 Executor (com.intellij.execution.Executor)3 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)2 RegexpFilter (com.intellij.execution.filters.RegexpFilter)2 ProcessHandler (com.intellij.execution.process.ProcessHandler)2 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)2 CloseAction (com.intellij.execution.ui.actions.CloseAction)2 Disposable (com.intellij.openapi.Disposable)2 Project (com.intellij.openapi.project.Project)2 Content (com.intellij.ui.content.Content)2 GoConsoleFilter (com.goide.runconfig.GoConsoleFilter)1 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)1 ExecutionException (com.intellij.execution.ExecutionException)1 ExecutionResult (com.intellij.execution.ExecutionResult)1 CommandLineState (com.intellij.execution.configurations.CommandLineState)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 TextConsoleBuilderImpl (com.intellij.execution.filters.TextConsoleBuilderImpl)1