use of com.intellij.ui.stripe.ErrorStripePainter 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;
}
Aggregations