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);
}
}
}
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);
}
});
}
Aggregations