EDU-707 PyCharm Edu 3 fatal error on the first attempt to open a course in the course...
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Fri, 5 Aug 2016 16:59:57 +0000 (19:59 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Fri, 5 Aug 2016 17:02:43 +0000 (20:02 +0300)
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java
python/educational-core/student/src/com/jetbrains/edu/learning/StudyProjectComponent.java
python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java
python/educational-core/student/src/com/jetbrains/edu/learning/courseGeneration/StudyProjectGenerator.java
python/educational-python/course-creator-python/src/com/jetbrains/edu/coursecreator/PyCCProjectGenerator.java

index 45f89c83db2b4be83c31478e8beb49c5c7c44c2a..578f1a50afc5e8896fe70564c67c908ef1ac8dff 100644 (file)
@@ -10,8 +10,8 @@ import com.intellij.openapi.util.io.FileUtilRt;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileManager;
-import com.jetbrains.edu.learning.StudyProjectComponent;
 import com.jetbrains.edu.learning.StudyTaskManager;
+import com.jetbrains.edu.learning.StudyUtils;
 import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.courseFormat.Course;
 import com.jetbrains.edu.learning.courseFormat.Lesson;
@@ -50,7 +50,7 @@ public class CCProjectComponent extends AbstractProjectComponent {
       File coursesDir = new File(PathManager.getConfigPath(), "courses");
       File courseDir = new File(coursesDir, oldCourse.getName() + "-" + myProject.getName());
       oldCourse.setCourseDirectory(courseDir.getPath());
-      StudyProjectComponent.getInstance(myProject).registerStudyToolWindow(oldCourse);
+      StudyUtils.registerStudyToolWindow(oldCourse, myProject);
       transformFiles(oldCourse, myProject);
     }
   }
index 18deb4d89a940fb98793018708bb62da35396dac..8617bb5d223c19963374d5d8159158f3f0fbfcbd 100644 (file)
@@ -25,7 +25,6 @@ import com.intellij.openapi.vfs.VirtualFileAdapter;
 import com.intellij.openapi.vfs.VirtualFileEvent;
 import com.intellij.openapi.vfs.VirtualFileManager;
 import com.intellij.openapi.wm.ToolWindow;
-import com.intellij.openapi.wm.ToolWindowAnchor;
 import com.intellij.openapi.wm.ToolWindowManager;
 import com.intellij.util.containers.hash.HashMap;
 import com.jetbrains.edu.learning.actions.StudyActionWithShortcut;
@@ -42,7 +41,6 @@ import com.jetbrains.edu.learning.ui.StudyToolWindow;
 import com.jetbrains.edu.learning.ui.StudyToolWindowFactory;
 import javafx.application.Platform;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import javax.swing.event.HyperlinkEvent;
@@ -97,7 +95,7 @@ public class StudyProjectComponent implements ProjectComponent {
 
     }
 
-    registerStudyToolWindow(course);
+    StudyUtils.registerStudyToolWindow(course, myProject);
     ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
       @Override
       public void run() {
@@ -119,18 +117,6 @@ public class StudyProjectComponent implements ProjectComponent {
     });
   }
 
-  public void registerStudyToolWindow(@Nullable final Course course) {
-    if (course != null && "PyCharm".equals(course.getCourseType())) {
-      final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
-      registerToolWindows(toolWindowManager);
-      final ToolWindow studyToolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
-      if (studyToolWindow != null) {
-        studyToolWindow.show(null);
-        StudyUtils.initToolWindows(myProject);
-      }
-    }
-  }
-
   private void registerShortcuts() {
     StudyToolWindow window = StudyUtils.getStudyToolWindow(myProject);
     if (window != null) {
@@ -154,13 +140,6 @@ public class StudyProjectComponent implements ProjectComponent {
     }
   }
 
-  private void registerToolWindows(@NotNull final ToolWindowManager toolWindowManager) {
-    final ToolWindow toolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
-    if (toolWindow == null) {
-      toolWindowManager.registerToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW, true, ToolWindowAnchor.RIGHT, myProject, true);
-    }
-  }
-
   private void updateCourse() {
     final Course currentCourse = StudyTaskManager.getInstance(myProject).getCourse();
     final CourseInfo info = CourseInfo.fromCourse(currentCourse);
index 092ce8f2a52ca3dd4eb26d9eccc0dcd5c2b78476..c82a0379c2d1751881e5e8fd03726b1934fddc32 100644 (file)
@@ -37,6 +37,7 @@ import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.openapi.wm.ToolWindow;
+import com.intellij.openapi.wm.ToolWindowAnchor;
 import com.intellij.openapi.wm.ToolWindowManager;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiElement;
@@ -742,4 +743,23 @@ public class StudyUtils {
     int startOffset = placeholder.getOffset();
     editor.getSelectionModel().setSelection(startOffset, startOffset + placeholder.getRealLength());
   }
+
+  public static void registerStudyToolWindow(@Nullable final Course course, Project project) {
+    if (course != null && "PyCharm".equals(course.getCourseType())) {
+      final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
+      registerToolWindows(toolWindowManager, project);
+      final ToolWindow studyToolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
+      if (studyToolWindow != null) {
+        studyToolWindow.show(null);
+        initToolWindows(project);
+      }
+    }
+  }
+
+  private static void registerToolWindows(@NotNull final ToolWindowManager toolWindowManager, Project project) {
+    final ToolWindow toolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
+    if (toolWindow == null) {
+      toolWindowManager.registerToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW, true, ToolWindowAnchor.RIGHT, project, true);
+    }
+  }
 }
index 92c9feae8a8cb4d273784e1b650b8e190b4d0d3c..b512f91cfa3b7df7d0df9cf94ba94352356f0855 100644 (file)
@@ -24,7 +24,6 @@ import com.intellij.platform.templates.github.ZipUtil;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiManager;
 import com.intellij.util.containers.ContainerUtil;
-import com.jetbrains.edu.learning.StudyProjectComponent;
 import com.jetbrains.edu.learning.StudySerializationUtils;
 import com.jetbrains.edu.learning.StudyTaskManager;
 import com.jetbrains.edu.learning.StudyUtils;
@@ -100,7 +99,7 @@ public class StudyProjectGenerator {
       StudyGenerator.createCourse(course, baseDir, courseDirectory, project);
       course.setCourseDirectory(courseDirectory.getAbsolutePath());
       VirtualFileManager.getInstance().refreshWithoutFileWatcher(true);
-      StudyProjectComponent.getInstance(project).registerStudyToolWindow(course);
+      StudyUtils.registerStudyToolWindow(course, project);
       openFirstTask(course, project);
       EduUsagesCollector.projectTypeCreated(course.isAdaptive() ? EduNames.ADAPTIVE : EduNames.STUDY);
     });
index 5d786bf9b24ff0821d46a3200419a8a9ea870ec0..ef641f57cf8483fbdf85bb2b33d4bf9b4613164d 100644 (file)
@@ -19,8 +19,8 @@ import com.intellij.psi.PsiManager;
 import com.jetbrains.edu.coursecreator.actions.CCCreateLesson;
 import com.jetbrains.edu.coursecreator.actions.CCCreateTask;
 import com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel;
-import com.jetbrains.edu.learning.StudyProjectComponent;
 import com.jetbrains.edu.learning.StudyTaskManager;
+import com.jetbrains.edu.learning.StudyUtils;
 import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.courseFormat.Course;
 import com.jetbrains.edu.learning.statistics.EduUsagesCollector;
@@ -107,7 +107,7 @@ public class PyCCProjectGenerator extends PythonProjectGenerator implements Dire
     course.setCourseDirectory(courseDir.getPath());
 
     StudyTaskManager.getInstance(project).setCourse(course);
-    StudyProjectComponent.getInstance(project).registerStudyToolWindow(course);
+    StudyUtils.registerStudyToolWindow(course, project);
     return course;
   }