Search in sources :

Example 16 with PsiDirectory

use of com.intellij.psi.PsiDirectory in project intellij-plugins by StepicOrg.

the class NavBarModelExtensionUtils method getPresentableText.

@Nullable
public static String getPresentableText(@Nullable final Object object) {
    if (object instanceof Project) {
        Project project = (Project) object;
        StudyNode root = StepikProjectManager.getProjectRoot(project);
        if (root == null) {
            return null;
        }
        return root.getName();
    }
    if (object instanceof PsiDirectory) {
        PsiDirectory psiDirectory = (PsiDirectory) object;
        PresentationData data = new PresentationData();
        updatePresentationData(data, psiDirectory);
        String text = data.getPresentableText();
        if (text != null)
            return text;
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) PresentationData(com.intellij.ide.projectView.PresentationData) PresentationDataUtils.updatePresentationData(org.stepik.plugin.utils.PresentationDataUtils.updatePresentationData) PsiDirectory(com.intellij.psi.PsiDirectory) StudyNode(org.stepik.core.courseFormat.StudyNode) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with PsiDirectory

use of com.intellij.psi.PsiDirectory 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 18 with PsiDirectory

use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.

the class CCCreateLesson method createItemDir.

@Override
@Nullable
protected PsiDirectory createItemDir(@NotNull final Project project, @NotNull final StudyItem item, @Nullable final IdeView view, @NotNull final PsiDirectory parentDirectory, @NotNull final Course course) {
    CCLessonCreator creator = CCLessonCreator.INSTANCE.forLanguage(course.getLanguageById());
    if (creator != null) {
        return creator.createLesson(project, item, view, parentDirectory, course);
    }
    final PsiDirectory[] lessonDirectory = new PsiDirectory[1];
    ApplicationManager.getApplication().runWriteAction(() -> {
        lessonDirectory[0] = DirectoryUtil.createSubdirectories(EduNames.LESSON + item.getIndex(), parentDirectory, "\\/");
    });
    if (lessonDirectory[0] != null) {
        if (view != null) {
            view.selectElement(lessonDirectory[0]);
        }
    }
    return lessonDirectory[0];
}
Also used : PsiDirectory(com.intellij.psi.PsiDirectory) CCLessonCreator(com.jetbrains.edu.coursecreator.creation.CCLessonCreator) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with PsiDirectory

use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.

the class CCCreateStudyItemActionBase method update.

@Override
public void update(@NotNull AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    presentation.setEnabledAndVisible(false);
    final Project project = event.getData(CommonDataKeys.PROJECT);
    final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
    if (project == null || view == null) {
        return;
    }
    if (!StudyUtils.isStudyProject(project) || !CCUtils.isCourseCreator(project)) {
        return;
    }
    final PsiDirectory[] directories = view.getDirectories();
    if (directories.length == 0) {
        return;
    }
    final PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
    final Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null || sourceDirectory == null) {
        return;
    }
    if (!isAddedAsLast(sourceDirectory, project, course) && getThresholdItem(course, sourceDirectory) == null) {
        return;
    }
    if (CommonDataKeys.PSI_FILE.getData(event.getDataContext()) != null) {
        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) Course(com.jetbrains.edu.learning.courseFormat.Course)

Example 20 with PsiDirectory

use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.

the class CCCreateStudyItemActionBase method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    final Project project = e.getProject();
    if (view == null || project == null) {
        return;
    }
    final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
    if (directory == null)
        return;
    final Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null) {
        return;
    }
    createItem(view, project, directory, course);
}
Also used : Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView) Course(com.jetbrains.edu.learning.courseFormat.Course)

Aggregations

PsiDirectory (com.intellij.psi.PsiDirectory)321 VirtualFile (com.intellij.openapi.vfs.VirtualFile)122 PsiFile (com.intellij.psi.PsiFile)111 PsiElement (com.intellij.psi.PsiElement)79 Project (com.intellij.openapi.project.Project)73 Module (com.intellij.openapi.module.Module)68 Nullable (org.jetbrains.annotations.Nullable)62 NotNull (org.jetbrains.annotations.NotNull)50 IdeView (com.intellij.ide.IdeView)31 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)24 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)24 PsiManager (com.intellij.psi.PsiManager)24 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)20 ArrayList (java.util.ArrayList)20 PsiPackage (com.intellij.psi.PsiPackage)17 File (java.io.File)15 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)11 IncorrectOperationException (com.intellij.util.IncorrectOperationException)11 Course (com.jetbrains.edu.learning.courseFormat.Course)11 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)10