@SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"})
@SuppressWarnings({"HardCodedStringLiteral"})
public void setBugsDetails(final BugInstanceNode bugInstanceNode, final TreePath treePath) {
_currentTreePath = treePath;
final BugInstance bugInstance = bugInstanceNode.getBugInstance();
final int[] lines = BugInstanceUtil.getSourceLines(bugInstanceNode);
final MethodAnnotation methodAnnotation = BugInstanceUtil.getPrimaryMethod(bugInstance);
final FieldAnnotation fieldAnnotation = BugInstanceUtil.getPrimaryField(bugInstance);
final StringBuilder html = new StringBuilder();
html.append("<html><body>");
html.append("<h2>");
html.append(bugInstance.getAbridgedMessage());
html.append("</h2><p/>");
final SortedBugCollection bc = _lastBugCollection;
if (bc != null) {
final Cloud cloud = bc.getCloud();
//noinspection ConstantConditions
if (cloud != null) {
final int reviewers = cloud.getReviewers(bugInstance).size();
if (reviewers > 0) {
html.append(" - <a href='#comments'><u>");
html.append(reviewers);
html.append(" comment");
html.append(reviewers != 1 ? "s" : "");
html.append("</u></a>");
}
final UserDesignation designation = cloud.getConsensusDesignation(bugInstance);
if (designation != UserDesignation.UNCLASSIFIED) {
//List<String> userDesignationKeys = I18N.instance().getUserDesignationKeys(true);
html.append(" - \"");
html.append(I18N.instance().getUserDesignation(designation.name()));
html.append('\"');
}
final int ageInDays = (int) ((System.currentTimeMillis() - cloud.getFirstSeen(bugInstance)) / (1000 * 60 * 60 * 24));
if (cloud.isInCloud(bugInstance) && ageInDays > 0) {
html.append(" - first seen ");
html.append(ageInDays);
html.append(" day");
html.append(ageInDays != 1 ? "s" : "");
html.append(" ago");
}
}
}
html.append("<table border=0><tr valign=top><td valign=top>");
html.append("<h3>Class:</h3>");
html.append("<ul>");
html.append("<li>");
html.append("<a href='#class'><u>");
html.append(BugInstanceUtil.getSimpleClassName(bugInstance));
html.append("</u></a>");
html.append(" <font color='gray'>(");
final String packageName = BugInstanceUtil.getPackageName(bugInstance);
html.append(packageName);
html.append(")</font>");
if (lines[0] > -1) {
final boolean singleLine = lines[1] == lines[0];
if (singleLine) {
html.append(" line ");
} else {
html.append(" lines ");
}
html.append(lines[0]);
if (!singleLine) {
html.append('-').append(lines[1]);
}
}
html.append("</ul>");
if (methodAnnotation != null) {
html.append("<p><h3>Method:</p>");
html.append("<ul>");
html.append("<li>");
if ("<init>".equals(methodAnnotation.getMethodName())) {
html.append(BugInstanceUtil.getJavaSourceMethodName(bugInstance)).append("<init> <font color='gray'>(").append(BugInstanceUtil.getFullMethod(bugInstance)).append(")</font>");
} else {
html.append(BugInstanceUtil.getMethodName(bugInstance)).append(" <font color='gray'>(").append(BugInstanceUtil.getFullMethod(bugInstance)).append(")</font>");
}
html.append("</li>");
html.append("</ul>");
}
if (fieldAnnotation != null) {
html.append("<p><h3>Field:</p>");
html.append("<ul>");
html.append("<li>");
html.append(BugInstanceUtil.getFieldName(bugInstance));
html.append("</li>");
html.append("</ul>");
}
html.append("<p><h3>Priority:</p>");
html.append("<ul>");
html.append("<li>");
html.append("<span width='15px' height='15px;' id='").append(BugInstanceUtil.getPriorityString(bugInstance)).append("'> </span> ");
html.append(BugInstanceUtil.getPriorityTypeString(bugInstance));
html.append("</li>");
html.append("</ul>");
html.append("</td><td width='20px'> </td><td valign=top>");
html.append("<h3>Problem classification:</h3>");
html.append("<ul>");
html.append("<li>");
html.append(BugInstanceUtil.getBugCategoryDescription(bugInstance));
html.append(" <font color='gray'>(");
html.append(BugInstanceUtil.getBugTypeDescription(bugInstance));
html.append(")</font>");
html.append("</li>");
html.append("<li>");
html.append(BugInstanceUtil.getBugType(bugInstance));
html.append(" <font color='gray'>(");
html.append(BugInstanceUtil.getBugPatternShortDescription(bugInstance));
html.append(")</font>");
html.append("</li>");
final Iterable<BugAnnotation> annotations = bugInstance.getAnnotationsForMessage(false);
if (annotations.iterator().hasNext()) {
html.append("<p><h3>Notes:</p>");
html.append("<ul>");
for (final BugAnnotation annotation : annotations) {
html.append("<li>").append(annotation.toString(bugInstance.getPrimaryClass())).append("</li>");
}
html.append("</ul>");
}
final DetectorFactory detectorFactory = bugInstance.getDetectorFactory();
if (detectorFactory != null) {
html.append("<li>");
html.append(detectorFactory.getShortName());
html.append(" <font color='gray'>(");
html.append(DetectorConfiguration.createBugsAbbreviation(detectorFactory));