com.intellij.openapi.actionSystem.impl.ActionManagerImpl Java Examples

The following examples show how to use com.intellij.openapi.actionSystem.impl.ActionManagerImpl. 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: UnifiedToolWindowContentUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void showContextMenu(Component comp, int x, int y, ActionGroup toolWindowGroup, @Nullable Content selectedContent) {
  if (selectedContent == null && toolWindowGroup == null) {
    return;
  }
  DefaultActionGroup group = new DefaultActionGroup();
  if (selectedContent != null) {
    initActionGroup(group, selectedContent);
  }

  if (toolWindowGroup != null) {
    group.addAll(toolWindowGroup);
  }

  final ActionPopupMenu popupMenu = ((ActionManagerImpl)ActionManager.getInstance()).createActionPopupMenu(POPUP_PLACE, group, new MenuItemPresentationFactory(true));
  popupMenu.getComponent().show(comp, x, y);
}
 
Example #2
Source File: GotoActionItemProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
private boolean processActions(String pattern, Processor<? super MatchedValue> consumer, DataContext dataContext) {
  Set<String> ids = ((ActionManagerImpl)myActionManager).getActionIds();
  JBIterable<AnAction> actions = JBIterable.from(ids).filterMap(myActionManager::getAction);
  Matcher matcher = buildMatcher(pattern);

  QuickActionProvider provider = dataContext.getData(QuickActionProvider.KEY);
  if (provider != null) {
    actions = actions.append(provider.getActions(true));
  }

  JBIterable<ActionWrapper> actionWrappers = actions.unique().filterMap(action -> {
    MatchMode mode = myModel.actionMatches(pattern, matcher, action);
    if (mode == MatchMode.NONE) return null;
    return new ActionWrapper(action, myModel.getGroupMapping(action), mode, dataContext, myModel);
  });
  return processItems(pattern, actionWrappers, consumer);
}
 
Example #3
Source File: DesktopToolWindowContentUi.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void showContextMenu(Component comp, int x, int y, ActionGroup toolWindowGroup, @Nullable Content selectedContent) {
  if (selectedContent == null && toolWindowGroup == null) {
    return;
  }
  DefaultActionGroup group = new DefaultActionGroup();
  if (selectedContent != null) {
    initActionGroup(group, selectedContent);
  }

  if (toolWindowGroup != null) {
    group.addAll(toolWindowGroup);
  }

  final ActionPopupMenu popupMenu = ((ActionManagerImpl)ActionManager.getInstance()).createActionPopupMenu(POPUP_PLACE, group, new MenuItemPresentationFactory(true));
  popupMenu.getComponent().show(comp, x, y);
}
 
Example #4
Source File: DesktopToolWindowHeader.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  final InputEvent inputEvent = e.getInputEvent();
  final ActionPopupMenu popupMenu =
          ((ActionManagerImpl)ActionManager.getInstance()).createActionPopupMenu(DesktopToolWindowContentUi.POPUP_PLACE, myGearProducer.produce(), new MenuItemPresentationFactory(true));

  int x = 0;
  int y = 0;
  if (inputEvent instanceof MouseEvent) {
    x = ((MouseEvent)inputEvent).getX();
    y = ((MouseEvent)inputEvent).getY();
  }

  popupMenu.getComponent().show(inputEvent.getComponent(), x, y);
}
 
Example #5
Source File: RunAndroidDevicesAction.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void showDevicesPopup(Component component, int x, int y, DefaultActionGroup defaultActionGroup) {
    ActionPopupMenu popupMenu =
            ((ActionManagerImpl) ActionManager.getInstance())
                    .createActionPopupMenu(ToolWindowContentUi.POPUP_PLACE, defaultActionGroup,
                            new MenuItemPresentationFactory(false));// don't set forceHide to true, otherwise icons will be hidden in menu item
    popupMenu.getComponent().show(component, x, y);
}
 
Example #6
Source File: RunIOSDevicesAction.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void showDevicesPopup(Component component, int x, int y, DefaultActionGroup defaultActionGroup) {
    ActionPopupMenu popupMenu =
            ((ActionManagerImpl) ActionManager.getInstance())
                    .createActionPopupMenu(ToolWindowContentUi.POPUP_PLACE, defaultActionGroup,
                            new MenuItemPresentationFactory(false));// don't set forceHide to true, otherwise icons will be hidden in menu item
    popupMenu.getComponent().show(component, x, y);
}
 
Example #7
Source File: AbstractRichStringBasedPostfixTemplate.java    From HakunaMatataIntelliJPlugin with Apache License 2.0 5 votes vote down vote up
protected void onTemplateFinished(TemplateManager manager, Editor editor, Template template) {
    // format and add ;
    final ActionManager actionManager = ActionManagerImpl.getInstance();
    final String editorCompleteStatementText = "EditorCompleteStatement";
    final AnAction action = actionManager.getAction(editorCompleteStatementText);
    actionManager.tryToExecute(action, ActionCommand.getInputEvent(editorCompleteStatementText), null, ActionPlaces.UNKNOWN, true);
}
 
Example #8
Source File: FindViewByIdFieldTemplate.java    From android-postfix-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTemplateFinished(final TemplateManager manager, final Editor editor, Template template) {
    final ActionManager actionManager = ActionManagerImpl.getInstance();
    final String editorCompleteStatementText = "IntroduceField";
    final AnAction action = actionManager.getAction(editorCompleteStatementText);
    actionManager.tryToExecute(action, ActionCommand.getInputEvent(editorCompleteStatementText), null, ActionPlaces.UNKNOWN, true);
}
 
Example #9
Source File: FindViewByIdVariableTemplate.java    From android-postfix-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTemplateFinished(final TemplateManager manager, final Editor editor, Template template) {
    final ActionManager actionManager = ActionManagerImpl.getInstance();
    final String editorCompleteStatementText = "IntroduceVariable";
    final AnAction action = actionManager.getAction(editorCompleteStatementText);
    actionManager.tryToExecute(action, ActionCommand.getInputEvent(editorCompleteStatementText), null, ActionPlaces.UNKNOWN, true);
}
 
Example #10
Source File: AbstractRichStringBasedPostfixTemplate.java    From android-postfix-plugin with Apache License 2.0 5 votes vote down vote up
protected void onTemplateFinished(TemplateManager manager, Editor editor, Template template) {
    // format and add ;
    final ActionManager actionManager = ActionManagerImpl.getInstance();
    final String editorCompleteStatementText = "EditorCompleteStatement";
    final AnAction action = actionManager.getAction(editorCompleteStatementText);
    actionManager.tryToExecute(action, ActionCommand.getInputEvent(editorCompleteStatementText), null, ActionPlaces.UNKNOWN, true);
}
 
Example #11
Source File: ShowRNConsoleAction.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void showGearPopup(Component component, int x, int y) {
    ActionPopupMenu popupMenu =
            ((ActionManagerImpl) ActionManager.getInstance())
                    .createActionPopupMenu(ToolWindowContentUi.POPUP_PLACE, createGearPopupGroup(), new MenuItemPresentationFactory(true));
    popupMenu.getComponent().show(component, x, y);
}
 
Example #12
Source File: LightToolWindow.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void showGearPopup(Component component, int x, int y) {
  ActionPopupMenu popupMenu = ((ActionManagerImpl)ActionManager.getInstance()).createActionPopupMenu(ToolWindowContentUI.POPUP_PLACE, createGearPopupGroup(), new MenuItemPresentationFactory(true));
  popupMenu.getComponent().show(component, x, y);
}