List of usage examples for com.intellij.openapi.actionSystem DefaultActionGroup getChildActionsOrStubs
public final AnAction @NotNull [] getChildActionsOrStubs()
From source file:com.android.tools.adtui.workbench.AttachedToolWindowTest.java
License:Apache License
@Nullable private static AnAction findActionWithName(@NotNull DefaultActionGroup group, @NotNull String name) { for (AnAction action : group.getChildActionsOrStubs()) { if (name.equals(action.getTemplatePresentation().getText())) { return action; }/*from w w w .java 2 s .co m*/ if (action instanceof DefaultActionGroup) { AnAction childAction = findActionWithName((DefaultActionGroup) action, name); if (childAction != null) { return childAction; } } } return null; }
From source file:com.android.tools.idea.configurations.DeviceMenuActionTest.java
License:Apache License
private static void prettyPrintActions(AnAction action, StringBuilder sb, int depth) { String text;//from ww w. j av a 2 s . c o m if (action instanceof Separator) { text = "------------------------------------------------------"; } else { text = action.getTemplatePresentation().getText(); if (text != null && text.startsWith("AVD:")) { // Skip AVD items in tests - these tend to vary from build environment to // build environment return; } } if (text != null) { for (int i = 0; i < depth; i++) { sb.append(" "); } sb.append(text).append("\n"); } DefaultActionGroup group = action instanceof DefaultActionGroup ? (DefaultActionGroup) action : null; if (group != null) { for (AnAction child : group.getChildActionsOrStubs()) { prettyPrintActions(child, sb, depth + 1); } } }
From source file:com.android.tools.idea.startup.GradleSpecificInitializer.java
License:Apache License
private static void replaceProjectPopupActions() { Deque<Pair<DefaultActionGroup, AnAction>> stack = new ArrayDeque<>(); stack.add(Pair.of(null, ActionManager.getInstance().getAction("ProjectViewPopupMenu"))); while (!stack.isEmpty()) { Pair<DefaultActionGroup, AnAction> entry = stack.pop(); DefaultActionGroup parent = entry.getFirst(); AnAction action = entry.getSecond(); if (action instanceof DefaultActionGroup) { DefaultActionGroup actionGroup = (DefaultActionGroup) action; for (AnAction child : actionGroup.getChildActionsOrStubs()) { stack.push(Pair.of(actionGroup, child)); }/* w w w . j a v a 2 s.c o m*/ } if (action instanceof MoveModuleToGroupTopLevel) { parent.remove(action); parent.add(new AndroidActionGroupRemover((ActionGroup) action, "Move Module to Group"), new Constraints(AFTER, "OpenModuleSettings")); } else if (action instanceof MarkRootGroup) { parent.remove(action); parent.add(new AndroidActionGroupRemover((ActionGroup) action, "Mark Directory As"), new Constraints(AFTER, "OpenModuleSettings")); } } }
From source file:com.google.cloud.tools.intellij.debugger.CloudDebugProcess.java
License:Apache License
@Override public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) { ActionManager manager = ActionManager.getInstance(); leftToolbar.add(new SaveAndExitAction(), new Constraints(Anchor.AFTER, IdeActions.ACTION_STOP_PROGRAM)); leftToolbar.remove(manager.getAction(IdeActions.ACTION_RERUN)); leftToolbar.remove(manager.getAction(IdeActions.ACTION_STOP_PROGRAM)); // XDebugSessionTab puts this action second from end. AnAction[] actions = leftToolbar.getChildActionsOrStubs(); for (AnAction action : actions) { String text = action.getTemplatePresentation().getText(); if (ExecutionBundle.message("close.tab.action.name").equals(text)) { leftToolbar.remove(action);/* w w w .j a va2 s . com*/ break; } } // remove help button since it points to the IntelliJ help by default and we don't have // a help page yet. // for some reason, the help button's key in leftToolbar is null, so we need to remove it // by class name. // https://github.com/GoogleCloudPlatform/gcloud-intellij/issues/149 for (AnAction child : leftToolbar.getChildActionsOrStubs()) { if (child.getClass().getCanonicalName() .equalsIgnoreCase("com.intellij.ide.actions.ContextHelpAction")) { // we never want to show IDEA's help. leftToolbar.remove(child); // show our help if we have it. String helpUrl = GctBundle.getString("clouddebug.helpurl"); if (!"".equals(helpUrl)) { leftToolbar.add(new CloudDebugHelpAction(helpUrl)); } break; } } leftToolbar.remove(manager.getAction(XDebuggerActions.RESUME)); leftToolbar.remove(manager.getAction(XDebuggerActions.PAUSE)); leftToolbar.remove(manager.getAction(XDebuggerActions.MUTE_BREAKPOINTS)); topToolbar.remove(manager.getAction(XDebuggerActions.STEP_OVER)); topToolbar.remove(manager.getAction(XDebuggerActions.STEP_INTO)); topToolbar.remove(manager.getAction(XDebuggerActions.FORCE_STEP_INTO)); topToolbar.remove(manager.getAction(XDebuggerActions.STEP_OUT)); topToolbar.remove(manager.getAction(XDebuggerActions.RUN_TO_CURSOR)); topToolbar.remove(manager.getAction(XDebuggerActions.EVALUATE_EXPRESSION)); topToolbar.remove(manager.getAction(DebuggerActions.POP_FRAME)); }
From source file:com.google.cloud.tools.intellij.debugger.CloudDebugProcessTest.java
License:Apache License
@Test public void testRegisterAdditionalActions_close() { ActionManager manager = ActionManager.getInstance(); AnAction action0 = manager.getAction(IdeActions.ACTION_PIN_ACTIVE_TAB); AnAction action1 = manager.getAction(IdeActions.ACTION_CLOSE); action1.getTemplatePresentation().setText("Close"); AnAction action2 = manager.getAction(IdeActions.ACTION_CONTEXT_HELP); AnAction action3 = manager.getAction(IdeActions.ACTION_CALL_HIERARCHY); List<AnAction> leftToolbarActions = Lists.newArrayList(); leftToolbarActions.add(action0);/*from w ww. ja va2 s . c om*/ leftToolbarActions.add(action1); leftToolbarActions.add(action2); leftToolbarActions.add(action3); DefaultActionGroup leftToolbar = new DefaultActionGroup(leftToolbarActions); List<AnAction> actions = Lists.newArrayList(); DefaultActionGroup topToolbar = new DefaultActionGroup(actions); DefaultActionGroup settings = new DefaultActionGroup(actions); process.registerAdditionalActions(leftToolbar, topToolbar, settings); assertEquals(4, leftToolbar.getChildrenCount()); assertEquals(action0, leftToolbar.getChildActionsOrStubs()[0]); assertEquals(action3, leftToolbar.getChildActionsOrStubs()[1]); }
From source file:com.google.cloud.tools.intellij.debugger.CloudDebugProcessTest.java
License:Apache License
private void assertRemoveFromLeftToolbar(String actionId) { ActionManager manager = ActionManager.getInstance(); AnAction action = manager.getAction(actionId); List<AnAction> leftToolbarActions = Lists.newArrayList(); leftToolbarActions.add(action);//from w w w. ja v a 2 s .c o m DefaultActionGroup leftToolbar = new DefaultActionGroup(leftToolbarActions); List<AnAction> actions = Lists.newArrayList(); DefaultActionGroup topToolbar = new DefaultActionGroup(actions); DefaultActionGroup settings = new DefaultActionGroup(actions); process.registerAdditionalActions(leftToolbar, topToolbar, settings); assertEquals(1, leftToolbar.getChildrenCount()); AnAction actual = leftToolbar.getChildActionsOrStubs()[0]; assertEquals("Stop IDE Debugging. (Exit debug mode and continue the debug session later.)", actual.toString()); }
From source file:com.google.cloud.tools.intellij.debugger.CloudDebugProcessTest.java
License:Apache License
private void assertRemoveFromTopToolbar(String actionId) { ActionManager manager = ActionManager.getInstance(); AnAction action = manager.getAction(actionId); List<AnAction> topToolbarActions = Lists.newArrayList(); topToolbarActions.add(action);// ww w . ja va 2 s . com DefaultActionGroup topToolbar = new DefaultActionGroup(topToolbarActions); List<AnAction> actions = Lists.newArrayList(); DefaultActionGroup leftToolbar = new DefaultActionGroup(actions); DefaultActionGroup settings = new DefaultActionGroup(actions); process.registerAdditionalActions(leftToolbar, topToolbar, settings); assertEmpty(topToolbar.getChildActionsOrStubs()); }
From source file:com.intellij.xdebugger.impl.actions.DebuggerKeymapExtension.java
License:Apache License
public KeymapGroup createGroup(final Condition<AnAction> filtered, final Project project) { ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup debuggerGroup = (DefaultActionGroup) actionManager .getActionOrStub(IdeActions.GROUP_DEBUGGER); AnAction[] debuggerActions = debuggerGroup.getChildActionsOrStubs(); ArrayList<String> ids = new ArrayList<String>(); for (AnAction debuggerAction : debuggerActions) { String actionId = debuggerAction instanceof ActionStub ? ((ActionStub) debuggerAction).getId() : actionManager.getId(debuggerAction); if (filtered == null || filtered.value(debuggerAction)) { ids.add(actionId);/*from ww w . j ava2 s . c o m*/ } } Collections.sort(ids); Group group = new Group(KeyMapBundle.message("debugger.actions.group.title"), IdeActions.GROUP_DEBUGGER, null); for (String id : ids) { group.addActionId(id); } return group; }
From source file:com.mediaworx.intellij.opencmsplugin.actions.menus.OpenCmsMainMenu.java
License:Open Source License
private void unregisterChildActions(DefaultActionGroup parentGroup) { AnAction[] allActions = parentGroup.getChildActionsOrStubs(); for (AnAction action : allActions) { String actionId = actionManager.getId(action); keymap.removeAllActionShortcuts(actionId); actionManager.unregisterAction(actionId); }//from w ww . j a v a 2 s . c o m parentGroup.removeAll(); }
From source file:com.microsoft.alm.plugin.idea.common.ui.common.tabs.TabFormImplTest.java
License:Open Source License
@Test public void createActionGroup() { DefaultActionGroup group = underTest.createActionsGroup(); assertEquals(2, group.getChildrenCount()); assertEquals(TfPluginBundle.message(TfPluginBundle.KEY_VCS_WIT_CREATE_WIT), group.getChildActionsOrStubs()[0].getTemplatePresentation().getText()); assertEquals(TfPluginBundle.message(TfPluginBundle.KEY_VCS_WIT_REFRESH_TOOLTIP), group.getChildActionsOrStubs()[1].getTemplatePresentation().getText()); }