@Override
public void renderTable(List<TransMemoryResultItem> memories,
List<String> queries) {
currentQueries = queries;
for (int i = 0; i < memories.size(); i++) {
final TransMemoryResultItem item = memories.get(i);
resultTable.setWidget(i + 1, SOURCE_COL,
createSourcePanel(item, queries));
resultTable.setWidget(i + 1, TARGET_COL, createTargetPanel(item));
Label countLabel = new Label(String.valueOf(item.getMatchCount()));
countLabel
.setTitle(messages.matchCountTooltip(item.getMatchCount()));
resultTable.setWidget(i + 1, NUM_TRANS_COL, countLabel);
resultTable.getFlexCellFormatter().setStyleName(i + 1,
NUM_TRANS_COL, "txt--align-center");
if (odd(i)) {
resultTable.getRowFormatter().setStyleName(i + 1, "oddRow");
}
Button copyButton = new Button(messages.copy());
copyButton.setTitle(messages.copyTooltip());
copyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
listener.fireCopyEvent(item);
}
});
resultTable.setWidget(i + 1, ACTION_COL, copyButton);
resultTable.getFlexCellFormatter().setStyleName(i + 1, ACTION_COL,
"txt--align-center");
Label similarityLabel =
new Label((int) item.getSimilarityPercent() + "%");
resultTable.setWidget(i + 1, SIMILARITY_COL, similarityLabel);
resultTable.getFlexCellFormatter().setStyleName(i + 1,
SIMILARITY_COL, "txt--align-center");
Anchor infoCell = new Anchor();
if (item.getMatchType() == MatchType.Imported) {
String originStr = Joiner.on(", ").join(item.getOrigins());
infoCell.setText(shorten(originStr, 10));
infoCell.setTitle(originStr);
} else {
infoCell.setStyleName("i i--info txt--lead");
infoCell.addClickHandler(new ClickHandler() {