Fix according to review IDEA-CR-11509: Use ConsoleView instead of PythonConsoleView to show adaptive courses test results

This commit is contained in:
Valentina Kiryushkina
2016-06-20 15:21:22 +03:00
parent bce7f14a93
commit cf2d81effd
3 changed files with 18 additions and 23 deletions
@@ -1,5 +1,6 @@
package com.jetbrains.edu.learning.checker;
import com.intellij.execution.impl.ConsoleViewImpl;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -32,7 +33,6 @@ import com.jetbrains.edu.learning.courseFormat.TaskFile;
import com.jetbrains.edu.learning.editor.StudyEditor;
import com.jetbrains.edu.learning.navigation.StudyNavigator;
import com.jetbrains.edu.learning.ui.StudyTestResultsToolWindowFactory;
import com.jetbrains.python.console.PythonConsoleView;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -206,13 +206,13 @@ public class StudyCheckUtils {
final Content[] contents = window.getContentManager().getContents();
for (Content content : contents) {
final JComponent component = content.getComponent();
if (component instanceof PythonConsoleView) {
((PythonConsoleView)component).clear();
if (component instanceof ConsoleViewImpl) {
((ConsoleViewImpl)component).clear();
if (!solved) {
((PythonConsoleView)component).print(message, ConsoleViewContentType.ERROR_OUTPUT);
((ConsoleViewImpl)component).print(message, ConsoleViewContentType.ERROR_OUTPUT);
}
else {
((PythonConsoleView)component).print(message, ConsoleViewContentType.NORMAL_OUTPUT);
((ConsoleViewImpl)component).print(message, ConsoleViewContentType.NORMAL_OUTPUT);
}
window.setAvailable(true, () -> {});
window.show(() -> {});
@@ -1,5 +1,7 @@
package com.jetbrains.edu.learning.ui
import com.intellij.execution.impl.ConsoleViewImpl
import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.FileEditorManagerEvent
import com.intellij.openapi.fileEditor.FileEditorManagerListener
@@ -8,30 +10,24 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.jetbrains.edu.learning.StudyUtils
import com.jetbrains.python.console.PythonConsoleView
class StudyTestResultsToolWindowFactory: ToolWindowFactory {
class StudyTestResultsToolWindowFactory : ToolWindowFactory {
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
val currentTask = StudyUtils.getCurrentTask(project)
if (currentTask != null) {
val sdk = StudyUtils.findSdk(currentTask, project)
if (sdk != null) {
val testResultsToolWindow = PythonConsoleView(project, "Local test results", sdk);
testResultsToolWindow.isEditable = false
testResultsToolWindow.isConsoleEditorEnabled = false
testResultsToolWindow.prompt = null
toolWindow.isToHideOnEmptyContent = true
val consoleView = ConsoleViewImpl(project, true);
toolWindow.isToHideOnEmptyContent = true
val contentManager = toolWindow.contentManager
val content = contentManager.factory.createContent(testResultsToolWindow.component, null, false)
contentManager.addContent(content)
val contentManager = toolWindow.contentManager
val content = contentManager.factory.createContent(consoleView.component, null, false)
contentManager.addContent(content)
val editor = consoleView.editor
if (editor is EditorEx) {
editor.isRendererMode = true
}
project.messageBus.connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, getFileEditorManagerListener(toolWindow))
}
else {
StudyUtils.showNoSdkNotification(currentTask, project)
}
project.messageBus.connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, getFileEditorManagerListener(toolWindow))
}
}
@@ -22,7 +22,6 @@
</library>
</orderEntry>
<orderEntry type="module" module-name="platform-api" />
<orderEntry type="module" module-name="python-community" />
<orderEntry type="module" module-name="xml" />
<orderEntry type="library" name="markdownj" level="project" />
</component>