Search in sources :

Example 6 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class VcsLogSingleCommitAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
    if (project == null || log == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    List<CommitId> commits = log.getSelectedCommits();
    if (commits.isEmpty()) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    CommitId commit = ContainerUtil.getFirstItem(commits);
    assert commit != null;
    Repo repository = getRepositoryForRoot(project, commit.getRoot());
    if (repository == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    e.getPresentation().setVisible(isVisible(project, repository, commit.getHash()));
    e.getPresentation().setEnabled(commits.size() == 1 && isEnabled(repository, commit.getHash()));
}
Also used : Project(com.intellij.openapi.project.Project) CommitId(com.intellij.vcs.log.CommitId) VcsLog(com.intellij.vcs.log.VcsLog)

Example 7 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class GoToHashOrRefAction method update.

@Override
public void update(AnActionEvent e) {
    VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
    VcsLogUi logUi = e.getData(VcsLogDataKeys.VCS_LOG_UI);
    e.getPresentation().setEnabledAndVisible(e.getProject() != null && log != null && logUi != null && logUi instanceof AbstractVcsLogUi);
}
Also used : VcsLog(com.intellij.vcs.log.VcsLog) AbstractVcsLogUi(com.intellij.vcs.log.ui.AbstractVcsLogUi) AbstractVcsLogUi(com.intellij.vcs.log.ui.AbstractVcsLogUi) VcsLogUi(com.intellij.vcs.log.VcsLogUi)

Example 8 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class HgQGotoFromLogAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
    log.requestSelectedDetails(new Consumer<List<VcsFullCommitDetails>>() {

        @Override
        public void consume(List<VcsFullCommitDetails> selectedDetails) {
            VcsFullCommitDetails fullCommitDetails = ContainerUtil.getFirstItem(selectedDetails);
            assert fullCommitDetails != null;
            final HgRepository repository = getRepositoryForRoot(project, fullCommitDetails.getRoot());
            assert repository != null;
            actionPerformed(repository, fullCommitDetails);
        }
    }, null);
}
Also used : Project(com.intellij.openapi.project.Project) VcsLog(com.intellij.vcs.log.VcsLog) List(java.util.List) HgRepository(org.zmlx.hg4idea.repo.HgRepository) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails)

Example 9 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class GithubOpenInBrowserAction method getDataFromLog.

@Nullable
private static CommitData getDataFromLog(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
    if (project == null || log == null)
        return null;
    List<CommitId> selectedCommits = log.getSelectedCommits();
    if (selectedCommits.size() != 1)
        return null;
    CommitId commit = ContainerUtil.getFirstItem(selectedCommits);
    if (commit == null)
        return null;
    GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(commit.getRoot());
    if (repository == null || !GithubUtil.isRepositoryOnGitHub(repository))
        return null;
    return new CommitData(project, repository, commit.getHash().asString());
}
Also used : Project(com.intellij.openapi.project.Project) GitRepository(git4idea.repo.GitRepository) CommitId(com.intellij.vcs.log.CommitId) VcsLog(com.intellij.vcs.log.VcsLog) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

VcsLog (com.intellij.vcs.log.VcsLog)9 Project (com.intellij.openapi.project.Project)8 CommitId (com.intellij.vcs.log.CommitId)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 VcsLogUi (com.intellij.vcs.log.VcsLogUi)2 AbstractVcsLogUi (com.intellij.vcs.log.ui.AbstractVcsLogUi)2 List (java.util.List)2 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)1 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 Content (com.intellij.ui.content.Content)1 ContentManager (com.intellij.ui.content.ContentManager)1 VcsFullCommitDetails (com.intellij.vcs.log.VcsFullCommitDetails)1 VcsGoToRefComparator (com.intellij.vcs.log.impl.VcsGoToRefComparator)1 VcsProjectLog (com.intellij.vcs.log.impl.VcsProjectLog)1 VcsLogUiImpl (com.intellij.vcs.log.ui.VcsLogUiImpl)1 GitRepository (git4idea.repo.GitRepository)1 Nullable (org.jetbrains.annotations.Nullable)1 HgRepository (org.zmlx.hg4idea.repo.HgRepository)1