Search in sources :

Example 1 with StudyTestResultsToolWindowFactory

use of com.jetbrains.edu.learning.ui.StudyTestResultsToolWindowFactory in project intellij-community by JetBrains.

the class StudyCheckUtils method showTestResultsToolWindow.

public static void showTestResultsToolWindow(@NotNull final Project project, @NotNull final String message, boolean solved) {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow window = toolWindowManager.getToolWindow(StudyTestResultsToolWindowFactoryKt.ID);
    if (window == null) {
        toolWindowManager.registerToolWindow(StudyTestResultsToolWindowFactoryKt.ID, true, ToolWindowAnchor.BOTTOM);
        window = toolWindowManager.getToolWindow(StudyTestResultsToolWindowFactoryKt.ID);
        new StudyTestResultsToolWindowFactory().createToolWindowContent(project, window);
    }
    final Content[] contents = window.getContentManager().getContents();
    for (Content content : contents) {
        final JComponent component = content.getComponent();
        if (component instanceof ConsoleViewImpl) {
            ((ConsoleViewImpl) component).clear();
            if (!solved) {
                ((ConsoleViewImpl) component).print(message, ConsoleViewContentType.ERROR_OUTPUT);
            } else {
                ((ConsoleViewImpl) component).print(message, ConsoleViewContentType.NORMAL_OUTPUT);
            }
            window.setAvailable(true, () -> {
            });
            window.show(() -> {
            });
            return;
        }
    }
}
Also used : StudyTestResultsToolWindowFactory(com.jetbrains.edu.learning.ui.StudyTestResultsToolWindowFactory) Content(com.intellij.ui.content.Content) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl)

Aggregations

ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)1 Content (com.intellij.ui.content.Content)1 StudyTestResultsToolWindowFactory (com.jetbrains.edu.learning.ui.StudyTestResultsToolWindowFactory)1