diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchPopup.java b/platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchPopup.java index 19ad276fa0aa..4aa98ad8a400 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchPopup.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchPopup.java @@ -48,6 +48,7 @@ public abstract class DvcsBranchPopup { @NotNull protected final Repo myCurrentRepository; @NotNull protected final ListPopupImpl myPopup; + @NotNull protected final String myRepoTitleInfo; protected DvcsBranchPopup(@NotNull Repo currentRepository, @NotNull AbstractRepositoryManager repositoryManager, @@ -60,8 +61,10 @@ public abstract class DvcsBranchPopup { myVcs = currentRepository.getVcs(); myVcsSettings = vcsSettings; myMultiRootBranchConfig = multiRootBranchConfig; - String title = createPopupTitle(currentRepository); - myPopup = new BranchActionGroupPopup(title, myProject, preselectActionCondition, createActions()); + String title = myVcs.getDisplayName() + " Branches"; + myRepoTitleInfo = (myRepositoryManager.moreThanOneRoot() && myVcsSettings.getSyncSetting() == DvcsSyncSettings.Value.DONT_SYNC) + ? " in " + DvcsUtil.getShortRepositoryName(currentRepository) : ""; + myPopup = new BranchActionGroupPopup(title + myRepoTitleInfo, myProject, preselectActionCondition, createActions()); initBranchSyncPolicyIfNotInitialized(); setCurrentBranchInfo(); @@ -85,15 +88,6 @@ public abstract class DvcsBranchPopup { } } - @NotNull - private String createPopupTitle(@NotNull Repo currentRepository) { - String title = myVcs.getDisplayName() + " Branches"; - if (myRepositoryManager.moreThanOneRoot() && myVcsSettings.getSyncSetting() == DvcsSyncSettings.Value.DONT_SYNC) { - title += " in " + DvcsUtil.getShortRepositoryName(currentRepository); - } - return title; - } - protected void setCurrentBranchInfo() { String branchText = "Current branch : "; myPopup.setAdText(branchText + myCurrentRepository.getCurrentBranchName(), SwingConstants.CENTER); diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java index 114956d0d902..ef81babc5a51 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java @@ -126,7 +126,7 @@ class GitBranchPopup extends DvcsBranchPopup { popupGroup.addSeparator("Repositories"); for (GitRepository repository : DvcsUtil.sortRepositories(myRepositoryManager.getRepositories())) { popupGroup.add(new RootAction<>(repository, highlightCurrentRepo() ? myCurrentRepository : null, - new GitBranchPopupActions(repository.getProject(), repository).createActions(null), + new GitBranchPopupActions(repository.getProject(), repository).createActions(), GitBranchUtil.getDisplayableBranchText(repository))); } return popupGroup; @@ -134,6 +134,7 @@ class GitBranchPopup extends DvcsBranchPopup { @Override protected void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup, @Nullable DefaultActionGroup actions) { - popupGroup.addAll(new GitBranchPopupActions(myCurrentRepository.getProject(), myCurrentRepository).createActions(actions)); + popupGroup + .addAll(new GitBranchPopupActions(myCurrentRepository.getProject(), myCurrentRepository).createActions(actions, myRepoTitleInfo)); } } diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java index 5b5156f17ee7..661a0efdb7dd 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java @@ -51,7 +51,11 @@ class GitBranchPopupActions { myRepository = repository; } - ActionGroup createActions(@Nullable DefaultActionGroup toInsert) { + ActionGroup createActions() { + return createActions(null, ""); + } + + ActionGroup createActions(@Nullable DefaultActionGroup toInsert, @NotNull String repoInfo) { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); List repositoryList = Collections.singletonList(myRepository); @@ -61,8 +65,7 @@ class GitBranchPopupActions { if (toInsert != null) { popupGroup.addAll(toInsert); } - - popupGroup.addSeparator("Local Branches"); + popupGroup.addSeparator("Local Branches" + repoInfo); List localBranches = new ArrayList<>(myRepository.getBranches().getLocalBranches()); Collections.sort(localBranches); for (GitBranch localBranch : localBranches) { @@ -71,7 +74,7 @@ class GitBranchPopupActions { } } - popupGroup.addSeparator("Remote Branches"); + popupGroup.addSeparator("Remote Branches" + repoInfo); List remoteBranches = new ArrayList<>(myRepository.getBranches().getRemoteBranches()); Collections.sort(remoteBranches); for (GitBranch remoteBranch : remoteBranches) { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java b/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java index 9f055bf05bdd..27d1115c3f1a 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java @@ -108,14 +108,14 @@ public class HgBranchPopup extends DvcsBranchPopup { popupGroup.addSeparator("Repositories"); for (HgRepository repository : DvcsUtil.sortRepositories(myRepositoryManager.getRepositories())) { popupGroup.add(new RootAction<>(repository, highlightCurrentRepo() ? myCurrentRepository : null, - new HgBranchPopupActions(repository.getProject(), repository).createActions(null), + new HgBranchPopupActions(repository.getProject(), repository).createActions(), HgUtil.getDisplayableBranchOrBookmarkText(repository))); } return popupGroup; } protected void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup, @Nullable DefaultActionGroup actions) { - popupGroup.addAll(new HgBranchPopupActions(myProject, myCurrentRepository).createActions(actions)); + popupGroup.addAll(new HgBranchPopupActions(myProject, myCurrentRepository).createActions(actions, myRepoTitleInfo)); } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java b/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java index e34ef534d3ac..9288bd47b491 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java @@ -68,7 +68,11 @@ public class HgBranchPopupActions { myRepository = repository; } - ActionGroup createActions(@Nullable DefaultActionGroup toInsert) { + ActionGroup createActions() { + return createActions(null, ""); + } + + ActionGroup createActions(@Nullable DefaultActionGroup toInsert, @NotNull String repoInfo) { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); popupGroup.addAction(new HgNewBranchAction(myProject, Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgNewBookmarkAction(Collections.singletonList(myRepository), myRepository)); @@ -78,7 +82,7 @@ public class HgBranchPopupActions { popupGroup.addAll(toInsert); } - popupGroup.addSeparator("Bookmarks"); + popupGroup.addSeparator("Bookmarks" + repoInfo); List bookmarkNames = getSortedNamesWithoutHashes(myRepository.getBookmarks()); String currentBookmark = myRepository.getCurrentBookmark(); for (String bookmark : bookmarkNames) { @@ -89,7 +93,7 @@ public class HgBranchPopupActions { popupGroup.add(bookmarkAction); } - popupGroup.addSeparator("Branches"); + popupGroup.addSeparator("Branches" + repoInfo); List branchNamesList = new ArrayList<>(myRepository.getOpenedBranches());//only opened branches have to be shown Collections.sort(branchNamesList); for (String branch : branchNamesList) {