private void update(PsiElement element) { if (element != null && element.isValid()) { final ItemPresentation presentation = ((NavigationItem)element).getPresentation(); myIconOpen = presentation == null ? null : ComputableIcon.create(presentation, true); myIconClosed = presentation == null ? null : ComputableIcon.create(presentation, false); myPresentableText = presentation == null ? UsageViewUtil.createNodeText(element) : presentation.getPresentableText(); if (myIconOpen == null || myIconClosed == null) { if (element instanceof PsiMetaOwner) { final PsiMetaOwner psiMetaOwner = (PsiMetaOwner)element; final PsiMetaData metaData = psiMetaOwner.getMetaData(); if (metaData instanceof PsiPresentableMetaData) { final PsiPresentableMetaData psiPresentableMetaData = (PsiPresentableMetaData)metaData; if (myIconOpen == null) myIconOpen = ComputableIcon.create(psiPresentableMetaData); if (myIconClosed == null) myIconClosed = ComputableIcon.create(psiPresentableMetaData); } } else if (element instanceof PsiFile) { final PsiFile psiFile = (PsiFile)element; final VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile != null) { myIconOpen = ComputableIcon.create(virtualFile); myIconClosed = ComputableIcon.create(virtualFile); } } } } }
public void update() { final PsiElement element = getElement(); if (element != null && element.isValid()) { final ItemPresentation presentation = ((NavigationItem)element).getPresentation(); myIconOpen = presentation != null ? ComputableIcon.create(presentation, true) : null; myIconClosed = presentation != null ? ComputableIcon.create(presentation, false) : null; myPresentableText = presentation != null ? presentation.getPresentableText() : UsageViewUtil.createNodeText(element); if (myIconOpen == null || myIconClosed == null) { if (element instanceof PsiMetaOwner) { final PsiMetaOwner psiMetaOwner = (PsiMetaOwner)element; final PsiMetaData metaData = psiMetaOwner.getMetaData(); if (metaData instanceof PsiPresentableMetaData) { final PsiPresentableMetaData psiPresentableMetaData = (PsiPresentableMetaData)metaData; if (myIconOpen == null) myIconOpen = ComputableIcon.create(psiPresentableMetaData); if (myIconClosed == null) myIconClosed = ComputableIcon.create(psiPresentableMetaData); } } else if (element instanceof PsiFile) { final PsiFile psiFile = (PsiFile)element; final VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile != null) { myIconOpen = ComputableIcon.create(virtualFile); myIconClosed = ComputableIcon.create(virtualFile); } } } } }
@Override public Icon getIcon(boolean open) { final ComputableIcon computableIcon = open ? myIconOpen : myIconClosed; return computableIcon == null ? null : computableIcon.getIcon(); }
@Override public Icon getIcon(boolean open) { final ComputableIcon computableIcon = open ? myIconOpen : myIconClosed; return computableIcon == null? null : computableIcon.getIcon(); }