Search in sources :

Example 1 with ArchivedOutputListener

use of com.intellij.javascript.karma.util.ArchivedOutputListener in project intellij-plugins by JetBrains.

the class KarmaProcessOutputManager method addText.

private void addText(@NotNull String text, @NotNull Key outputType) {
    synchronized (myArchivedTexts) {
        myArchivedTexts.addLast(Pair.create(text, outputType));
        myArchivedTextsLength += text.length();
        while (myArchivedTextsLength > MAX_ARCHIVED_TEXTS_LENGTH) {
            Pair<String, Key> pair = myArchivedTexts.removeFirst();
            myArchivedTextsLength -= pair.getFirst().length();
            myArchiveTextsTruncated = true;
        }
        for (ArchivedOutputListener listener : myOutputListeners) {
            listener.onOutputAvailable(text, outputType, false);
        }
    }
}
Also used : ArchivedOutputListener(com.intellij.javascript.karma.util.ArchivedOutputListener) Key(com.intellij.openapi.util.Key)

Example 2 with ArchivedOutputListener

use of com.intellij.javascript.karma.util.ArchivedOutputListener in project intellij-plugins by JetBrains.

the class KarmaServerLogComponent method register.

public static void register(@NotNull Project project, @NotNull final KarmaServer server, @NotNull final RunnerLayoutUi ui, boolean requestFocus) {
    final ConsoleView console = createConsole(project);
    KarmaServerLogComponent component = new KarmaServerLogComponent(console, server);
    final Content content = ui.createContent("KarmaServer", component, "Karma Server", null, console.getPreferredFocusableComponent());
    content.setCloseable(false);
    ui.addContent(content, 4, PlaceInGrid.bottom, false);
    if (requestFocus && !server.isPortBound()) {
        ui.selectAndFocus(content, false, false);
    }
    final KarmaServerTerminatedListener terminationCallback = new KarmaServerTerminatedListener() {

        @Override
        public void onTerminated(int exitCode) {
            KarmaUtil.selectAndFocusIfNotDisposed(ui, content, false, false);
        }
    };
    server.onTerminated(terminationCallback);
    final ArchivedOutputListener outputListener = new ArchivedOutputListener() {

        @Override
        public void onOutputAvailable(@NotNull String text, Key outputType, boolean archived) {
            ConsoleViewContentType contentType = ConsoleViewContentType.getConsoleViewType(outputType);
            console.print(text, contentType);
            if (!archived && text.startsWith("ERROR ")) {
                ApplicationManager.getApplication().invokeLater(() -> content.fireAlert(), ModalityState.any());
            }
        }
    };
    server.getProcessOutputManager().addOutputListener(outputListener);
    Disposer.register(content, console);
    Disposer.register(console, new Disposable() {

        @Override
        public void dispose() {
            server.removeTerminatedListener(terminationCallback);
            server.getProcessOutputManager().removeOutputListener(outputListener);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) ConsoleView(com.intellij.execution.ui.ConsoleView) Content(com.intellij.ui.content.Content) ArchivedOutputListener(com.intellij.javascript.karma.util.ArchivedOutputListener) NotNull(org.jetbrains.annotations.NotNull) Key(com.intellij.openapi.util.Key) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType)

Aggregations

ArchivedOutputListener (com.intellij.javascript.karma.util.ArchivedOutputListener)2 Key (com.intellij.openapi.util.Key)2 ConsoleView (com.intellij.execution.ui.ConsoleView)1 ConsoleViewContentType (com.intellij.execution.ui.ConsoleViewContentType)1 Disposable (com.intellij.openapi.Disposable)1 Content (com.intellij.ui.content.Content)1 NotNull (org.jetbrains.annotations.NotNull)1