mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not try to create non-pycharm step from stepic. Added progress bar on creating new course
This commit is contained in:
+17
-1
@@ -8,6 +8,8 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -63,7 +65,21 @@ public class StudyProjectGenerator {
|
||||
}
|
||||
|
||||
public void generateProject(@NotNull final Project project, @NotNull final VirtualFile baseDir) {
|
||||
final Course course = getCourse();
|
||||
final Course course;
|
||||
try {
|
||||
course =
|
||||
ProgressManager.getInstance().run(new com.intellij.openapi.progress.Task.WithResult<Course, Exception>(project, "Creating Course", false) {
|
||||
@Override
|
||||
protected Course compute(@NotNull ProgressIndicator indicator) throws Exception {
|
||||
return getCourse();
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("Failed to obtain course " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (course == null) return;
|
||||
StudyTaskManager.getInstance(project).setCourse(course);
|
||||
ApplicationManager.getApplication().invokeLater(
|
||||
|
||||
@@ -279,20 +279,20 @@ public class EduStepicConnector {
|
||||
int lessonID = unit.units.get(0).lesson;
|
||||
LessonContainer lesson = getFromStepic("lessons/" + String.valueOf(lessonID), LessonContainer.class);
|
||||
Lesson realLesson = lesson.lessons.get(0);
|
||||
lessons.add(realLesson);
|
||||
realLesson.taskList = new ArrayList<Task>();
|
||||
for (Integer s : realLesson.steps) {
|
||||
createTask(realLesson, s);
|
||||
}
|
||||
if (!realLesson.taskList.isEmpty())
|
||||
lessons.add(realLesson);
|
||||
}
|
||||
|
||||
for (Lesson lesson : lessons) {
|
||||
lesson.taskList = new ArrayList<Task>();
|
||||
for (Integer s : lesson.steps) {
|
||||
createTask(lesson, s);
|
||||
}
|
||||
}
|
||||
return lessons;
|
||||
}
|
||||
|
||||
private static void createTask(Lesson lesson, Integer stepicId) throws IOException {
|
||||
final Step step = getStep(stepicId);
|
||||
if (!step.name.equals(PYCHARM_PREFIX)) return;
|
||||
final Task task = new Task();
|
||||
task.setStepicId(stepicId);
|
||||
task.setName(step.options != null ? step.options.title : PYCHARM_PREFIX);
|
||||
|
||||
Reference in New Issue
Block a user