Search in sources :

Example 1 with BaseProjectTreeBuilder

use of com.intellij.ide.projectView.BaseProjectTreeBuilder 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 BaseProjectTreeBuilder

use of com.intellij.ide.projectView.BaseProjectTreeBuilder in project intellij-community by JetBrains.

the class AbstractProjectViewPSIPane method createComponent.

@Override
public JComponent createComponent() {
    if (myComponent != null)
        return myComponent;
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(null);
    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    myTree = createTree(treeModel);
    enableDnD();
    myComponent = ScrollPaneFactory.createScrollPane(myTree);
    if (Registry.is("error.stripe.enabled")) {
        ErrorStripePainter painter = new ErrorStripePainter(true);
        Disposer.register(this, new TreeUpdater<ErrorStripePainter>(painter, myComponent, myTree) {

            @Override
            protected void update(ErrorStripePainter painter, int index, Object object) {
                if (object instanceof DefaultMutableTreeNode) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
                    object = node.getUserObject();
                }
                if (object instanceof PsiDirectoryNode && !myTree.isCollapsed(index)) {
                    object = null;
                }
                super.update(painter, index, object);
            }

            @Override
            protected ErrorStripe getErrorStripe(Object object) {
                if (object instanceof PresentableNodeDescriptor) {
                    PresentableNodeDescriptor node = (PresentableNodeDescriptor) object;
                    PresentationData presentation = node.getPresentation();
                    TextAttributesKey key = presentation.getTextAttributesKey();
                    if (key != null) {
                        TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
                        if (attributes != null && EffectType.WAVE_UNDERSCORE == attributes.getEffectType()) {
                            return ErrorStripe.create(attributes.getEffectColor(), 1);
                        }
                    }
                }
                return null;
            }
        });
    }
    myTreeStructure = createStructure();
    BaseProjectTreeBuilder treeBuilder = createBuilder(treeModel);
    installComparator(treeBuilder);
    setTreeBuilder(treeBuilder);
    initTree();
    Disposer.register(getTreeBuilder(), new UiNotifyConnector(myTree, new Activatable() {

        private boolean showing;

        @Override
        public void showNotify() {
            if (!showing) {
                showing = true;
                restoreExpandedPaths();
            }
        }

        @Override
        public void hideNotify() {
            if (showing) {
                showing = false;
                saveExpandedPaths();
            }
        }
    }));
    return myComponent;
}
Also used : ErrorStripe(com.intellij.ui.stripe.ErrorStripe) PresentableNodeDescriptor(com.intellij.ide.util.treeView.PresentableNodeDescriptor) PresentationData(com.intellij.ide.projectView.PresentationData) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Activatable(com.intellij.util.ui.update.Activatable) ErrorStripePainter(com.intellij.ui.stripe.ErrorStripePainter) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) BaseProjectTreeBuilder(com.intellij.ide.projectView.BaseProjectTreeBuilder)

Aggregations

BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)2 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)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 PresentationData (com.intellij.ide.projectView.PresentationData)1 ProjectView (com.intellij.ide.projectView.ProjectView)1 AbstractModuleNode (com.intellij.ide.projectView.impl.nodes.AbstractModuleNode)1 AbstractProjectNode (com.intellij.ide.projectView.impl.nodes.AbstractProjectNode)1 ModuleGroupNode (com.intellij.ide.projectView.impl.nodes.ModuleGroupNode)1 com.intellij.ide.util.treeView (com.intellij.ide.util.treeView)1 PresentableNodeDescriptor (com.intellij.ide.util.treeView.PresentableNodeDescriptor)1 VirtualFileWindow (com.intellij.injected.editor.VirtualFileWindow)1 Disposable (com.intellij.openapi.Disposable)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 DataProvider (com.intellij.openapi.actionSystem.DataProvider)1