Search in sources :

Example 1 with AbstractModuleNode

use of com.intellij.ide.projectView.impl.nodes.AbstractModuleNode in project intellij-community by JetBrains.

the class AbstractProjectViewPane method doSelectModuleOrGroup.

private void doSelectModuleOrGroup(final Object toSelect, final boolean requestFocus) {
    ToolWindowManager windowManager = ToolWindowManager.getInstance(myProject);
    final Runnable runnable = () -> {
        ProjectView projectView = ProjectView.getInstance(myProject);
        if (requestFocus) {
            projectView.changeView(getId(), getSubId());
        }
        ((BaseProjectTreeBuilder) getTreeBuilder()).selectInWidth(toSelect, requestFocus, node -> node instanceof AbstractModuleNode || node instanceof ModuleGroupNode || node instanceof AbstractProjectNode);
    };
    if (requestFocus) {
        windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW).activate(runnable);
    } else {
        runnable.run();
    }
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) AbstractProjectNode(com.intellij.ide.projectView.impl.nodes.AbstractProjectNode) VirtualFileWindow(com.intellij.injected.editor.VirtualFileWindow) UIUtil(com.intellij.util.ui.UIUtil) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) BaseProjectTreeBuilder(com.intellij.ide.projectView.BaseProjectTreeBuilder) com.intellij.ide.util.treeView(com.intellij.ide.util.treeView) VirtualFile(com.intellij.openapi.vfs.VirtualFile) HashMap(com.intellij.util.containers.HashMap) ProjectView(com.intellij.ide.projectView.ProjectView) Map(java.util.Map) MoveHandler(com.intellij.refactoring.move.MoveHandler) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) Module(com.intellij.openapi.module.Module) ReflectionUtil(com.intellij.util.ReflectionUtil) AbstractModuleNode(com.intellij.ide.projectView.impl.nodes.AbstractModuleNode) ModuleUtilCore(com.intellij.openapi.module.ModuleUtilCore) TreePath(javax.swing.tree.TreePath) BufferedImage(java.awt.image.BufferedImage) DnDAwareTree(com.intellij.ide.dnd.aware.DnDAwareTree) SelectInTarget(com.intellij.ide.SelectInTarget) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) PsiUtilCore(com.intellij.psi.util.PsiUtilCore) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Registry(com.intellij.openapi.util.registry.Registry) DataProvider(com.intellij.openapi.actionSystem.DataProvider) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) ArrayUtil(com.intellij.util.ArrayUtil) DataContext(com.intellij.openapi.actionSystem.DataContext) TreeNode(javax.swing.tree.TreeNode) Transferable(java.awt.datatransfer.Transferable) NonNls(org.jetbrains.annotations.NonNls) DnDConstants(java.awt.dnd.DnDConstants) ContainerUtil(com.intellij.util.containers.ContainerUtil) ArrayList(java.util.ArrayList) PsiCopyPasteManager(com.intellij.ide.PsiCopyPasteManager) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) ToolWindowId(com.intellij.openapi.wm.ToolWindowId) Project(com.intellij.openapi.project.Project) com.intellij.ide.dnd(com.intellij.ide.dnd) DataManager(com.intellij.ide.DataManager) TreeUtil(com.intellij.util.ui.tree.TreeUtil) Disposable(com.intellij.openapi.Disposable) File(java.io.File) ExtensionPointName(com.intellij.openapi.extensions.ExtensionPointName) java.awt(java.awt) WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver) Navigatable(com.intellij.pom.Navigatable) Element(org.jdom.Element) Collections(java.util.Collections) ModuleGroupNode(com.intellij.ide.projectView.impl.nodes.ModuleGroupNode) javax.swing(javax.swing) AbstractModuleNode(com.intellij.ide.projectView.impl.nodes.AbstractModuleNode) AbstractProjectNode(com.intellij.ide.projectView.impl.nodes.AbstractProjectNode) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ProjectView(com.intellij.ide.projectView.ProjectView) ModuleGroupNode(com.intellij.ide.projectView.impl.nodes.ModuleGroupNode)

Example 2 with AbstractModuleNode

use of com.intellij.ide.projectView.impl.nodes.AbstractModuleNode in project intellij-community by JetBrains.

the class AbstractProjectViewPane method getSelectedDirectoriesInAmbiguousCase.

@NotNull
protected PsiDirectory[] getSelectedDirectoriesInAmbiguousCase(@NotNull final DefaultMutableTreeNode node) {
    final Object userObject = node.getUserObject();
    if (userObject instanceof AbstractModuleNode) {
        final Module module = ((AbstractModuleNode) userObject).getValue();
        if (module != null) {
            final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
            final VirtualFile[] sourceRoots = moduleRootManager.getSourceRoots();
            List<PsiDirectory> dirs = new ArrayList<>(sourceRoots.length);
            final PsiManager psiManager = PsiManager.getInstance(myProject);
            for (final VirtualFile sourceRoot : sourceRoots) {
                final PsiDirectory directory = psiManager.findDirectory(sourceRoot);
                if (directory != null) {
                    dirs.add(directory);
                }
            }
            return dirs.toArray(new PsiDirectory[dirs.size()]);
        }
    }
    return PsiDirectory.EMPTY_ARRAY;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AbstractModuleNode(com.intellij.ide.projectView.impl.nodes.AbstractModuleNode) ArrayList(java.util.ArrayList) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AbstractModuleNode (com.intellij.ide.projectView.impl.nodes.AbstractModuleNode)2 Module (com.intellij.openapi.module.Module)2 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 DataManager (com.intellij.ide.DataManager)1 PsiCopyPasteManager (com.intellij.ide.PsiCopyPasteManager)1 SelectInTarget (com.intellij.ide.SelectInTarget)1 com.intellij.ide.dnd (com.intellij.ide.dnd)1 DnDAwareTree (com.intellij.ide.dnd.aware.DnDAwareTree)1 BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)1 ProjectView (com.intellij.ide.projectView.ProjectView)1 AbstractProjectNode (com.intellij.ide.projectView.impl.nodes.AbstractProjectNode)1 ModuleGroupNode (com.intellij.ide.projectView.impl.nodes.ModuleGroupNode)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 com.intellij.ide.util.treeView (com.intellij.ide.util.treeView)1 VirtualFileWindow (com.intellij.injected.editor.VirtualFileWindow)1 Disposable (com.intellij.openapi.Disposable)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1