Search in sources :

Example 1 with FAVORITE_BRANCH_COMPARATOR

use of com.intellij.dvcs.ui.BranchActionUtil.FAVORITE_BRANCH_COMPARATOR in project intellij-community by JetBrains.

the class GitBranchPopupActions method createActions.

ActionGroup createActions(@Nullable DefaultActionGroup toInsert, @NotNull String repoInfo, boolean firstLevelGroup) {
    DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
    List<GitRepository> repositoryList = Collections.singletonList(myRepository);
    popupGroup.addAction(new GitNewBranchAction(myProject, repositoryList));
    popupGroup.addAction(new CheckoutRevisionActions(myProject, repositoryList));
    if (toInsert != null) {
        popupGroup.addAll(toInsert);
    }
    popupGroup.addSeparator("Local Branches" + repoInfo);
    List<BranchActionGroup> localBranchActions = myRepository.getBranches().getLocalBranches().stream().sorted().filter(branch -> !branch.equals(myRepository.getCurrentBranch())).map(branch -> new LocalBranchActions(myProject, repositoryList, branch.getName(), myRepository)).collect(toList());
    // if there are only a few local favorites -> show all;  for remotes it's better to show only favorites; 
    wrapWithMoreActionIfNeeded(myProject, popupGroup, ContainerUtil.sorted(localBranchActions, FAVORITE_BRANCH_COMPARATOR), getNumOfTopShownBranches(localBranchActions), firstLevelGroup ? GitBranchPopup.SHOW_ALL_LOCALS_KEY : null, firstLevelGroup);
    popupGroup.addSeparator("Remote Branches" + repoInfo);
    List<BranchActionGroup> remoteBranchActions = myRepository.getBranches().getRemoteBranches().stream().sorted().map(remoteBranch -> new RemoteBranchActions(myProject, repositoryList, remoteBranch.getName(), myRepository)).collect(toList());
    wrapWithMoreActionIfNeeded(myProject, popupGroup, ContainerUtil.sorted(remoteBranchActions, FAVORITE_BRANCH_COMPARATOR), getNumOfTopShownBranches(remoteBranchActions), firstLevelGroup ? GitBranchPopup.SHOW_ALL_REMOTES_KEY : null);
    return popupGroup;
}
Also used : BranchActionGroupPopup.wrapWithMoreActionIfNeeded(com.intellij.dvcs.ui.BranchActionGroupPopup.wrapWithMoreActionIfNeeded) ContainerUtil(com.intellij.util.containers.ContainerUtil) GitBranchUtil(git4idea.branch.GitBranchUtil) GitNewBranchOptions(git4idea.branch.GitNewBranchOptions) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) GitStatisticsCollectorKt.reportUsage(git4idea.GitStatisticsCollectorKt.reportUsage) GitRepository(git4idea.repo.GitRepository) BranchActionGroup(com.intellij.dvcs.ui.BranchActionGroup) HEAD(git4idea.GitUtil.HEAD) PopupElementWithAdditionalInfo(com.intellij.dvcs.ui.PopupElementWithAdditionalInfo) GitBrancher(git4idea.branch.GitBrancher) AnAction(com.intellij.openapi.actionSystem.AnAction) BranchActionUtil.getNumOfTopShownBranches(com.intellij.dvcs.ui.BranchActionUtil.getNumOfTopShownBranches) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) GitNewBranchNameValidator(git4idea.validators.GitNewBranchNameValidator) LOCAL(git4idea.branch.GitBranchType.LOCAL) Nullable(org.jetbrains.annotations.Nullable) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ServiceManager(com.intellij.openapi.components.ServiceManager) NewBranchAction(com.intellij.dvcs.ui.NewBranchAction) StreamEx(one.util.streamex.StreamEx) REMOTE(git4idea.branch.GitBranchType.REMOTE) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) NotNull(org.jetbrains.annotations.NotNull) FAVORITE_BRANCH_COMPARATOR(com.intellij.dvcs.ui.BranchActionUtil.FAVORITE_BRANCH_COMPARATOR) Collections(java.util.Collections) GitRepository(git4idea.repo.GitRepository) BranchActionGroup(com.intellij.dvcs.ui.BranchActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Aggregations

BranchActionGroup (com.intellij.dvcs.ui.BranchActionGroup)1 BranchActionGroupPopup.wrapWithMoreActionIfNeeded (com.intellij.dvcs.ui.BranchActionGroupPopup.wrapWithMoreActionIfNeeded)1 FAVORITE_BRANCH_COMPARATOR (com.intellij.dvcs.ui.BranchActionUtil.FAVORITE_BRANCH_COMPARATOR)1 BranchActionUtil.getNumOfTopShownBranches (com.intellij.dvcs.ui.BranchActionUtil.getNumOfTopShownBranches)1 NewBranchAction (com.intellij.dvcs.ui.NewBranchAction)1 PopupElementWithAdditionalInfo (com.intellij.dvcs.ui.PopupElementWithAdditionalInfo)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 ServiceManager (com.intellij.openapi.components.ServiceManager)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 Project (com.intellij.openapi.project.Project)1 Messages (com.intellij.openapi.ui.Messages)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 GitStatisticsCollectorKt.reportUsage (git4idea.GitStatisticsCollectorKt.reportUsage)1 HEAD (git4idea.GitUtil.HEAD)1 LOCAL (git4idea.branch.GitBranchType.LOCAL)1 REMOTE (git4idea.branch.GitBranchType.REMOTE)1 GitBranchUtil (git4idea.branch.GitBranchUtil)1