Search in sources :

Example 1 with ActionManagerImpl

use of com.intellij.openapi.actionSystem.impl.ActionManagerImpl in project intellij-community by JetBrains.

the class ToolWindowContentUi method showContextMenu.

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);
}
Also used : ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) MenuItemPresentationFactory(com.intellij.openapi.actionSystem.impl.MenuItemPresentationFactory)

Example 2 with ActionManagerImpl

use of com.intellij.openapi.actionSystem.impl.ActionManagerImpl in project intellij-community by JetBrains.

the class GotoActionItemProvider method processActions.

private boolean processActions(String pattern, boolean everywhere, Processor<MatchedValue> consumer, DataContext dataContext) {
    JBIterable<AnAction> actions;
    if (everywhere) {
        Set<String> ids = ((ActionManagerImpl) myActionManager).getActionIds();
        actions = JBIterable.from(ids).transform(myActionManager::getAction).filter(Condition.NOT_NULL);
    } else {
        actions = JBIterable.from(myModel.myActionGroups.keySet());
    }
    MinusculeMatcher matcher = NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE);
    JBIterable<ActionWrapper> actionWrappers = actions.transform(action -> {
        MatchMode mode = myModel.actionMatches(pattern, matcher, action);
        if (mode == MatchMode.NONE)
            return null;
        return new ActionWrapper(action, myModel.myActionGroups.get(action), mode, dataContext);
    }).filter(Condition.NOT_NULL);
    return processItems(pattern, actionWrappers, consumer);
}
Also used : CollectConsumer(com.intellij.util.CollectConsumer) java.util(java.util) JBIterable(com.intellij.util.containers.JBIterable) ApplyIntentionAction(com.intellij.ide.actions.ApplyIntentionAction) MinusculeMatcher(com.intellij.psi.codeStyle.MinusculeMatcher) ContainerUtil(com.intellij.util.containers.ContainerUtil) ActionFromOptionDescriptorProvider(com.intellij.ide.ui.search.ActionFromOptionDescriptorProvider) NameUtil(com.intellij.psi.codeStyle.NameUtil) SearchableOptionsRegistrarImpl(com.intellij.ide.ui.search.SearchableOptionsRegistrarImpl) Project(com.intellij.openapi.project.Project) SearchableOptionsRegistrar(com.intellij.ide.ui.search.SearchableOptionsRegistrar) Matcher(com.intellij.util.text.Matcher) DataManager(com.intellij.ide.DataManager) ProgressManager(com.intellij.openapi.progress.ProgressManager) StringUtil(com.intellij.openapi.util.text.StringUtil) NotNullLazyValue(com.intellij.openapi.util.NotNullLazyValue) ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) GotoActionModel(com.intellij.ide.util.gotoByName.GotoActionModel) OptionDescription(com.intellij.ide.ui.search.OptionDescription) Processor(com.intellij.util.Processor) OptionsTopHitProvider(com.intellij.ide.ui.OptionsTopHitProvider) NotNull(org.jetbrains.annotations.NotNull) SearchTopHitProvider(com.intellij.ide.SearchTopHitProvider) Condition(com.intellij.openapi.util.Condition) ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) MinusculeMatcher(com.intellij.psi.codeStyle.MinusculeMatcher)

Example 3 with ActionManagerImpl

use of com.intellij.openapi.actionSystem.impl.ActionManagerImpl in project intellij-community by JetBrains.

the class LightToolWindow method showGearPopup.

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);
}
Also used : ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) MenuItemPresentationFactory(com.intellij.openapi.actionSystem.impl.MenuItemPresentationFactory)

Example 4 with ActionManagerImpl

use of com.intellij.openapi.actionSystem.impl.ActionManagerImpl in project intellij-community by JetBrains.

the class TraverseUIStarter method processKeymap.

private static void processKeymap(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<>();
    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);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 5 with ActionManagerImpl

use of com.intellij.openapi.actionSystem.impl.ActionManagerImpl in project intellij-community by JetBrains.

the class ActionsWithoutUpdateMethodTest method testActionsWithShortcuts.

public void testActionsWithShortcuts() throws Exception {
    Set<String> ids = new HashSet<>();
    for (String id : ((ActionManagerImpl) ActionManager.getInstance()).getActionIds()) {
        for (Keymap keymap : KeymapManagerEx.getInstanceEx().getAllKeymaps()) {
            if (keymap.getShortcuts(id).length > 0 && !PLATFORM_WIDE_ACTIONS.contains(id)) {
                ids.add(id);
            }
        }
    }
    ActionManager mgr = ActionManager.getInstance();
    ArrayList<AnAction> failed = new ArrayList<>();
    for (String id : ids) {
        AnAction action = mgr.getAction(id);
        if (action == null) {
            System.out.println("Can't find action: " + id);
            continue;
        }
        Method updateMethod = action.getClass().getMethod("update", AnActionEvent.class);
        if (updateMethod.getDeclaringClass() == AnAction.class) {
            failed.add(action);
        }
    }
    for (AnAction action : failed) {
        System.out.println(action + " ID: " + mgr.getId(action) + " Class: " + action.getClass());
    }
    assertEmpty("The following actions have shortcuts, but don't have update() method redefined", failed);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ArrayList(java.util.ArrayList) ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) Method(java.lang.reflect.Method) AnAction(com.intellij.openapi.actionSystem.AnAction) Keymap(com.intellij.openapi.keymap.Keymap) HashSet(com.intellij.util.containers.HashSet)

Aggregations

ActionManagerImpl (com.intellij.openapi.actionSystem.impl.ActionManagerImpl)5 ActionManager (com.intellij.openapi.actionSystem.ActionManager)2 AnAction (com.intellij.openapi.actionSystem.AnAction)2 MenuItemPresentationFactory (com.intellij.openapi.actionSystem.impl.MenuItemPresentationFactory)2 DataManager (com.intellij.ide.DataManager)1 SearchTopHitProvider (com.intellij.ide.SearchTopHitProvider)1 ApplyIntentionAction (com.intellij.ide.actions.ApplyIntentionAction)1 OptionsTopHitProvider (com.intellij.ide.ui.OptionsTopHitProvider)1 ActionFromOptionDescriptorProvider (com.intellij.ide.ui.search.ActionFromOptionDescriptorProvider)1 OptionDescription (com.intellij.ide.ui.search.OptionDescription)1 SearchableOptionsRegistrar (com.intellij.ide.ui.search.SearchableOptionsRegistrar)1 SearchableOptionsRegistrarImpl (com.intellij.ide.ui.search.SearchableOptionsRegistrarImpl)1 GotoActionModel (com.intellij.ide.util.gotoByName.GotoActionModel)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Keymap (com.intellij.openapi.keymap.Keymap)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 Project (com.intellij.openapi.project.Project)1 Condition (com.intellij.openapi.util.Condition)1 NotNullLazyValue (com.intellij.openapi.util.NotNullLazyValue)1