use of com.intellij.openapi.project.Project 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.intellij.openapi.project.Project 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.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class CCChangeCourseInfo method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
return;
}
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
CCNewProjectPanel panel = new CCNewProjectPanel(course.getName(), Course.getAuthorsString(course.getAuthors()), course.getDescription());
setupLanguageLevels(course, panel);
DialogBuilder builder = createChangeInfoDialog(project, panel);
if (builder.showAndGet()) {
course.setAuthorsAsString(panel.getAuthors());
course.setName(panel.getName());
course.setDescription(panel.getDescription());
setVersion(course, panel);
ProjectView.getInstance(project).refresh();
ProjectInspectionProfileManager.getInstance(project).fireProfileChanged();
}
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class CCChangeCourseInfo method update.
@Override
public void update(@NotNull AnActionEvent event) {
final Project project = event.getProject();
final Presentation presentation = event.getPresentation();
if (project == null) {
return;
}
presentation.setEnabledAndVisible(false);
if (!CCUtils.isCourseCreator(project)) {
return;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return;
}
presentation.setEnabledAndVisible(true);
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class CCCreateCourseArchive method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final Module module = e.getData(LangDataKeys.MODULE);
if (project == null || module == null) {
return;
}
CreateCourseArchiveDialog dlg = new CreateCourseArchiveDialog(project, this);
dlg.show();
if (dlg.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
return;
}
createCourseArchive(project, module, myZipName, myLocationDir, true);
EduUsagesCollector.createdCourseArchive();
}
Aggregations