diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java index d4193e697a48..839575e63556 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java @@ -388,18 +388,21 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup { @NotNull private final Project myProject; @Nullable private final String mySettingName; + private final boolean myDefaultExpandValue; private boolean myIsExpanded; @NotNull private final String myToCollapseText; @NotNull private final String myToExpandText; - public MoreAction(@NotNull Project project, int numberOfHiddenNodes, @Nullable String settingName) { + public MoreAction(@NotNull Project project, int numberOfHiddenNodes, @Nullable String settingName, boolean defaultExpandValue) { super(); myProject = project; mySettingName = settingName; + myDefaultExpandValue = defaultExpandValue; assert numberOfHiddenNodes > 0; myToExpandText = "Show " + numberOfHiddenNodes + " More..."; myToCollapseText = "Show Only Favorites"; - setExpanded(settingName != null && PropertiesComponent.getInstance(project).getBoolean(settingName, false)); + setExpanded( + settingName != null ? PropertiesComponent.getInstance(project).getBoolean(settingName, defaultExpandValue) : defaultExpandValue); } @Override @@ -430,7 +433,7 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup { public void saveState() { if (mySettingName != null) { - PropertiesComponent.getInstance(myProject).setValue(mySettingName, myIsExpanded); + PropertiesComponent.getInstance(myProject).setValue(mySettingName, myIsExpanded, myDefaultExpandValue); } } } @@ -456,8 +459,14 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup { public static void wrapWithMoreActionIfNeeded(@NotNull Project project, @NotNull DefaultActionGroup parentGroup, @NotNull List actionList, int maxIndex, @Nullable String settingName) { + wrapWithMoreActionIfNeeded(project, parentGroup, actionList, maxIndex, settingName, false); + } + + public static void wrapWithMoreActionIfNeeded(@NotNull Project project, + @NotNull DefaultActionGroup parentGroup, @NotNull List actionList, + int maxIndex, @Nullable String settingName, boolean defaultExpandValue) { if (actionList.size() > maxIndex) { - MoreAction moreAction = new MoreAction(project, actionList.size() - maxIndex, settingName); + MoreAction moreAction = new MoreAction(project, actionList.size() - maxIndex, settingName, defaultExpandValue); for (int i = 0; i < actionList.size(); i++) { parentGroup.add(i < maxIndex ? actionList.get(i) : new HideableActionGroup(actionList.get(i), moreAction)); } diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java index f45752e7c0e8..7db0a6cc5a76 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java @@ -124,7 +124,7 @@ class GitBranchPopup extends DvcsBranchPopup { myMultiRootBranchConfig.getLocalBranchNames().stream().map(l -> createLocalBranchActions(allRepositories, l)).filter(Objects::nonNull) .collect(toList()); wrapWithMoreActionIfNeeded(myProject, popupGroup, ContainerUtil.sorted(localBranchActions, FAVORITE_BRANCH_COMPARATOR), - getNumOfTopShownBranches(localBranchActions), SHOW_ALL_LOCALS_KEY); + getNumOfTopShownBranches(localBranchActions), SHOW_ALL_LOCALS_KEY, true); popupGroup.addSeparator("Common Remote Branches"); List remoteBranchActions = map(((GitMultiRootBranchConfig)myMultiRootBranchConfig).getRemoteBranches(), diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java index 51a320d277ae..bce8008ea8fe 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java @@ -78,7 +78,8 @@ class GitBranchPopupActions { .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); + getNumOfTopShownBranches(localBranchActions), firstLevelGroup ? GitBranchPopup.SHOW_ALL_LOCALS_KEY : null, + firstLevelGroup); popupGroup.addSeparator("Remote Branches" + repoInfo); List remoteBranchActions =