if (!canUndo) {
return;
}
if (userWorkspaceContext.hasReadOnlyAccess()) {
eventBus.fireEvent(new NotificationEvent(Severity.Warning,
messages.cannotUndoInReadOnlyMode()));
return;
}
callback.preUndo();
disableLink();
dispatcher.execute(revertAction,
new AsyncCallback<UpdateTransUnitResult>() {
@Override
public void onFailure(Throwable caught) {
eventBus.fireEvent(new NotificationEvent(
Severity.Error, messages.undoFailure()));
if (!Strings.isNullOrEmpty(getText())) {
setText(messages.undo());
}
enableLink();
}
@Override
public void onSuccess(UpdateTransUnitResult result) {
if (result.isAllSuccess()) {
eventBus.fireEvent(new NotificationEvent(
Severity.Info, messages.undoSuccess()));
callback.postUndoSuccess();
} else {
// most likely the undo link became stale i.e.
// entity state has
// changed on the server
Collection<TransUnitUpdateInfo> unsuccessful =
Collections2.filter(
result.getUpdateInfoList(),
UnsuccessfulUpdatePredicate.INSTANCE);
int unsuccessfulCount = unsuccessful.size();
int successfulCount =
result.getUpdateInfoList().size()
- unsuccessfulCount;
Log.info("undo not all successful. #"
+ unsuccessfulCount
+ " unsuccess and #" + successfulCount
+ " success");
eventBus.fireEvent(new NotificationEvent(
Severity.Info, messages
.undoUnsuccessful(
unsuccessfulCount,
successfulCount)));
setText("");