Search in sources :

Example 11 with PresentationData

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

Example 12 with PresentationData

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

the class DirectoryPresentationProvider method getPresentation.

@Override
public ItemPresentation getPresentation(@NotNull final PsiDirectory directory) {
    final VirtualFile vFile = directory.getVirtualFile();
    final Project project = directory.getProject();
    final String locationString = vFile.getPath();
    if (ProjectRootsUtil.isProjectHome(directory)) {
        final Icon projectIcon = PlatformUtils.isJetBrainsProduct() ? AllIcons.Nodes.IdeaProject : IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl());
        return new PresentationData(project.getName(), locationString, projectIcon, null);
    }
    if (ProjectRootsUtil.isModuleContentRoot(directory)) {
        final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile);
        assert module != null : directory;
        return new PresentationData(module.getName(), locationString, PlatformIcons.CONTENT_ROOT_ICON_CLOSED, null);
    }
    if (ProjectRootsUtil.isSourceRoot(directory)) {
        SourceFolder sourceRoot = ProjectRootsUtil.getModuleSourceRoot(vFile, project);
        if (sourceRoot != null) {
            Icon icon = SourceRootPresentation.getSourceRootIcon(sourceRoot);
            return new PresentationData(directory.getName(), locationString, icon, null);
        }
    }
    return new PresentationData(directory.getName(), locationString, PlatformIcons.DIRECTORY_CLOSED_ICON, null);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) SourceFolder(com.intellij.openapi.roots.SourceFolder) PresentationData(com.intellij.ide.projectView.PresentationData) Module(com.intellij.openapi.module.Module)

Example 13 with PresentationData

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

the class BreakpointsFavoriteListProvider method replicate.

private void replicate(DefaultMutableTreeNode source, AbstractTreeNode destination, final List<AbstractTreeNode<Object>> destinationChildren) {
    final ArrayList<AbstractTreeNode<Object>> copyChildren = new ArrayList<>();
    AbstractTreeNode<Object> copy = new AbstractTreeNode<Object>(myProject, source.getUserObject()) {

        @NotNull
        @Override
        public Collection<? extends AbstractTreeNode> getChildren() {
            return copyChildren;
        }

        @Override
        protected void update(PresentationData presentation) {
        }
    };
    for (int i = 0; i < source.getChildCount(); i++) {
        final TreeNode treeNode = source.getChildAt(i);
        if (treeNode instanceof DefaultMutableTreeNode) {
            final DefaultMutableTreeNode sourceChild = (DefaultMutableTreeNode) treeNode;
            replicate(sourceChild, copy, copyChildren);
        }
    }
    if (checkNavigatable(copy)) {
        destinationChildren.add(copy);
        copy.setParent(destination);
    }
}
Also used : PresentationData(com.intellij.ide.projectView.PresentationData) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode)

Example 14 with PresentationData

use of com.intellij.ide.projectView.PresentationData in project android by JetBrains.

the class AbstractPsModelNode method doUpdate.

@Override
protected void doUpdate() {
    PresentationData presentation = getTemplatePresentation();
    presentation.clearText();
    presentation.addText(myName, REGULAR_ATTRIBUTES);
}
Also used : PresentationData(com.intellij.ide.projectView.PresentationData)

Aggregations

PresentationData (com.intellij.ide.projectView.PresentationData)14 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)3 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)3 PresentableNodeDescriptor (com.intellij.ide.util.treeView.PresentableNodeDescriptor)2 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 List (java.util.List)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 PsIssue (com.android.tools.idea.gradle.structure.model.PsIssue)1 PsModel (com.android.tools.idea.gradle.structure.model.PsModel)1 ExporterToTextFile (com.intellij.ide.ExporterToTextFile)1 BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)1 ProjectViewNode (com.intellij.ide.projectView.ProjectViewNode)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 NodeDescriptor (com.intellij.ide.util.treeView.NodeDescriptor)1