public MyActionGroupWrapper(final ActionGroup actionGroup) {
   super(
       actionGroup.getTemplatePresentation().getText(),
       actionGroup.getTemplatePresentation().getDescription(),
       actionGroup.getTemplatePresentation().getIcon());
   myActionGroup = actionGroup;
   registerCustomShortcutSet(actionGroup.getShortcutSet(), myTree);
 }
 public IconsFreeActionGroup(ActionGroup group) {
   super(
       group.getTemplatePresentation().getText(),
       group.getTemplatePresentation().getDescription(),
       null);
   myGroup = group;
 }
 public boolean isGroupContainsInPath(ActionGroup group) {
   for (String s : myGroupPath) {
     if (s.equals(group.getTemplatePresentation().getText())) {
       return true;
     }
   }
   return false;
 }
 private void collectActions(
     String id,
     Map<AnAction, String> result,
     ActionGroup group,
     final String containingGroupName) {
   final AnAction[] actions = group.getChildren(null);
   for (AnAction action : actions) {
     if (action != null) {
       if (action instanceof ActionGroup) {
         final ActionGroup actionGroup = (ActionGroup) action;
         final String groupName = actionGroup.getTemplatePresentation().getText();
         collectActions(
             id, result, actionGroup, groupName != null ? groupName : containingGroupName);
       } else if (getActionId(action) == id) {
         final String groupName = group.getTemplatePresentation().getText();
         result.put(
             action,
             groupName != null && groupName.length() > 0 ? groupName : containingGroupName);
       }
     }
   }
 }
 public Object[] getElementsByName(
     final String id, final boolean checkBoxState, final String pattern) {
   final HashMap<AnAction, String> map = new HashMap<AnAction, String>();
   final ActionGroup mainMenu =
       (ActionGroup) myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU);
   collectActions(id, map, mainMenu, mainMenu.getTemplatePresentation().getText());
   if (checkBoxState) {
     final Set<String> ids = ((ActionManagerImpl) myActionManager).getActionIds();
     for (AnAction action : map.keySet()) { // do not add already included actions
       ids.remove(getActionId(action));
     }
     if (ids.contains(id)) {
       final AnAction anAction = myActionManager.getAction(id);
       if (!(anAction instanceof ActionGroup)) {
         map.put(anAction, null);
       }
     }
   }
   return map.entrySet().toArray(new Map.Entry[map.size()]);
 }
 public void actionPerformed(AnActionEvent e) {
   final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
   final ListPopupStep step =
       popupFactory.createActionsStep(
           myActionGroup,
           e.getDataContext(),
           false,
           false,
           myActionGroup.getTemplatePresentation().getText(),
           myTree,
           true,
           myPreselection != null ? myPreselection.getDefaultIndex() : 0,
           true);
   final ListPopup listPopup = popupFactory.createListPopup(step);
   listPopup.setHandleAutoSelectionBeforeShow(true);
   if (e instanceof AnActionButton.AnActionEventWrapper) {
     ((AnActionButton.AnActionEventWrapper) e).showPopup(listPopup);
   } else {
     listPopup.showUnderneathOf(myNorthPanel);
   }
 }
 private static void addSorted(DefaultActionGroup main, ActionGroup group) {
   final AnAction[] children = group.getChildren(null);
   boolean hadSecondary = false;
   for (AnAction action : children) {
     if (group.isPrimary(action)) {
       main.add(action);
     } else {
       hadSecondary = true;
     }
   }
   if (hadSecondary) {
     main.addSeparator();
     for (AnAction action : children) {
       if (!group.isPrimary(action)) {
         main.addAction(action).setAsSecondary(true);
       }
     }
   }
   String separatorText = group.getTemplatePresentation().getText();
   if (children.length > 0 && !StringUtil.isEmpty(separatorText)) {
     main.addAction(new Separator(separatorText), Constraints.FIRST);
   }
 }