Fix according to review IDEA-CR-11509: Use ConsoleView instead of PythonConsoleView...
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Mon, 20 Jun 2016 11:37:25 +0000 (14:37 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Mon, 20 Jun 2016 12:21:22 +0000 (15:21 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/checker/StudyCheckUtils.java
python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudyTestResultsToolWindowFactory.kt
python/educational-core/student/student.iml

index 7e62ccd1c0382076e1d14f523eca3b72d92cb6fe..940ce051c743923eafb0cf8c2cef4e36e046c8be 100644 (file)
@@ -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(() -> {});
index 549d4dd288a992d190ab27591b706e4f20fe2f0e..40be63a4cf58b967db3b4dc36499a802b7084189 100644 (file)
@@ -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 contentManager = toolWindow.contentManager
-        val content = contentManager.factory.createContent(testResultsToolWindow.component, null, false)
-        contentManager.addContent(content)
-
-        project.messageBus.connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, getFileEditorManagerListener(toolWindow))
-      }
-      else {
-        StudyUtils.showNoSdkNotification(currentTask, project)
+      val consoleView = ConsoleViewImpl(project, true);
+      toolWindow.isToHideOnEmptyContent = true
+
+      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))
     }
   }
 
index 5fff6115855f89dcc70fcfebd6c6f4934f66a94a..830451861a0f3a2e9e57e37d16feb1209a075ec4 100644 (file)
@@ -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>