c62bd5e1e069935658d820f8a6e93e5e4547e6df
[idea/community.git] / python / educational-core / course-creator / src / com / jetbrains / edu / coursecreator / actions / CCAddAsTaskFile.java
1 package com.jetbrains.edu.coursecreator.actions;
2
3 import com.intellij.openapi.project.Project;
4 import com.intellij.openapi.vfs.VirtualFile;
5 import com.jetbrains.edu.coursecreator.CCUtils;
6 import com.jetbrains.edu.learning.StudyUtils;
7 import com.jetbrains.edu.learning.courseFormat.Course;
8 import com.jetbrains.edu.learning.courseFormat.Task;
9
10 public class CCAddAsTaskFile extends CCTaskFileActionBase {
11
12   protected void performAction(VirtualFile file, Task task, Course course, Project project) {
13     task.addTaskFile(file.getName(), task.getTaskFiles().size());
14     CCUtils.createResourceFile(file, course, StudyUtils.getTaskDir(file));
15   }
16
17   protected boolean isAvailable(Project project, VirtualFile file) {
18     return StudyUtils.getTaskFile(project, file) == null && !CCUtils.isTestsFile(project, file);
19   }
20 }