@Override protected boolean customizeNonPsiElementLeftRenderer( ColoredListCellRenderer renderer, JList list, Object value, int index, boolean selected, boolean hasFocus) { if (!(value instanceof NavigationItem)) return false; NavigationItem item = (NavigationItem) value; TextAttributes attributes = getNavigationItemAttributes(item); SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null; Color color = list.getForeground(); if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(Font.PLAIN, color); renderer.append(item + " ", nameAttributes); ItemPresentation itemPresentation = item.getPresentation(); assert itemPresentation != null; renderer.setIcon(itemPresentation.getIcon(true)); String locationString = itemPresentation.getLocationString(); if (!StringUtil.isEmpty(locationString)) { renderer.append(locationString, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY)); } return true; }
@NotNull public String getNodeText(@NotNull PsiElement element, boolean useFullName) { if (useFullName) { if (element instanceof NavigationItem) { final NavigationItem navigationItem = ((NavigationItem) element); final ItemPresentation presentation = navigationItem.getPresentation(); if (presentation != null && presentation.getPresentableText() != null) { return presentation.getPresentableText(); } final String name = navigationItem.getName(); if (name != null) { return name; } } } if (element instanceof PsiNamedElement) { final String name = ((PsiNamedElement) element).getName(); if (name != null) return name; } return element.toString(); }