private Widget appendComment(DiscussionRecord r) { SmallLabel hrd = new SmallLabel(constants.smallCommentBy0On1Small(r.author, new Date(r.timestamp))); hrd.addStyleName("discussion-header"); commentList.add(hrd); String[] parts = r.note.split("\n"); if (parts.length > 0) { StringBuilder txtBuilder = new StringBuilder(); for (int i = 0; i < parts.length; i++) { txtBuilder.append(parts[i]); if (i != parts.length - 1) { txtBuilder.append("<br/>"); } } HTML hth = new HTML(txtBuilder.toString()); hth.setStyleName("form-field"); commentList.add(hth); } else { Label lbl = new Label(r.note); lbl.setStyleName("form-field"); commentList.add(lbl); } commentList.add(new HTML("<br/>")); return hrd; }
// HashMap DOES NOT guarantee order in different iterations! private static KeyValueTO convertMapToCsv(final Map map) { StringBuilder keysBuilder = new StringBuilder(); StringBuilder valuesBuilder = new StringBuilder(); for (Object o : map.entrySet()) { Map.Entry entry = (Map.Entry) o; if (keysBuilder.length() > 0) { keysBuilder.append(","); } if (valuesBuilder.length() > 0) { valuesBuilder.append(","); } keysBuilder.append(entry.getKey()); valuesBuilder.append(entry.getValue()); } return new KeyValueTO(keysBuilder.toString(), valuesBuilder.toString()); }