Search in sources :

Example 41 with Project

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) Project(com.intellij.openapi.project.Project) Task(com.jetbrains.edu.learning.courseFormat.Task)

Example 42 with Project

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);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) Project(com.intellij.openapi.project.Project) Course(com.jetbrains.edu.learning.courseFormat.Course)

Example 43 with 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();
    }
}
Also used : Project(com.intellij.openapi.project.Project) Course(com.jetbrains.edu.learning.courseFormat.Course) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) CCNewProjectPanel(com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel)

Example 44 with Project

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);
}
Also used : Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) Presentation(com.intellij.openapi.actionSystem.Presentation) IdeView(com.intellij.ide.IdeView)

Example 45 with Project

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();
}
Also used : Project(com.intellij.openapi.project.Project) CreateCourseArchiveDialog(com.jetbrains.edu.coursecreator.ui.CreateCourseArchiveDialog) Module(com.intellij.openapi.module.Module)

Aggregations

Project (com.intellij.openapi.project.Project)3623 VirtualFile (com.intellij.openapi.vfs.VirtualFile)874 NotNull (org.jetbrains.annotations.NotNull)580 Nullable (org.jetbrains.annotations.Nullable)478 Module (com.intellij.openapi.module.Module)368 PsiFile (com.intellij.psi.PsiFile)334 Editor (com.intellij.openapi.editor.Editor)301 PsiElement (com.intellij.psi.PsiElement)292 ArrayList (java.util.ArrayList)214 File (java.io.File)212 Document (com.intellij.openapi.editor.Document)180 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)172 List (java.util.List)158 IOException (java.io.IOException)107 TextRange (com.intellij.openapi.util.TextRange)99 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)96 IncorrectOperationException (com.intellij.util.IncorrectOperationException)95 Presentation (com.intellij.openapi.actionSystem.Presentation)94 DataContext (com.intellij.openapi.actionSystem.DataContext)92 PsiDirectory (com.intellij.psi.PsiDirectory)90