Search in sources :

Example 26 with ConsoleView

use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.

the class FoldLinesLikeThis method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Editor editor = e.getData(CommonDataKeys.EDITOR);
    assert editor != null;
    final String selection = getSingleLineSelection(editor);
    assert selection != null;
    ShowSettingsUtil.getInstance().editConfigurable(editor.getProject(), new ConsoleConfigurable() {

        @Override
        protected boolean editFoldingsOnly() {
            return true;
        }

        @Override
        public void reset() {
            super.reset();
            UIUtil.invokeLaterIfNeeded(() -> addRule(selection));
        }
    });
    final ConsoleView consoleView = e.getData(LangDataKeys.CONSOLE_VIEW);
    if (consoleView instanceof ConsoleViewImpl) {
        ((ConsoleViewImpl) consoleView).foldImmediately();
    }
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) Editor(com.intellij.openapi.editor.Editor) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl)

Example 27 with ConsoleView

use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.

the class DaemonRespondToChangesTest method testDaemonIgnoresConsoleActivities.

public void testDaemonIgnoresConsoleActivities() throws Exception {
    configureByFile(BASE_PATH + "AClass.java");
    doHighlighting(HighlightSeverity.WARNING);
    final ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(getProject()).getConsole();
    //create editor
    consoleView.getComponent();
    consoleView.print("haha", ConsoleViewContentType.NORMAL_OUTPUT);
    UIUtil.dispatchAllInvocationEvents();
    try {
        checkDaemonReaction(false, () -> {
            consoleView.clear();
            try {
                // *&^ing alarm
                Thread.sleep(300);
            } catch (InterruptedException e) {
                LOG.error(e);
            }
            //flush
            UIUtil.dispatchAllInvocationEvents();
        });
        checkDaemonReaction(false, () -> {
            consoleView.print("sss", ConsoleViewContentType.NORMAL_OUTPUT);
            try {
                // *&^ing alarm
                Thread.sleep(300);
            } catch (InterruptedException e) {
                LOG.error(e);
            }
            //flush
            UIUtil.dispatchAllInvocationEvents();
        });
        checkDaemonReaction(false, () -> {
            consoleView.setOutputPaused(true);
            try {
                // *&^ing alarm
                Thread.sleep(300);
            } catch (InterruptedException e) {
                LOG.error(e);
            }
            //flush
            UIUtil.dispatchAllInvocationEvents();
        });
    } finally {
        Disposer.dispose(consoleView);
    }
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView)

Example 28 with ConsoleView

use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.

the class CommandLineState method execute.

@Override
@NotNull
public ExecutionResult execute(@NotNull final Executor executor, @NotNull final ProgramRunner runner) throws ExecutionException {
    final ProcessHandler processHandler = startProcess();
    final ConsoleView console = createConsole(executor);
    if (console != null) {
        console.attachToProcess(processHandler);
    }
    return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler, executor));
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 29 with ConsoleView

use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.

the class LogConsoleBase method doFilter.

private synchronized void doFilter() {
    if (myDisposed) {
        return;
    }
    final ConsoleView console = getConsoleNotNull();
    console.clear();
    myModel.processingStarted();
    final String[] lines = myOriginalDocument != null ? myOriginalDocument.toString().split("\n") : ArrayUtil.EMPTY_STRING_ARRAY;
    ;
    int offset = 0;
    boolean caretPositioned = false;
    for (String line : lines) {
        final int printed = printMessageToConsole(line);
        if (printed > 0) {
            if (!caretPositioned) {
                if (Comparing.strEqual(myLineUnderSelection, line)) {
                    caretPositioned = true;
                    offset += myLineOffset != -1 ? myLineOffset : 0;
                } else {
                    offset += printed;
                }
            }
        }
    }
    // we need this, because, document can change before actual scrolling, so offset may be already not at the end
    if (caretPositioned) {
        console.scrollTo(offset);
    } else {
        ((ConsoleViewImpl) console).requestScrollingToEnd();
    }
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl)

Example 30 with ConsoleView

use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.

the class LogConsoleBase method printMessageToConsole.

private int printMessageToConsole(String line) {
    final ConsoleView console = getConsoleNotNull();
    if (myContentPreprocessor != null) {
        List<LogFragment> fragments = myContentPreprocessor.parseLogLine(line + '\n');
        for (LogFragment fragment : fragments) {
            ConsoleViewContentType consoleViewType = ConsoleViewContentType.getConsoleViewType(fragment.getOutputType());
            if (consoleViewType != null) {
                String formattedText = myFormatter.formatMessage(fragment.getText());
                console.print(formattedText, consoleViewType);
            }
        }
        return line.length() + 1;
    } else {
        final LogFilterModel.MyProcessingResult processingResult = myModel.processLine(line);
        if (processingResult.isApplicable()) {
            final Key key = processingResult.getKey();
            if (key != null) {
                ConsoleViewContentType type = ConsoleViewContentType.getConsoleViewType(key);
                if (type != null) {
                    final String messagePrefix = processingResult.getMessagePrefix();
                    if (messagePrefix != null) {
                        String formattedPrefix = myFormatter.formatPrefix(messagePrefix);
                        console.print(formattedPrefix, type);
                    }
                    String formattedMessage = myFormatter.formatMessage(line);
                    console.print(formattedMessage + "\n", type);
                    return (messagePrefix != null ? messagePrefix.length() : 0) + line.length() + 1;
                }
            }
        }
        return 0;
    }
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) Key(com.intellij.openapi.util.Key) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType)

Aggregations

ConsoleView (com.intellij.execution.ui.ConsoleView)42 NotNull (org.jetbrains.annotations.NotNull)20 ProcessHandler (com.intellij.execution.process.ProcessHandler)15 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)9 SMTRunnerConsoleView (com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView)7 TextConsoleBuilder (com.intellij.execution.filters.TextConsoleBuilder)6 Content (com.intellij.ui.content.Content)6 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)5 ToolWindow (com.intellij.openapi.wm.ToolWindow)5 Executor (com.intellij.execution.Executor)4 TestConsoleProperties (com.intellij.execution.testframework.TestConsoleProperties)4 ToggleAutoTestAction (com.intellij.execution.testframework.autotest.ToggleAutoTestAction)4 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)4 Disposable (com.intellij.openapi.Disposable)4 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)3 BaseTestsOutputConsoleView (com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView)3 CloseAction (com.intellij.execution.ui.actions.CloseAction)3 Project (com.intellij.openapi.project.Project)3 AndroidLogcatView (com.android.tools.idea.logcat.AndroidLogcatView)2 ExecutionException (com.intellij.execution.ExecutionException)2