Commit 1baa34e5 authored by Ekaterina Tuzova's avatar Ekaterina Tuzova Committed by Ekaterina Tuzova
Browse files

fix get courses in show course preview

parent e46cb033
Branches unavailable Tags unavailable
No related merge requests found
Showing with 15 additions and 10 deletions
+15 -10
......@@ -123,7 +123,7 @@ public class StudyProjectGenerator {
if (force) {
myCourses = execCancelable(() -> EduStepicConnector.getCourses(StepicUpdateSettings.getInstance().getUser()));
}
if (force || myCourses == null || myCourses.isEmpty() || (myCourses.size() == 1 && myCourses.contains(CourseInfo.INVALID_COURSE))) {
if (myCourses == null || myCourses.isEmpty() || (myCourses.size() == 1 && myCourses.contains(CourseInfo.INVALID_COURSE))) {
myCourses = Collections.singletonList(getBundledIntro());
}
sortCourses(myCourses);
......
......@@ -2,8 +2,8 @@ package com.jetbrains.edu.learning.intellij.localCourses;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator;
import com.jetbrains.edu.learning.courseFormat.CourseInfo;
import com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator;
import com.jetbrains.edu.learning.ui.StudyNewProjectPanel;
import javax.swing.*;
......@@ -45,7 +45,7 @@ public class EduLocalCoursePanel {
}
private void createUIComponents() {
myStudyPanel = new StudyNewProjectPanel(myGenerator);
myStudyPanel = new StudyNewProjectPanel(myGenerator, true);
myInfoPanel = myStudyPanel.getInfoPanel();
}
}
......@@ -57,6 +57,7 @@ public class StudyNewProjectPanel extends JPanel implements PanelWithAnchor {
private JTextPane myDescriptionPane;
private JComponent myAnchor;
private final StudyProjectGenerator myGenerator;
private boolean isLocal = false;
private static final String CONNECTION_ERROR = "<html>Failed to download courses.<br>Check your Internet connection.</html>";
private static final String INVALID_COURSE = "Selected course is invalid";
private FacetValidatorsManager myValidationManager;
......@@ -64,10 +65,10 @@ public class StudyNewProjectPanel extends JPanel implements PanelWithAnchor {
private static final String LOGIN_TO_STEPIC_MESSAGE = "<html><u>Login to Stepik</u> to open the adaptive course </html>";
private static final String LOGIN_TO_STEPIC = "Login to Stepik";
public StudyNewProjectPanel(@NotNull final StudyProjectGenerator generator) {
public StudyNewProjectPanel(@NotNull final StudyProjectGenerator generator, boolean isLocal) {
super(new VerticalFlowLayout(true, true));
myGenerator = generator;
this.isLocal = isLocal;
layoutPanel();
initListeners();
}
......@@ -116,7 +117,7 @@ public class StudyNewProjectPanel extends JPanel implements PanelWithAnchor {
private void initCoursesCombobox() {
myAvailableCourses =
myGenerator.getCoursesUnderProgress(false, "Getting Available Courses", ProjectManager.getInstance().getDefaultProject());
myGenerator.getCoursesUnderProgress(!isLocal, "Getting Available Courses", ProjectManager.getInstance().getDefaultProject());
if (myAvailableCourses.contains(CourseInfo.INVALID_COURSE)) {
setError(CONNECTION_ERROR);
}
......
......@@ -10,8 +10,8 @@ import com.jetbrains.edu.learning.PyStudyDirectoryProjectGenerator;
import com.jetbrains.edu.learning.StudyTaskManager;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.courseFormat.Course;
import com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator;
import com.jetbrains.edu.learning.courseFormat.CourseInfo;
import com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator;
import com.jetbrains.python.newProject.steps.PyCharmNewProjectStep;
import org.jetbrains.annotations.NotNull;
......@@ -25,7 +25,7 @@ class CreateFromArchiveProjectStep extends PyCharmNewProjectStep {
private final Project myProject;
private final Module myModule;
private PyStudyDirectoryProjectGenerator myGenerator = new PyStudyDirectoryProjectGenerator();
private PyStudyDirectoryProjectGenerator myGenerator = new PyStudyDirectoryProjectGenerator(true);
public MyCustomization(Project project,
Module module) {
......
......@@ -61,6 +61,10 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator<PyN
private StudyNewProjectPanel mySettingsPanel;
public PyStudyDirectoryProjectGenerator() {
this(false);
}
public PyStudyDirectoryProjectGenerator(boolean isLocal) {
myGenerator = new StudyProjectGenerator();
myGenerator.addSettingsStateListener(new StudyProjectGenerator.SettingsListener() {
@Override
......@@ -69,7 +73,7 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator<PyN
}
});
mySettingsPanel = new StudyNewProjectPanel(myGenerator);
mySettingsPanel = new StudyNewProjectPanel(myGenerator, isLocal);
mySettingsPanel.registerValidators(new FacetValidatorsManager() {
public void registerValidator(FacetEditorValidator validator, JComponent... componentsToWatch) {
throw new UnsupportedOperationException();
......
......@@ -61,7 +61,7 @@ public class PyStudyIntroductionCourseAction extends AnAction {
ProjectUtil.openProject(projectDir.getPath(), null, false);
}
else {
final PyStudyDirectoryProjectGenerator generator = new PyStudyDirectoryProjectGenerator();
final PyStudyDirectoryProjectGenerator generator = new PyStudyDirectoryProjectGenerator(true);
final EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(PythonLanguage.getInstance());
final String bundledCoursePath = configurator.getBundledCoursePath();
CourseInfo introCourse = generator.getGenerator().getCourseInfo(bundledCoursePath);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment