Search in sources :

Example 11 with PsiDirectory

use of com.intellij.psi.PsiDirectory in project folding-plugin by dmytrodanylyk.

the class ProjectStructureProvider method modify.

@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings viewSettings) {
    List<AbstractTreeNode> resultList = new ArrayList<>();
    if (parent.getValue() instanceof PsiDirectory) {
        PsiDirectory directory = (PsiDirectory) parent.getValue();
        String path = directory.getVirtualFile().getPath();
        if (SettingsManager.isComposed(path)) {
            resultList.addAll(createComposedFiles(children, viewSettings));
        } else {
            resultList.addAll(children);
        }
    } else {
        resultList.addAll(children);
    }
    return resultList;
}
Also used : PsiDirectory(com.intellij.psi.PsiDirectory) ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with PsiDirectory

use of com.intellij.psi.PsiDirectory in project folding-plugin by dmytrodanylyk.

the class ComposeAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent actionEvent) {
    Object nav = actionEvent.getData(CommonDataKeys.NAVIGATABLE);
    if (nav instanceof PsiDirectory) {
        PsiDirectory directory = (PsiDirectory) nav;
        String path = directory.getVirtualFile().getPath();
        if (SettingsManager.isComposed(path)) {
            SettingsManager.removeComposedFolder(path);
        } else {
            SettingsManager.addComposedFolder(path);
        }
        Project project = actionEvent.getData(CommonDataKeys.PROJECT);
        if (project != null) {
            ProjectView.getInstance(project).refresh();
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory)

Example 13 with PsiDirectory

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

the class NavigationUtils method findNodeWithObject.

@Nullable
private static DefaultMutableTreeNode findNodeWithObject(@NotNull TreeNode root, PsiFileSystemItem file) {
    for (int i = 0; i < root.getChildCount(); i++) {
        TreeNode child = root.getChildAt(i);
        if (child instanceof DefaultMutableTreeNode) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) child;
            Object userObject = node.getUserObject();
            if (userObject instanceof PsiDirectoryNode) {
                PsiDirectoryNode directoryNode = (PsiDirectoryNode) userObject;
                PsiDirectory value = directoryNode.getValue();
                if (file.equals(value)) {
                    return node;
                }
            }
            node = findNodeWithObject(child, file);
            if (node != null) {
                return node;
            }
        }
    }
    return null;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) PsiDirectory(com.intellij.psi.PsiDirectory) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) Nullable(org.jetbrains.annotations.Nullable)

Example 14 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 15 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)

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