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);
}
}
}
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);
}
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;
}
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);
}
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;
}
Aggregations