use of com.intellij.openapi.keymap.impl.ui.Group in project intellij-community by JetBrains.
the class VcsKeymapExtension method createGroup.
public KeymapGroup createGroup(final Condition<AnAction> filtered, final Project project) {
KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(KeyMapBundle.message("version.control.group.title"));
AnAction[] versionControlsGroups = ActionsTreeUtil.getActions("VcsGroup");
AnAction[] keymapGroups = ActionsTreeUtil.getActions("Vcs.KeymapGroup");
for (AnAction action : ContainerUtil.concat(versionControlsGroups, keymapGroups)) {
ActionsTreeUtil.addAction(result, action, filtered, false);
}
AnAction[] generalActions = ActionsTreeUtil.getActions("VcsGeneral.KeymapGroup");
for (AnAction action : generalActions) {
ActionsTreeUtil.addAction(result, action, filtered, true);
}
if (result instanceof Group) {
((Group) result).normalizeSeparators();
}
return result;
}
use of com.intellij.openapi.keymap.impl.ui.Group in project intellij-community by JetBrains.
the class CustomizationUtil method getActionUrl.
public static ActionUrl getActionUrl(final TreePath treePath, int actionType) {
ActionUrl url = new ActionUrl();
for (int i = 0; i < treePath.getPath().length - 1; i++) {
Object o = ((DefaultMutableTreeNode) treePath.getPath()[i]).getUserObject();
if (o instanceof Group) {
url.getGroupPath().add(((Group) o).getName());
}
}
final DefaultMutableTreeNode component = ((DefaultMutableTreeNode) treePath.getLastPathComponent());
url.setComponent(component.getUserObject());
final TreeNode parent = component.getParent();
url.setAbsolutePosition(parent != null ? parent.getIndex(component) : 0);
url.setActionType(actionType);
return url;
}
use of com.intellij.openapi.keymap.impl.ui.Group in project intellij-community by JetBrains.
the class CustomizationUtil method optimizeSchema.
public static void optimizeSchema(final JTree tree, final CustomActionsSchema schema) {
//noinspection HardCodedStringLiteral
Group rootGroup = new Group("root", null, null);
DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootGroup);
root.removeAllChildren();
schema.fillActionGroups(root);
final JTree defaultTree = new Tree(new DefaultTreeModel(root));
final List<ActionUrl> actions = new ArrayList<>();
TreeUtil.traverseDepth((TreeNode) tree.getModel().getRoot(), node -> {
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
Object userObject = treeNode.getUserObject();
if (treeNode.isLeaf() && !(userObject instanceof Group)) {
return true;
}
ActionUrl url = getActionUrl(new TreePath(treeNode.getPath()), 0);
String groupName = ((Group) userObject).getName();
url.getGroupPath().add(groupName);
final TreePath treePath = getTreePath(defaultTree, url);
if (treePath != null) {
final DefaultMutableTreeNode visited = (DefaultMutableTreeNode) treePath.getLastPathComponent();
final ActionUrl[] defaultUserObjects = getChildUserObjects(visited, url);
final ActionUrl[] currentUserObjects = getChildUserObjects(treeNode, url);
computeDiff(defaultUserObjects, currentUserObjects, actions);
} else {
url.getGroupPath().remove(url.getParentGroup());
if (actions.contains(url)) {
url.getGroupPath().add(groupName);
actions.addAll(schema.getChildActions(url));
}
}
return true;
});
schema.setActions(actions);
}
Aggregations