Search in sources :

Example 1 with VcsSelection

use of com.intellij.vcsUtil.VcsSelection in project intellij-community by JetBrains.

the class ShowSelectionHistoryAction method actionPerformed.

@Override
protected void actionPerformed(@NotNull Project p, @NotNull IdeaGateway gw, @NotNull VirtualFile f, @NotNull AnActionEvent e) {
    VcsSelection sel = notNull(getSelection(e));
    int from = sel.getSelectionStartLineNumber();
    int to = sel.getSelectionEndLineNumber();
    new SelectionHistoryDialog(p, gw, f, from, to).show();
}
Also used : VcsSelection(com.intellij.vcsUtil.VcsSelection) SelectionHistoryDialog(com.intellij.history.integration.ui.views.SelectionHistoryDialog)

Example 2 with VcsSelection

use of com.intellij.vcsUtil.VcsSelection in project intellij-community by JetBrains.

the class SelectedBlockHistoryAction method update.

protected void update(@NotNull VcsContext context, @NotNull Presentation presentation) {
    presentation.setEnabled(isEnabled(context));
    VcsSelection selection = VcsSelectionUtil.getSelection(context);
    if (selection != null) {
        presentation.setText(selection.getActionName());
    }
}
Also used : VcsSelection(com.intellij.vcsUtil.VcsSelection)

Example 3 with VcsSelection

use of com.intellij.vcsUtil.VcsSelection in project intellij-community by JetBrains.

the class SelectedBlockHistoryAction method isEnabled.

protected boolean isEnabled(VcsContext context) {
    Project project = context.getProject();
    if (project == null)
        return false;
    VcsSelection selection = VcsSelectionUtil.getSelection(context);
    if (selection == null)
        return false;
    VirtualFile file = FileDocumentManager.getInstance().getFile(selection.getDocument());
    if (file == null)
        return false;
    final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(project);
    final BackgroundableActionEnabledHandler handler = vcsManager.getBackgroundableActionHandler(VcsBackgroundableActions.HISTORY_FOR_SELECTION);
    if (handler.isInProgress(VcsBackgroundableActions.keyFrom(file)))
        return false;
    AbstractVcs activeVcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
    if (activeVcs == null)
        return false;
    VcsHistoryProvider provider = activeVcs.getVcsBlockHistoryProvider();
    if (provider == null)
        return false;
    if (!AbstractVcs.fileInVcsByFileStatus(project, VcsUtil.getFilePath(file)))
        return false;
    return true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) VcsSelection(com.intellij.vcsUtil.VcsSelection) BackgroundableActionEnabledHandler(com.intellij.openapi.vcs.impl.BackgroundableActionEnabledHandler) ProjectLevelVcsManagerImpl(com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl) VcsHistoryProvider(com.intellij.openapi.vcs.history.VcsHistoryProvider) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 4 with VcsSelection

use of com.intellij.vcsUtil.VcsSelection 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

VcsSelection (com.intellij.vcsUtil.VcsSelection)4 Project (com.intellij.openapi.project.Project)2 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)2 VcsHistoryProvider (com.intellij.openapi.vcs.history.VcsHistoryProvider)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 SelectionHistoryDialog (com.intellij.history.integration.ui.views.SelectionHistoryDialog)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 BackgroundableActionEnabledHandler (com.intellij.openapi.vcs.impl.BackgroundableActionEnabledHandler)1 ProjectLevelVcsManagerImpl (com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl)1