Search in sources :

Example 6 with Group

use of com.intellij.openapi.keymap.impl.ui.Group in project intellij-community by JetBrains.

the class ActionUrl method addPathToActionsTree.

private static void addPathToActionsTree(JTree tree, ActionUrl url) {
    final TreePath treePath = CustomizationUtil.getTreePath(tree, url);
    if (treePath == null)
        return;
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
    final int absolutePosition = url.getAbsolutePosition();
    if (node.getChildCount() >= absolutePosition && absolutePosition >= 0) {
        if (url.getComponent() instanceof Group) {
            node.insert(ActionsTreeUtil.createNode((Group) url.getComponent()), absolutePosition);
        } else {
            node.insert(new DefaultMutableTreeNode(url.getComponent()), absolutePosition);
        }
    }
}
Also used : ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) Group(com.intellij.openapi.keymap.impl.ui.Group) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 7 with Group

use of com.intellij.openapi.keymap.impl.ui.Group in project intellij-community by JetBrains.

the class ActionUrl method readExternal.

@Override
public void readExternal(Element element) throws InvalidDataException {
    myGroupPath = new ArrayList<>();
    for (Object o : element.getChildren(PATH)) {
        myGroupPath.add(((Element) o).getAttributeValue(VALUE));
    }
    final String attributeValue = element.getAttributeValue(VALUE);
    if (element.getAttributeValue(IS_ACTION) != null) {
        myComponent = attributeValue;
    } else if (element.getAttributeValue(SEPARATOR) != null) {
        myComponent = Separator.getInstance();
    } else if (element.getAttributeValue(IS_GROUP) != null) {
        final AnAction action = ActionManager.getInstance().getAction(attributeValue);
        myComponent = action instanceof ActionGroup ? ActionsTreeUtil.createGroup((ActionGroup) action, true, null) : new Group(attributeValue, attributeValue, null);
    }
    myActionType = Integer.parseInt(element.getAttributeValue(ACTION_TYPE));
    myAbsolutePosition = Integer.parseInt(element.getAttributeValue(POSITION));
    DefaultJDOMExternalizer.readExternal(this, element);
}
Also used : ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) Group(com.intellij.openapi.keymap.impl.ui.Group) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 8 with Group

use of com.intellij.openapi.keymap.impl.ui.Group in project intellij-community by JetBrains.

the class DebuggerKeymapExtension method createGroup.

public KeymapGroup createGroup(final Condition<AnAction> filtered, final Project project) {
    AnAction[] xDebuggerActions = ActionsTreeUtil.getActions("XDebugger.Actions");
    AnAction[] javaDebuggerActions = ActionsTreeUtil.getActions("JavaDebuggerActions");
    Group group = new Group(KeyMapBundle.message("debugger.actions.group.title"), AllIcons.General.Debug);
    for (AnAction action : ArrayUtil.mergeArrays(xDebuggerActions, javaDebuggerActions)) {
        ActionsTreeUtil.addAction(group, action, filtered);
    }
    return group;
}
Also used : KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) Group(com.intellij.openapi.keymap.impl.ui.Group) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 9 with Group

use of com.intellij.openapi.keymap.impl.ui.Group in project intellij-community by JetBrains.

the class ActionUrl method writeExternal.

@Override
public void writeExternal(Element element) throws WriteExternalException {
    for (String s : myGroupPath) {
        Element path = new Element(PATH);
        path.setAttribute(VALUE, s);
        element.addContent(path);
    }
    if (myComponent instanceof String) {
        element.setAttribute(VALUE, (String) myComponent);
        element.setAttribute(IS_ACTION, Boolean.TRUE.toString());
    } else if (myComponent instanceof Separator) {
        element.setAttribute(SEPARATOR, Boolean.TRUE.toString());
    } else if (myComponent instanceof Group) {
        final String groupId = ((Group) myComponent).getId() != null && ((Group) myComponent).getId().length() != 0 ? ((Group) myComponent).getId() : ((Group) myComponent).getName();
        element.setAttribute(VALUE, groupId != null ? groupId : "");
        element.setAttribute(IS_GROUP, Boolean.TRUE.toString());
    }
    element.setAttribute(ACTION_TYPE, Integer.toString(myActionType));
    element.setAttribute(POSITION, Integer.toString(myAbsolutePosition));
    DefaultJDOMExternalizer.writeExternal(this, element);
}
Also used : ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) Group(com.intellij.openapi.keymap.impl.ui.Group) Element(org.jdom.Element) Separator(com.intellij.openapi.actionSystem.Separator)

Example 10 with Group

use of com.intellij.openapi.keymap.impl.ui.Group in project intellij-community by JetBrains.

the class BaseToolKeymapExtension method createGroup.

@Override
public KeymapGroup createGroup(final Condition<AnAction> filtered, final Project project) {
    final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    String[] ids = actionManager.getActionIds(getActionIdPrefix());
    Arrays.sort(ids);
    Group group = new Group(getGroupName(), AllIcons.Nodes.KeymapTools);
    HashMap<String, Group> toolGroupNameToGroup = new HashMap<>();
    for (String id : ids) {
        if (filtered != null && !filtered.value(actionManager.getActionOrStub(id)))
            continue;
        String groupName = getGroupByActionId(id);
        if (groupName != null && groupName.trim().length() == 0) {
            groupName = null;
        }
        Group subGroup = toolGroupNameToGroup.get(groupName);
        if (subGroup == null) {
            subGroup = new Group(groupName, null, null);
            toolGroupNameToGroup.put(groupName, subGroup);
            if (groupName != null) {
                group.addGroup(subGroup);
            }
        }
        subGroup.addActionId(id);
    }
    Group subGroup = toolGroupNameToGroup.get(null);
    if (subGroup != null) {
        group.addAll(subGroup);
    }
    return group;
}
Also used : KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) Group(com.intellij.openapi.keymap.impl.ui.Group) HashMap(com.intellij.util.containers.HashMap) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

Aggregations

Group (com.intellij.openapi.keymap.impl.ui.Group)13 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)4 KeymapGroup (com.intellij.openapi.keymap.KeymapGroup)4 TreePath (javax.swing.tree.TreePath)4 AnAction (com.intellij.openapi.actionSystem.AnAction)3 Tree (com.intellij.ui.treeStructure.Tree)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 TreeNode (javax.swing.tree.TreeNode)2 AllIcons (com.intellij.icons.AllIcons)1 DataManager (com.intellij.ide.DataManager)1 CustomActionsSchema (com.intellij.ide.ui.customization.CustomActionsSchema)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 Separator (com.intellij.openapi.actionSystem.Separator)1 ActionManagerEx (com.intellij.openapi.actionSystem.ex.ActionManagerEx)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ExtensionPoint (com.intellij.openapi.extensions.ExtensionPoint)1 ExternalSystemKeymapExtension (com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemKeymapExtension)1 KeymapGroupFactory (com.intellij.openapi.keymap.KeymapGroupFactory)1