Search in sources :

Example 1 with VcsHistoryProviderBackgroundableProxy

use of com.intellij.openapi.vcs.history.VcsHistoryProviderBackgroundableProxy in project intellij-community by JetBrains.

the class SelectedBlockHistoryAction method actionPerformed.

public void actionPerformed(@NotNull final VcsContext context) {
    try {
        final Project project = context.getProject();
        assert project != null;
        final VcsSelection selection = VcsSelectionUtil.getSelection(context);
        assert selection != null;
        final VirtualFile file = FileDocumentManager.getInstance().getFile(selection.getDocument());
        assert file != null;
        final AbstractVcs activeVcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
        assert activeVcs != null;
        final VcsHistoryProvider provider = activeVcs.getVcsBlockHistoryProvider();
        assert provider != null;
        final int selectionStart = selection.getSelectionStartLineNumber();
        final int selectionEnd = selection.getSelectionEndLineNumber();
        new VcsHistoryProviderBackgroundableProxy(activeVcs, provider, activeVcs.getDiffProvider()).createSessionFor(activeVcs.getKeyInstanceMethod(), VcsUtil.getFilePath(file), new Consumer<VcsHistorySession>() {

            public void consume(VcsHistorySession session) {
                if (session == null)
                    return;
                final VcsSelectionHistoryDialog vcsHistoryDialog = new VcsSelectionHistoryDialog(project, file, selection.getDocument(), provider, session, activeVcs, Math.min(selectionStart, selectionEnd), Math.max(selectionStart, selectionEnd), selection.getDialogTitle());
                vcsHistoryDialog.show();
            }
        }, VcsBackgroundableActions.HISTORY_FOR_SELECTION, false, null);
    } catch (Exception exception) {
        reportError(exception);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) VcsSelection(com.intellij.vcsUtil.VcsSelection) VcsSelectionHistoryDialog(com.intellij.openapi.vcs.history.impl.VcsSelectionHistoryDialog) VcsHistorySession(com.intellij.openapi.vcs.history.VcsHistorySession) VcsHistoryProvider(com.intellij.openapi.vcs.history.VcsHistoryProvider) VcsHistoryProviderBackgroundableProxy(com.intellij.openapi.vcs.history.VcsHistoryProviderBackgroundableProxy) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Aggregations

Project (com.intellij.openapi.project.Project)1 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)1 VcsHistoryProvider (com.intellij.openapi.vcs.history.VcsHistoryProvider)1 VcsHistoryProviderBackgroundableProxy (com.intellij.openapi.vcs.history.VcsHistoryProviderBackgroundableProxy)1 VcsHistorySession (com.intellij.openapi.vcs.history.VcsHistorySession)1 VcsSelectionHistoryDialog (com.intellij.openapi.vcs.history.impl.VcsSelectionHistoryDialog)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 VcsSelection (com.intellij.vcsUtil.VcsSelection)1