}
new Task.Backgroundable(project, "Loading content...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
LocalHistoryAction action = file != null ? startLocalHistoryAction(filePath, revision) : LocalHistoryAction.NULL;
final byte[] revisionContent;
try {
revisionContent = VcsHistoryUtil.loadRevisionContent(revision);
} catch (final IOException e) {
log.info(e);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override public void run() {
Messages.showMessageDialog("Cannot load revision: " + e.getLocalizedMessage(),
"Get Revision Content", Messages.getInformationIcon());
}
});
return;
} catch (final VcsException e) {
log.info(e);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override public void run() {
Messages.showMessageDialog("Cannot load revision: " + e.getLocalizedMessage(),
"Get Revision Content", Messages.getInformationIcon());
}
});
return;
} catch (ProcessCanceledException ex) {
return;
}
try {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
public void run() {
try {
write(project, filePath, revisionContent);
} catch (IOException e) {
Messages.showMessageDialog("Cannot save content: " + e.getLocalizedMessage(),
"Get Revision Content", Messages.getErrorIcon());
}
}
}, createGetActionTitle(filePath, revision), null);
}
});
}
});
if (file != null) {
VcsDirtyScopeManager.getInstance(project).fileDirty(file);
}
} finally {
action.finish();
}
}
}.queue();
}