コード例 #1
0
    private void calcMaxIconSize(final ActionGroup actionGroup) {
      AnAction[] actions = actionGroup.getChildren(createActionEvent(actionGroup));
      for (AnAction action : actions) {
        if (action == null) continue;
        if (action instanceof ActionGroup) {
          final ActionGroup group = (ActionGroup) action;
          if (!group.isPopup()) {
            calcMaxIconSize(group);
            continue;
          }
        }

        Icon icon = action.getTemplatePresentation().getIcon();
        if (icon == null && action instanceof Toggleable) icon = PlatformIcons.CHECK_ICON;
        if (icon != null) {
          final int width = icon.getIconWidth();
          final int height = icon.getIconHeight();
          if (myMaxIconWidth < width) {
            myMaxIconWidth = width;
          }
          if (myMaxIconHeight < height) {
            myMaxIconHeight = height;
          }
        }
      }
    }
コード例 #2
0
ファイル: CardActionsPanel.java プロジェクト: ernestp/consulo
  private List<Button> buildButtons(ActionGroup group, String parentId) {
    AnAction[] actions = group.getChildren(null);

    List<Button> buttons = new ArrayList<Button>();

    for (AnAction action : actions) {
      Presentation presentation = action.getTemplatePresentation();
      if (!USE_ICONS) {
        presentation.setIcon(null);
      }
      if (action instanceof ActionGroup) {
        ActionGroup childGroup = (ActionGroup) action;
        if (childGroup.isPopup()) {
          final String id = String.valueOf(++nCards);
          createCardForGroup(childGroup, id, parentId);

          buttons.add(new Button(new ActivateCard(id), presentation));
        } else {
          buttons.addAll(buildButtons(childGroup, parentId));
        }
      } else {
        action.update(
            new AnActionEvent(
                null,
                DataManager.getInstance().getDataContext(this),
                ActionPlaces.WELCOME_SCREEN,
                presentation,
                ActionManager.getInstance(),
                0));
        if (presentation.isVisible()) {
          buttons.add(new Button(action, presentation));
        }
      }
    }
    return buttons;
  }
コード例 #3
0
 private void appendActionsFromGroup(@NotNull ActionGroup actionGroup) {
   AnAction[] actions = actionGroup.getChildren(createActionEvent(actionGroup));
   for (AnAction action : actions) {
     if (action == null) {
       LOG.error("null action in group " + actionGroup);
       continue;
     }
     if (action instanceof Separator) {
       myPrependWithSeparator = true;
       mySeparatorText = ((Separator) action).getText();
     } else {
       if (action instanceof ActionGroup) {
         ActionGroup group = (ActionGroup) action;
         if (group.isPopup()) {
           appendAction(group);
         } else {
           appendActionsFromGroup(group);
         }
       } else {
         appendAction(action);
       }
     }
   }
 }
コード例 #4
0
 @Override
 public boolean isPopup() {
   return myGroup.isPopup();
 }