Search in sources :

Example 1 with ErrorStripe

use of com.intellij.ui.stripe.ErrorStripe 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)1 PresentationData (com.intellij.ide.projectView.PresentationData)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 PresentableNodeDescriptor (com.intellij.ide.util.treeView.PresentableNodeDescriptor)1 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 ErrorStripe (com.intellij.ui.stripe.ErrorStripe)1 ErrorStripePainter (com.intellij.ui.stripe.ErrorStripePainter)1 Activatable (com.intellij.util.ui.update.Activatable)1 UiNotifyConnector (com.intellij.util.ui.update.UiNotifyConnector)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1