Widget authorName = RenderUtilities.renderEntityName(author, "");
authorName.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageCommentAuthor());
body.add(authorName);
// parse the comment content
ContentSegment segments = new ContentParser().split(comment.getBody().trim());
boolean oversize = truncate && isTooLong(segments);
// build/display the comment content, truncating if too long
final ComplexPanel textContainer = new FlowPanel();
textContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageCommentText());
body.add(textContainer);
// render only up to the limit
Widget shortTextWidget = null;
int size = 0;
ContentSegment segment = segments;
for (; segment != null; segment = segment.getNext())
{
// check for when to stop
if (oversize && !segment.isTag())
{
int spaceLeft = TRUNCATE_LENGTH - size;
int contentLength = segment.getContent().length();
if (contentLength > spaceLeft)
{
if (segment.isText())
{
String shortText = getTruncatedText(segment.getContent(), spaceLeft);
if (shortText != null)
{
shortTextWidget = new InlineLabel(shortText);
textContainer.add(shortTextWidget);
}
}
break;
}
size += contentLength;
}
contentRenderer.renderSegment(segment, textContainer, searchLinkBuilder);
}
final ContentSegment remainingSegments = segment;
final Widget shortTextToReplace = shortTextWidget;
// if too long, add a ... and "show more" link
if (oversize)
{