Search in sources :

Example 1 with EduCourseConfigurator

use of com.jetbrains.edu.learning.intellij.EduCourseConfigurator in project intellij-community by JetBrains.

the class EduCustomCourseModuleBuilder method createModule.

@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
    Module baseModule = super.createModule(moduleModel);
    if (mySelectedCourse != null) {
        String type = mySelectedCourse.getType();
        String languageName = type.substring("pycharm ".length());
        Language language = Language.findLanguageByID(languageName);
        if (language != null) {
            EduCourseConfigurator configurator = EduCourseConfigurator.INSTANCE.forLanguage(language);
            if (configurator != null) {
                configurator.createCourseFromCourseInfo(moduleModel, baseModule.getProject(), myGenerator, mySelectedCourse, getModuleFileDirectory());
            }
        }
    }
    return baseModule;
}
Also used : Language(com.intellij.lang.Language) EduCourseConfigurator(com.jetbrains.edu.learning.intellij.EduCourseConfigurator) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with EduCourseConfigurator

use of com.jetbrains.edu.learning.intellij.EduCourseConfigurator in project intellij-community by JetBrains.

the class EduCCModuleBuilder method createModule.

@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
    Module module = super.createModule(moduleModel);
    Project project = module.getProject();
    final Course course = new Course();
    course.setName(myPanel.getName());
    course.setAuthorsAsString(myPanel.getAuthors());
    course.setDescription(myPanel.getDescription());
    LanguageWrapper wrapper = (LanguageWrapper) myLanguageComboBox.getSelectedItem();
    course.setLanguage(wrapper.getLanguage().getID());
    course.setCourseMode(CCUtils.COURSE_MODE);
    File courseDir = new File(StudyProjectGenerator.OUR_COURSES_DIR, myPanel.getName() + "-" + project.getName());
    course.setCourseDirectory(courseDir.getPath());
    Lesson lesson = new Lesson();
    Task task = new Task();
    task.setName("task1");
    lesson.addTask(task);
    lesson.setName("lesson1");
    course.addLesson(lesson);
    course.initCourse(false);
    StudyTaskManager.getInstance(project).setCourse(course);
    EduCourseConfigurator configurator = EduCourseConfigurator.INSTANCE.forLanguage(wrapper.getLanguage());
    if (configurator == null) {
        LOG.error("EduCourseConfigurator for language " + wrapper.getLanguage().getDisplayName() + " not found");
        return module;
    }
    configurator.configureModule(module);
    configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
    return module;
}
Also used : Project(com.intellij.openapi.project.Project) Task(com.jetbrains.edu.learning.courseFormat.Task) EduCourseConfigurator(com.jetbrains.edu.learning.intellij.EduCourseConfigurator) Module(com.intellij.openapi.module.Module) Course(com.jetbrains.edu.learning.courseFormat.Course) File(java.io.File) Lesson(com.jetbrains.edu.learning.courseFormat.Lesson) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with EduCourseConfigurator

use of com.jetbrains.edu.learning.intellij.EduCourseConfigurator in project intellij-community by JetBrains.

the class EduCustomCourseModuleBuilder method commitModule.

@Nullable
@Override
public Module commitModule(@NotNull Project project, @Nullable ModifiableModuleModel model) {
    Module module = super.commitModule(project, model);
    if (module == null) {
        return null;
    }
    String type = mySelectedCourse.getType();
    String languageName = type.substring("pycharm ".length());
    Language language = Language.findLanguageByID(languageName);
    if (language != null) {
        EduCourseConfigurator configurator = EduCourseConfigurator.INSTANCE.forLanguage(language);
        if (configurator != null) {
            configurator.configureModule(module);
        }
    }
    return module;
}
Also used : Language(com.intellij.lang.Language) EduCourseConfigurator(com.jetbrains.edu.learning.intellij.EduCourseConfigurator) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Module (com.intellij.openapi.module.Module)3 EduCourseConfigurator (com.jetbrains.edu.learning.intellij.EduCourseConfigurator)3 Language (com.intellij.lang.Language)2 NotNull (org.jetbrains.annotations.NotNull)2 Project (com.intellij.openapi.project.Project)1 Course (com.jetbrains.edu.learning.courseFormat.Course)1 Lesson (com.jetbrains.edu.learning.courseFormat.Lesson)1 Task (com.jetbrains.edu.learning.courseFormat.Task)1 File (java.io.File)1 Nullable (org.jetbrains.annotations.Nullable)1