use of com.intellij.vcs.AnnotationProviderEx in project intellij-community by JetBrains.
the class AnnotateVcsVirtualFileAction method doAnnotate.
private static void doAnnotate(@NotNull final Project project, @NotNull final Editor editor, @NotNull final VirtualFile file) {
final AnnotationData data = extractData(project, file);
assert data != null;
final AnnotationProviderEx provider = (AnnotationProviderEx) data.vcs.getAnnotationProvider();
assert provider != null;
final Ref<FileAnnotation> fileAnnotationRef = new Ref<>();
final Ref<VcsException> exceptionRef = new Ref<>();
VcsAnnotateUtil.getBackgroundableLock(project, file).lock();
final Task.Backgroundable annotateTask = new Task.Backgroundable(project, VcsBundle.message("retrieving.annotations"), true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
try {
fileAnnotationRef.set(provider.annotate(data.filePath, data.revisionNumber));
} catch (VcsException e) {
exceptionRef.set(e);
} catch (ProcessCanceledException pce) {
throw pce;
} catch (Throwable t) {
exceptionRef.set(new VcsException(t));
}
}
@Override
public void onCancel() {
onSuccess();
}
@Override
public void onSuccess() {
VcsAnnotateUtil.getBackgroundableLock(project, file).unlock();
if (!exceptionRef.isNull()) {
LOG.warn(exceptionRef.get());
AbstractVcsHelper.getInstance(project).showErrors(Collections.singletonList(exceptionRef.get()), VcsBundle.message("message.title.annotate"));
}
if (!fileAnnotationRef.isNull()) {
AnnotateToggleAction.doAnnotate(editor, project, null, fileAnnotationRef.get(), data.vcs);
}
}
};
ProgressManager.getInstance().run(annotateTask);
}
use of com.intellij.vcs.AnnotationProviderEx in project intellij-community by JetBrains.
the class AnnotateVcsVirtualFileAction method isEnabled.
private static boolean isEnabled(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null || project.isDisposed())
return false;
VirtualFile[] selectedFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (selectedFiles == null || selectedFiles.length != 1)
return false;
VirtualFile file = selectedFiles[0];
if (file.isDirectory() || file.getFileType().isBinary())
return false;
if (VcsAnnotateUtil.getEditors(project, file).isEmpty())
return false;
AnnotationData data = extractData(project, file);
if (data == null)
return false;
AnnotationProvider provider = data.vcs.getAnnotationProvider();
return provider instanceof AnnotationProviderEx;
}
Aggregations