@Override
public void proceedToMergeTM(int percentage, MergeOptions mergeOptions) {
Collection<TransUnit> items = getNotTranslatedItems();
if (items.isEmpty()) {
eventBus.fireEvent(new NotificationEvent(Info, messages
.noTranslationToMerge()));
display.hide();
return;
}
display.showProcessing();
TransMemoryMerge action =
prepareTMMergeAction(items, percentage, mergeOptions);
dispatcher.execute(action, new AsyncCallback<UpdateTransUnitResult>() {
@Override
public void onFailure(Throwable caught) {
Log.warn("TM merge failed", caught);
eventBus.fireEvent(new NotificationEvent(Error, messages
.mergeTMFailed()));
display.hide();
}
@Override
public void onSuccess(final UpdateTransUnitResult result) {
if (result.getUpdateInfoList().isEmpty()) {
eventBus.fireEvent(new NotificationEvent(Info, messages
.noTranslationToMerge()));
} else {
final UndoLink undoLink = undoLinkProvider.get();
undoLink.prepareUndoFor(result);
List<String> rowIndicesOrNull =
Lists.transform(result.getUpdateInfoList(),
SuccessRowIndexOrNullFunction.FUNCTION);
Iterable<String> successRowIndices =
Iterables.filter(rowIndicesOrNull,
StringNotEmptyPredicate.INSTANCE);
Log.info("number of rows auto filled by TM merge: "
+ Iterables.size(successRowIndices));
NotificationEvent event =
new NotificationEvent(Info, messages
.mergeTMSuccess(Lists
.newArrayList(successRowIndices)),
undoLink);
eventBus.fireEvent(event);
}