show standard test file name instead of real name for subtask tests in tab title
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Thu, 22 Sep 2016 12:46:55 +0000 (15:46 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 17 Nov 2016 14:05:05 +0000 (17:05 +0300)
python/educational-core/course-creator/resources/META-INF/plugin.xml
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCTestsTabTitleProvider.java [new file with mode: 0644]

index 797eace2e67d099d91a0cc77fb3e62165006be8f..b4cc3f63b44fea07316ec2bae09c2418d145099e 100644 (file)
@@ -27,6 +27,7 @@
                         serviceImplementation="com.jetbrains.edu.coursecreator.settings.CCSettings"/>
     <highlightErrorFilter implementation="com.jetbrains.edu.coursecreator.CCHighlightErrorFilter"/>
     <editorNotificationProvider implementation="com.jetbrains.edu.coursecreator.CCSubtaskEditorNotificationProvider"/>
+    <editorTabTitleProvider implementation="com.jetbrains.edu.coursecreator.CCTestsTabTitleProvider"/>
   </extensions>
   <extensions defaultExtensionNs="Edu">
     <studyActionsProvider implementation="com.jetbrains.edu.coursecreator.CCStudyActionsProvider"/>
diff --git a/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCTestsTabTitleProvider.java b/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCTestsTabTitleProvider.java
new file mode 100644 (file)
index 0000000..fc74f83
--- /dev/null
@@ -0,0 +1,30 @@
+package com.jetbrains.edu.coursecreator;
+
+import com.intellij.openapi.fileEditor.impl.EditorTabTitleProvider;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.jetbrains.edu.learning.StudyLanguageManager;
+import com.jetbrains.edu.learning.StudyTaskManager;
+import com.jetbrains.edu.learning.StudyUtils;
+import com.jetbrains.edu.learning.courseFormat.Course;
+import org.jetbrains.annotations.Nullable;
+
+public class CCTestsTabTitleProvider implements EditorTabTitleProvider {
+  @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();
+  }
+}
\ No newline at end of file