Java Code Examples for com.intellij.openapi.actionSystem.ActionGroup#getChildren()

The following examples show how to use com.intellij.openapi.actionSystem.ActionGroup#getChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectedTestRunLineMarkerContributorTest.java    From buck with Apache License 2.0 6 votes vote down vote up
private AnAction findActionAtCaretWithText(Predicate<String> textMatcher) {
  List<GutterMark> gutterMarks = myFixture.findGuttersAtCaret();
  for (GutterMark gutterMark : gutterMarks) {
    if (!(gutterMark instanceof GutterIconRenderer)) {
      continue;
    }
    GutterIconRenderer renderer = (GutterIconRenderer) gutterMark;
    ActionGroup group = renderer.getPopupMenuActions();
    for (AnAction action : group.getChildren(new TestActionEvent())) {
      TestActionEvent actionEvent = new TestActionEvent();
      action.update(actionEvent);
      String actualText = actionEvent.getPresentation().getText();
      if (actualText == null) {
        actualText = action.getTemplatePresentation().getText();
        if (actualText == null) {
          continue;
        }
      }
      if (textMatcher.test(actualText)) {
        return action;
      }
    }
  }
  return null;
}
 
Example 2
Source File: SmartPopupActionGroup.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static int getChildrenCountRecursive(ActionGroup group) {
  AnAction[] children;
  if (group instanceof DefaultActionGroup) {
    children = ((DefaultActionGroup) group).getChildActionsOrStubs();
  }
  else {
    children = group.getChildren(null);
  }
  int count = 0;
  for (AnAction child : children) {
    if (child instanceof ActionGroup) {
      count += getChildrenCountRecursive((ActionGroup) child);
    }
    else {
      count++;
    }
  }
  return count;
}
 
Example 3
Source File: ActionPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ActionPanel(JBTabsImpl tabs, TabInfo tabInfo, Pass<MouseEvent> pass) {
  myTabs = tabs;
  ActionGroup group = tabInfo.getTabLabelActions() != null ? tabInfo.getTabLabelActions() : new DefaultActionGroup();
  AnAction[] children = group.getChildren(null);

  final NonOpaquePanel wrapper = new NonOpaquePanel(new BorderLayout());
  wrapper.add(Box.createHorizontalStrut(2), BorderLayout.WEST);
  NonOpaquePanel inner = new NonOpaquePanel();
  inner.setLayout(new BoxLayout(inner, BoxLayout.X_AXIS));
  wrapper.add(inner, BorderLayout.CENTER);
  for (AnAction each : children) {
    ActionButton eachButton = new ActionButton(myTabs, tabInfo, each, tabInfo.getTabActionPlace(), pass, tabs.getTabActionsMouseDeadzone()) {
      @Override
      protected void repaintComponent(final Component c) {
        TabLabel tabLabel = (TabLabel) SwingUtilities.getAncestorOfClass(TabLabel.class, c);
        if (tabLabel != null) {
          Point point = SwingUtilities.convertPoint(c, new Point(0, 0), tabLabel);
          Dimension d = c.getSize();
          tabLabel.repaint(point.x, point.y, d.width, d.height);
        } else {
          super.repaintComponent(c);
        }
      }
    };

    myButtons.add(eachButton);
    InplaceButton component = eachButton.getComponent();
    inner.add(component);
  }

  add(wrapper);
}
 
Example 4
Source File: FlatWelcomeScreen.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void collectAllActions(List<AnAction> group, ActionGroup actionGroup) {
  for (AnAction action : actionGroup.getChildren(null)) {
    if (action instanceof ActionGroup && !((ActionGroup)action).isPopup()) {
      collectAllActions(group, (ActionGroup)action);
    }
    else {
      group.add(action);
    }
  }
}
 
Example 5
Source File: RunnerLayoutUiImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public AnAction[] getLayoutActionsList() {
  final ActionGroup group = (ActionGroup)getLayoutActions();
  return group.getChildren(null);
}
 
Example 6
Source File: RunnerLayoutUiImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public AnAction[] getSettingsActionsList() {
  final ActionGroup group = (ActionGroup)getSettingsActions();
  return group.getChildren(null);
}