make all "Group By" and "View Options" popups multi-choice
authorGregory.Shrago <gregory.shrago@jetbrains.com>
Sat, 28 May 2022 12:47:31 +0000 (15:47 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Sat, 28 May 2022 17:05:53 +0000 (17:05 +0000)
GitOrigin-RevId: 2edac4707d19425ddd21617d88a1e86c9fbea373

platform/platform-impl/src/com/intellij/ui/popup/ActionStepBuilder.java
platform/platform-impl/src/com/intellij/ui/popup/PopupFactoryImpl.java
platform/usageView-impl/src/com/intellij/usages/impl/UsageViewImpl.java

index 4c495a8bfebcd39d945c605287e00f3991b90898..1b4b5a76fd543e6f3ce0b8708490487e8ef7f635 100644 (file)
@@ -1,6 +1,7 @@
 // Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
 package com.intellij.ui.popup;
 
+import com.intellij.icons.AllIcons;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.actionSystem.impl.MenuItemPresentationFactory;
 import com.intellij.openapi.actionSystem.impl.PresentationFactory;
@@ -92,6 +93,9 @@ class ActionStepBuilder {
   }
 
   private void appendActionsFromGroup(@NotNull ActionGroup actionGroup) {
+    boolean multiChoicePopup = actionGroup.getTemplatePresentation().isMultipleChoice() ||
+                               actionGroup.getTemplatePresentation().getIcon() == AllIcons.Actions.GroupBy ||
+                               actionGroup.getTemplatePresentation().getIcon() == AllIcons.Actions.Show;
     List<AnAction> newVisibleActions = Utils.expandActionGroup(
       actionGroup, myPresentationFactory, myDataContext, myActionPlace);
     List<AnAction> filtered = myShowDisabled ? newVisibleActions : ContainerUtil.filter(
@@ -103,13 +107,16 @@ class ActionStepBuilder {
         mySeparatorText = ((Separator)action).getText();
       }
       else {
-        appendAction(action);
+        Presentation presentation = myPresentationFactory.getPresentation(action);
+        if (multiChoicePopup && action instanceof Toggleable) {
+          presentation.setMultipleChoice(true);
+        }
+        appendAction(action, presentation);
       }
     }
   }
 
-  private void appendAction(@NotNull AnAction action) {
-    Presentation presentation = myPresentationFactory.getPresentation(action);
+  private void appendAction(@NotNull AnAction action, @NotNull Presentation presentation) {
     Character mnemonic = null;
     if (myShowNumbers) {
       if (myCurrentNumber < 9) {
index 6267327e69a8d2ecedd191e3b77dc8c26e6c1287..9a377ce529451a94052d57d68273b65266986725 100644 (file)
@@ -696,7 +696,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
       myIsEnabled = presentation.isEnabled();
       myIsPerformGroup = myAction instanceof ActionGroup && presentation.isPerformGroup();
       myIsSubstepSuppressed = myAction instanceof ActionGroup && Utils.isSubmenuSuppressed(presentation);
-      myIsKeepPopupOpen = myAction instanceof KeepingPopupOpenAction || presentation.isMultipleChoice();
+      myIsKeepPopupOpen = myIsKeepPopupOpen || myAction instanceof KeepingPopupOpenAction || presentation.isMultipleChoice();
 
       Couple<Icon> icons = ActionStepBuilder.calcRawIcons(myAction, presentation);
       Icon icon = icons.first;
index d7c3a0d739b8827e94d60fca007dc84c14f697f6..985ccf5cf64a3314e480c407bd3507a3c89983e4 100644 (file)
@@ -980,11 +980,7 @@ public class UsageViewImpl implements UsageViewEx {
     group.getTemplatePresentation().setIcon(AllIcons.Actions.GroupBy);
     group.getTemplatePresentation().setText(UsageViewBundle.messagePointer("action.group.by.title"));
     group.getTemplatePresentation().setDescription(UsageViewBundle.messagePointer("action.group.by.title"));
-    group.getTemplatePresentation().setMultipleChoice(true);
     AnAction[] groupingActions = createGroupingActions();
-    for (AnAction a : groupingActions) {
-      a.getTemplatePresentation().setMultipleChoice(true);
-    }
     if (groupingActions.length > 0) {
       group.add(new Separator(UsageViewBundle.message("action.group.by.title")));
       group.addAll(groupingActions);