Fix EDU-636 Do not load course list on stepic login for adaptive course
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Wed, 22 Jun 2016 16:46:43 +0000 (19:46 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Wed, 22 Jun 2016 16:49:14 +0000 (19:49 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudyNewProjectPanel.java
python/educational-python/student-python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java

index df010216a5dcb7bf1032af7cc85d47c4218eb90b..5b89e8bf62a84a80c194bfc753ecb588ac869502 100644 (file)
@@ -184,7 +184,7 @@ public class StudyNewProjectPanel extends JPanel implements PanelWithAnchor {
                                        });
               }
               else if (LOGIN_TO_STEPIC.equals(selectedValue)) {
-                showLoginDialog();
+                showLoginDialog(true, "Signing In And Getting Stepic Course List");
               }
             });
           }
@@ -195,8 +195,8 @@ public class StudyNewProjectPanel extends JPanel implements PanelWithAnchor {
     });
   }
 
-  public void showLoginDialog() {
-    final AddRemoteDialog dialog = new AddRemoteDialog();
+  public void showLoginDialog(final boolean refreshCourseList, @NotNull final String progressTitle) {
+    final AddRemoteDialog dialog = new AddRemoteDialog(refreshCourseList, progressTitle);
     dialog.show();
   }
 
@@ -321,8 +321,13 @@ public class StudyNewProjectPanel extends JPanel implements PanelWithAnchor {
 
   private class AddRemoteDialog extends LoginDialog {
 
-    protected AddRemoteDialog() {
+    private final boolean myRefreshCourseList;
+    private final String myProgressTitle;
+
+    protected AddRemoteDialog(final boolean refreshCourseList, @NotNull final String progressTitle) {
       super();
+      myRefreshCourseList = refreshCourseList;
+      myProgressTitle = progressTitle;
     }
 
     @Override
@@ -342,14 +347,15 @@ public class StudyNewProjectPanel extends JPanel implements PanelWithAnchor {
           myGenerator.setEnrolledCoursesIds(EduStepicConnector.getEnrolledCoursesIds());
 
           final List<CourseInfo> courses = myGenerator.getCourses(true);
-          if (courses != null) {
+          if (courses != null && myRefreshCourseList) {
             ApplicationManager.getApplication().invokeLater(() -> refreshCoursesList(courses));
           }
+          setOK();
         }
         else {
           setError("Failed to login");
         }
-      }, "Signing In And Getting Stepic Course List", true, new DefaultProjectFactoryImpl().getDefaultProject());
+      }, myProgressTitle, true, new DefaultProjectFactoryImpl().getDefaultProject());
     }
   }
 }
index 2fbe4b54929903631580cac15b601f7635ae5dcc..20d11cb4bc97cde9d4ccd5f50754ae9e30d6b1e8 100644 (file)
@@ -68,7 +68,7 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator imp
       @Override
       public void mouseClicked(MouseEvent e) {
         if (((CourseInfo)mySettingsPanel.getCoursesComboBox().getSelectedItem()).isAdaptive() && !myGenerator.isLoggedIn()) {
-          mySettingsPanel.showLoginDialog();
+          mySettingsPanel.showLoginDialog(false, "Signing In");
         }
       }