final AnnotationProvider annotationProvider = vcs.getAnnotationProvider();
final Ref<FileAnnotation> fileAnnotationRef = new Ref<FileAnnotation>();
final Ref<VcsException> exceptionRef = new Ref<VcsException>();
final BackgroundableActionEnabledHandler handler =
((ProjectLevelVcsManagerImpl) plVcsManager).getBackgroundableActionHandler(
VcsBackgroundableActions.ANNOTATE);
handler.register(file.getPath());
ProgressManager.getInstance()
.run(new Task.Backgroundable(project, VcsBundle.message("retrieving.annotations"), true,
BackgroundFromStartOption.getInstance())
{
public void run(@NotNull ProgressIndicator indicator)
{
try
{
fileAnnotationRef.set(annotationProvider.annotate(file));
}
catch (VcsException e)
{
exceptionRef.set(e);
}
}
@Override
public void onCancel()
{
onSuccess();
}
@Override
public void onSuccess()
{
handler.completed(file.getPath());
if (!exceptionRef.isNull())
{
AbstractVcsHelper.getInstance(project)
.showErrors(Arrays.asList(exceptionRef.get()), VcsBundle.message("message.title.annotate"));