use of com.jetbrains.edu.learning.courseFormat.TaskFile in project intellij-community by JetBrains.
the class CCStudyActionListener method beforeCheck.
@Override
public void beforeCheck(AnActionEvent event) {
Project project = event.getProject();
if (project == null) {
return;
}
if (!CCUtils.isCourseCreator(project)) {
return;
}
VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(event.getDataContext());
if (virtualFile == null) {
return;
}
TaskFile taskFile = StudyUtils.getTaskFile(project, virtualFile);
if (taskFile == null) {
return;
}
Task task = taskFile.getTask();
VirtualFile taskDir = StudyUtils.getTaskDir(virtualFile);
if (taskDir == null) {
return;
}
CCUtils.updateResources(project, task, taskDir);
}
use of com.jetbrains.edu.learning.courseFormat.TaskFile 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.TaskFile 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);
}
use of com.jetbrains.edu.learning.courseFormat.TaskFile in project intellij-community by JetBrains.
the class CCAnswerPlaceholderActionTest method doTest.
private void doTest(String name, AnAction action) {
VirtualFile virtualFile = configureByTaskFile(name + CCTestsUtil.BEFORE_POSTFIX);
myFixture.testAction(action);
TaskFile taskFile = StudyUtils.getTaskFile(getProject(), virtualFile);
checkByFile(taskFile, name + CCTestsUtil.AFTER_POSTFIX, false);
checkHighlighters(taskFile, myFixture.getEditor().getMarkupModel());
UndoManager.getInstance(getProject()).undo(FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile));
checkByFile(taskFile, name + CCTestsUtil.BEFORE_POSTFIX, false);
}
use of com.jetbrains.edu.learning.courseFormat.TaskFile in project intellij-community by JetBrains.
the class CCTaskFileActionTest method testAddTaskFile.
public void testAddTaskFile() {
VirtualFile virtualFile = copyFileToTask("nonTaskFile.txt");
myFixture.configureFromExistingVirtualFile(virtualFile);
launchAction(virtualFile, new CCAddAsTaskFile());
TaskFile taskFile = StudyUtils.getTaskFile(getProject(), virtualFile);
assertNotNull(taskFile);
FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile);
UndoManager.getInstance(getProject()).undo(fileEditor);
assertNull(StudyUtils.getTaskFile(getProject(), virtualFile));
}
Aggregations