String pageName = (value != null) ? value.toString() : "";
String text = pageName;
Boolean disambiguation = null;
Boolean exist = null;
boolean redirect = false;
InternalLinkCount count = null;
if (value instanceof Page) {
Page pageElement = (Page) value;
pageName = pageElement.getTitle();
text = pageName;
disambiguation = pageElement.isDisambiguationPage();
exist = pageElement.isExisting();
count = (analysis != null) ? analysis.getLinkCount(pageElement) : null;
if (showCountOccurrence &&
(count != null) &&
(count.getTotalLinkCount() > 0)) {
text += " → " + count.getTotalLinkCount();
}
redirect = pageElement.isRedirect();
if (redirect && showRedirectBacklinks) {
Integer backlinks = pageElement.getBacklinksCountInMainNamespace();
if ((backlinks != null) && (backlinks.intValue() > 0)) {
text += " ← " + backlinks;
}
}
}
// Text
setText(text);
// Color
Color background = isSelected ? list.getSelectionBackground() : Color.WHITE;
Color foreground = isSelected ? list.getSelectionForeground() : list.getForeground();
if (showDisambiguation) {
if (disambiguation == null) {
if (!isSelected) {
foreground = Color.DARK_GRAY;
}
} else if (disambiguation.booleanValue()) {
if (count == null) {
foreground = Color.RED;
} else if ((count.getInternalLinkCount() > 0) || (count.getIncorrectTemplateCount() > 0)) {
foreground = Color.RED;
} else if ((count.getHelpNeededCount() > 0)) {
foreground = Color.ORANGE;
} else {
foreground = Color.BLUE;
}
}