Search in sources :

Example 1 with UniqueNameEditorTabTitleProvider

use of com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider in project intellij-community by JetBrains.

the class StudyTabTitleProvider method getEditorTabTitle.

@Nullable
@Override
public String getEditorTabTitle(Project project, VirtualFile file) {
    TaskFile taskFile = StudyUtils.getTaskFile(project, file);
    if (taskFile == null) {
        return null;
    }
    String title = new UniqueNameEditorTabTitleProvider().getEditorTabTitle(project, file);
    if (title == null) {
        return null;
    }
    String[] split = title.split(Pattern.quote(File.separator));
    for (int i = 0; i < split.length; i++) {
        String part = split[i];
        Task task = taskFile.getTask();
        VirtualFile taskDir = task.getTaskDir(project);
        if (taskDir != null && part.equals(taskDir.getName())) {
            split[i] = task.getName();
            continue;
        }
        Lesson lesson = task.getLesson();
        int lessonIndex = lesson.getIndex();
        if (part.equals(EduNames.LESSON + lessonIndex)) {
            split[i] = lesson.getName();
        }
    }
    return StringUtil.join(split, File.separator);
}
Also used : TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Task(com.jetbrains.edu.learning.courseFormat.Task) UniqueNameEditorTabTitleProvider(com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider) Lesson(com.jetbrains.edu.learning.courseFormat.Lesson) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

UniqueNameEditorTabTitleProvider (com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Lesson (com.jetbrains.edu.learning.courseFormat.Lesson)1 Task (com.jetbrains.edu.learning.courseFormat.Task)1 TaskFile (com.jetbrains.edu.learning.courseFormat.TaskFile)1 Nullable (org.jetbrains.annotations.Nullable)1