use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCProjectComponent method migrateIfNeeded.
public void migrateIfNeeded() {
Course studyCourse = StudyTaskManager.getInstance(myProject).getCourse();
if (studyCourse == null) {
Course oldCourse = CCProjectService.getInstance(myProject).getCourse();
if (oldCourse == null) {
return;
}
StudyTaskManager.getInstance(myProject).setCourse(oldCourse);
CCProjectService.getInstance(myProject).setCourse(null);
oldCourse.initCourse(true);
oldCourse.setCourseMode(CCUtils.COURSE_MODE);
File coursesDir = new File(PathManager.getConfigPath(), "courses");
File courseDir = new File(coursesDir, oldCourse.getName() + "-" + myProject.getName());
oldCourse.setCourseDirectory(courseDir.getPath());
StudyUtils.registerStudyToolWindow(oldCourse, myProject);
transformFiles(oldCourse, myProject);
}
}
use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCSubtaskChangeListener method subtaskChanged.
@Override
public void subtaskChanged(@NotNull Project project, @NotNull Task task, int oldSubtaskNumber, int newSubtaskNumber) {
VirtualFile taskDir = task.getTaskDir(project);
if (taskDir == null) {
return;
}
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
return;
}
String testFileName = manager.getTestFileName();
if (newSubtaskNumber != 0) {
String nameWithoutExtension = FileUtil.getNameWithoutExtension(testFileName);
String extension = FileUtilRt.getExtension(testFileName);
testFileName = nameWithoutExtension + EduNames.SUBTASK_MARKER + newSubtaskNumber + "." + extension;
}
VirtualFile newTestFile = taskDir.findChild(testFileName);
if (newTestFile == null) {
return;
}
FileEditorManager editorManager = FileEditorManager.getInstance(project);
List<VirtualFile> testFiles = ContainerUtil.filter(taskDir.getChildren(), file -> CCUtils.isTestsFile(project, file) && editorManager.isFileOpen(file));
if (testFiles.isEmpty()) {
return;
}
Editor selectedTextEditor = editorManager.getSelectedTextEditor();
for (VirtualFile testFile : testFiles) {
editorManager.closeFile(testFile);
}
editorManager.openFile(newTestFile, true);
if (selectedTextEditor != null) {
reopenSelectedEditor(editorManager, selectedTextEditor);
}
}
use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCTestsTabTitleProvider method getEditorTabTitle.
@Nullable
@Override
public String getEditorTabTitle(Project project, VirtualFile file) {
if (!CCUtils.isCourseCreator(project)) {
return null;
}
if (!CCUtils.isTestsFile(project, file)) {
return null;
}
Course course = StudyTaskManager.getInstance(project).getCourse();
assert course != null;
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
return null;
}
return manager.getTestFileName();
}
use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCVirtualFileListener method fileDeleted.
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
VirtualFile removedFile = event.getFile();
String path = removedFile.getPath();
if (path.contains(CCUtils.GENERATED_FILES_FOLDER)) {
return;
}
Project project = ProjectUtil.guessProjectForFile(removedFile);
if (project == null) {
return;
}
if (project.getBasePath() != null && !FileUtil.isAncestor(project.getBasePath(), removedFile.getPath(), true)) {
return;
}
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null || path.contains(FileUtil.toSystemIndependentName(course.getCourseDirectory()))) {
return;
}
final TaskFile taskFile = StudyUtils.getTaskFile(project, removedFile);
if (taskFile != null) {
deleteTaskFile(removedFile, taskFile);
return;
}
if (removedFile.getName().contains(EduNames.TASK)) {
deleteTask(course, removedFile);
}
if (removedFile.getName().contains(EduNames.LESSON)) {
deleteLesson(course, removedFile, project);
}
}
use of com.jetbrains.edu.learning.courseFormat.Course in project intellij-community by JetBrains.
the class CCChangeCourseInfo method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
return;
}
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
CCNewProjectPanel panel = new CCNewProjectPanel(course.getName(), Course.getAuthorsString(course.getAuthors()), course.getDescription());
setupLanguageLevels(course, panel);
DialogBuilder builder = createChangeInfoDialog(project, panel);
if (builder.showAndGet()) {
course.setAuthorsAsString(panel.getAuthors());
course.setName(panel.getName());
course.setDescription(panel.getDescription());
setVersion(course, panel);
ProjectView.getInstance(project).refresh();
ProjectInspectionProfileManager.getInstance(project).fireProfileChanged();
}
}
Aggregations