public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf,
int row, boolean hasFocus)
{
if (value instanceof PackageDependenciesNode)
{
PackageDependenciesNode node = (PackageDependenciesNode) value;
try
{
setIcon(expanded ? node.getOpenIcon() : node.getClosedIcon());
}
catch (IndexNotReadyException ignore)
{
}
final SimpleTextAttributes regularAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
TextAttributes textAttributes = regularAttributes.toTextAttributes();
if (node instanceof BasePsiNode && ((BasePsiNode) node).isDeprecated())
{
textAttributes =
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.DEPRECATED_ATTRIBUTES)
.clone();
}
PsiElement psiElement = node.getPsiElement();
VirtualFile vFile = (psiElement == null)
? null
: ((psiElement instanceof PsiDirectory)
? ((PsiDirectory) psiElement).getVirtualFile()
: (psiElement.getContainingFile() == null) ? null : psiElement.getContainingFile().getVirtualFile());
String reviewName = scopeTreeViewPanel.CURRENT_SCOPE_NAME;
if (reviewName == null)
{
return;
}
Review review = project.getComponent(ReviewManager.class).getReviewByName(reviewName);
if (review != null)
{
FileStatus fileStatus = retrieveFileStatus(review, vFile);
textAttributes.setForegroundColor(fileStatus.getColor());
}
append(node.toString(), SimpleTextAttributes.fromTextAttributes(textAttributes));
String oldToString = toString();
for (ProjectViewNodeDecorator decorator : Extensions.getExtensions(ProjectViewNodeDecorator.EP_NAME, myProject))
{
decorator.decorate(node, this);
}
if (review != null)
{
int issueCount = retrieveIssueCount(review, vFile);
if (issueCount > 0)
{
append(" [" + RevuBundle.message("projectView.issueCount.text", issueCount) + "]",
SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}
if (toString().equals(oldToString))
{ // nothing was decorated
final String locationString = node.getComment();
if (locationString != null && locationString.length() > 0)
{
append(" (" + locationString + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}