show standard test file name instead of real name for subtask tests in tab title
[idea/community.git] / python / educational-core / course-creator / src / com / jetbrains / edu / coursecreator / CCTestsTabTitleProvider.java
1 package com.jetbrains.edu.coursecreator;
2
3 import com.intellij.openapi.fileEditor.impl.EditorTabTitleProvider;
4 import com.intellij.openapi.project.Project;
5 import com.intellij.openapi.vfs.VirtualFile;
6 import com.jetbrains.edu.learning.StudyLanguageManager;
7 import com.jetbrains.edu.learning.StudyTaskManager;
8 import com.jetbrains.edu.learning.StudyUtils;
9 import com.jetbrains.edu.learning.courseFormat.Course;
10 import org.jetbrains.annotations.Nullable;
11
12 public class CCTestsTabTitleProvider implements EditorTabTitleProvider {
13   @Nullable
14   @Override
15   public String getEditorTabTitle(Project project, VirtualFile file) {
16     if (!CCUtils.isCourseCreator(project)) {
17       return null;
18     }
19     if (!CCUtils.isTestsFile(project, file)) {
20       return null;
21     }
22     Course course = StudyTaskManager.getInstance(project).getCourse();
23     assert course != null;
24     StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
25     if (manager == null) {
26       return null;
27     }
28     return manager.getTestFileName();
29   }
30 }