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); }
private static void processKeymap(final Element configurableElement){ final ActionManager actionManager = ActionManager.getInstance(); final String componentName = actionManager.getComponentName(); final SearchableOptionsRegistrar searchableOptionsRegistrar = SearchableOptionsRegistrar.getInstance(); final Set<String> ids = ((ActionManagerImpl)actionManager).getActionIds(); final TreeSet<OptionDescription> options = new TreeSet<OptionDescription>(); for (String id : ids) { final AnAction anAction = actionManager.getAction(id); final String text = anAction.getTemplatePresentation().getText(); if (text != null) { collectOptions(searchableOptionsRegistrar, options, text, componentName); } final String description = anAction.getTemplatePresentation().getDescription(); if (description != null) { collectOptions(searchableOptionsRegistrar, options, description, componentName); } } writeOptions(configurableElement, options); }
private boolean processActions(String pattern, boolean everywhere, Processor<MatchedValue> consumer, DataContext dataContext) { Set<AnAction> actions = new THashSet<AnAction>(ACTION_OBJECT_HASHING_STRATEGY); if (everywhere) { for (String id : ((ActionManagerImpl)myActionManager).getActionIds()) { ProgressManager.checkCanceled(); ContainerUtil.addIfNotNull(actions, myActionManager.getAction(id)); } } else { actions.addAll(myModel.myActionGroups.keySet()); } List<ActionWrapper> actionWrappers = ContainerUtil.newArrayList(); for (AnAction action : actions) { ProgressManager.checkCanceled(); MatchMode mode = myModel.actionMatches(pattern, action); if (mode != MatchMode.NONE) { actionWrappers.add(new ActionWrapper(action, myModel.myActionGroups.get(action), mode, dataContext)); } } return processItems(pattern, actionWrappers, consumer); }
@Override @NotNull public String[] getNames(boolean checkBoxState) { final ArrayList<String> result = new ArrayList<String>(); for (AnAction action : myActionsMap.keySet()) { result.add(getActionId(action)); } if (checkBoxState) { final Set<String> ids = ((ActionManagerImpl)myActionManager).getActionIds(); for (String id : ids) { result.add(id); } } result.add(SETTINGS_KEY); return ArrayUtil.toStringArray(result); }
private boolean processActions(String pattern, boolean everywhere, Processor<MatchedValue> consumer, DataContext dataContext) { List<AnAction> actions = ContainerUtil.newArrayList(); if (everywhere) { for (String id : ((ActionManagerImpl)myActionManager).getActionIds()) { ProgressManager.checkCanceled(); ContainerUtil.addIfNotNull(actions, myActionManager.getAction(id)); } } else { actions.addAll(myModel.myActionGroups.keySet()); } List<ActionWrapper> actionWrappers = ContainerUtil.newArrayList(); for (AnAction action : actions) { ProgressManager.checkCanceled(); MatchMode mode = myModel.actionMatches(pattern, action); if (mode != MatchMode.NONE) { actionWrappers.add(new ActionWrapper(action, myModel.myActionGroups.get(action), mode, dataContext)); } } return processItems(pattern, actionWrappers, consumer); }
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); }
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); }
@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); }
@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); }
private void createTitlePanelToolbar(@Nonnull String dimensionKey) { JPanel panel = new NonOpaquePanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); myRestoreSizeButton = new MyToolbarButton("Restore Size", CollapseComponent, CollapseComponentHover, e -> { WindowStateService.getInstance(myProject).putSizeFor(myProject, dimensionKey, null); myInternalSizeChanged = true; pack(true, true); }) { @Override protected boolean isButtonEnabled() { return myUserSizeChanged; } }; mySettingsButton = new MyToolbarButton("Settings", AllIcons.General.Gear, AllIcons.General.GearHover, e -> { final ActionPopupMenu popupMenu = ((ActionManagerImpl)ActionManager.getInstance()).createActionPopupMenu(BRANCH_POPUP, new DefaultActionGroup(mySettingsActions)); popupMenu.getComponent().show(mySettingsButton, 0, assertNotNull(mySettingsButton).getHeight()); }) { @Override protected boolean isButtonEnabled() { return !mySettingsActions.isEmpty(); } }; mySettingsButton.setBorder(JBUI.Borders.emptyLeft(4)); panel.add(myRestoreSizeButton); panel.add(mySettingsButton); getTitle().setButtonComponent(new ActiveComponent.Adapter() { @Override public JComponent getComponent() { return panel; } }, JBUI.Borders.emptyRight(2)); }
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); }
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); }
@Override public void preload() { ((ActionManagerImpl) ActionManager.getInstance()).preloadActionGroup(IdeActions.GROUP_GENERATE); }
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); }