public final boolean update() { boolean changes = super.update(); if (getPsiElement() == null) { final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid"); if (!myHighlightedText.getText().startsWith(invalidPrefix)) { myHighlightedText .getBeginning() .addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes()); } return true; } if (changes && myIsBase) { final LayeredIcon icon = new LayeredIcon(2); icon.setIcon(getIcon(), 0); icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0); setIcon(icon); } final PsiElement psiElement = getPsiClass(); final CompositeAppearance oldText = myHighlightedText; myHighlightedText = new CompositeAppearance(); TextAttributes classNameAttributes = null; if (myColor != null) { classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN); } if (psiElement instanceof PsiClass) { myHighlightedText .getEnding() .addText( ClassPresentationUtil.getNameForClass((PsiClass) psiElement, false), classNameAttributes); myHighlightedText .getEnding() .addText( " (" + JavaHierarchyUtil.getPackageName((PsiClass) psiElement) + ")", HierarchyNodeDescriptor.getPackageNameAttributes()); } else if (psiElement instanceof PsiFunctionalExpression) { myHighlightedText .getEnding() .addText( ClassPresentationUtil.getFunctionalExpressionPresentation( ((PsiFunctionalExpression) psiElement), false)); } myName = myHighlightedText.getText(); if (!Comparing.equal(myHighlightedText, oldText)) { changes = true; } return changes; }
@Override public final boolean update() { CompositeAppearance oldText = myHighlightedText; Icon oldIcon = getIcon(); int flags = Iconable.ICON_FLAG_VISIBILITY; if (isMarkReadOnly()) { flags |= Iconable.ICON_FLAG_READ_STATUS; } boolean changes = super.update(); PsiElement targetElement = getTargetElement(); String elementText = renderElement(targetElement); if (elementText == null) { String invalidPrefix = IdeBundle.message("node.hierarchy.invalid"); if (!myHighlightedText.getText().startsWith(invalidPrefix)) { myHighlightedText .getBeginning() .addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes()); } return true; } Icon newIcon = targetElement.getIcon(flags); if (changes && myIsBase) { LayeredIcon icon = new LayeredIcon(2); icon.setIcon(newIcon, 0); icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0); newIcon = icon; } setIcon(newIcon); myHighlightedText = new CompositeAppearance(); TextAttributes mainTextAttributes = null; if (myColor != null) { mainTextAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN); } String packageName = null; if (targetElement instanceof JetElement) { packageName = JetPsiUtil.getPackageName((JetElement) targetElement); } else { PsiClass enclosingClass = PsiTreeUtil.getParentOfType(targetElement, PsiClass.class, false); if (enclosingClass != null) { packageName = JavaHierarchyUtil.getPackageName(enclosingClass); } } myHighlightedText.getEnding().addText(elementText, mainTextAttributes); if (usageCount > 1) { myHighlightedText .getEnding() .addText( IdeBundle.message("node.call.hierarchy.N.usages", usageCount), HierarchyNodeDescriptor.getUsageCountPrefixAttributes()); } if (packageName == null) { packageName = ""; } myHighlightedText .getEnding() .addText(" (" + packageName + ")", HierarchyNodeDescriptor.getPackageNameAttributes()); myName = myHighlightedText.getText(); if (!(Comparing.equal(myHighlightedText, oldText) && Comparing.equal(getIcon(), oldIcon))) { changes = true; } return changes; }