Search in sources :

Example 1 with DomElementsGroupNode

use of com.intellij.util.xml.tree.DomElementsGroupNode in project intellij-community by JetBrains.

the class AddElementInCollectionAction method getParentDomElement.

@Override
protected DomElement getParentDomElement(final AnActionEvent e) {
    final DomModelTreeView view = getTreeView(e);
    SimpleNode node = view.getTree().getSelectedNode();
    if (node instanceof BaseDomElementNode) {
        if (((BaseDomElementNode) node).getConsolidatedChildrenDescriptions().size() > 0) {
            return ((BaseDomElementNode) node).getDomElement();
        }
    }
    final DomElementsGroupNode groupNode = getDomElementsGroupNode(view);
    return groupNode == null ? null : groupNode.getDomElement();
}
Also used : BaseDomElementNode(com.intellij.util.xml.tree.BaseDomElementNode) DomModelTreeView(com.intellij.util.xml.tree.DomModelTreeView) DomElementsGroupNode(com.intellij.util.xml.tree.DomElementsGroupNode) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 2 with DomElementsGroupNode

use of com.intellij.util.xml.tree.DomElementsGroupNode in project intellij-community by JetBrains.

the class AddElementInCollectionAction method getDomCollectionChildDescriptions.

@Override
@NotNull
protected DomCollectionChildDescription[] getDomCollectionChildDescriptions(final AnActionEvent e) {
    final DomModelTreeView view = getTreeView(e);
    SimpleNode node = view.getTree().getSelectedNode();
    if (node instanceof BaseDomElementNode) {
        List<DomCollectionChildDescription> consolidated = ((BaseDomElementNode) node).getConsolidatedChildrenDescriptions();
        if (consolidated.size() > 0) {
            return consolidated.toArray(new DomCollectionChildDescription[consolidated.size()]);
        }
    }
    final DomElementsGroupNode groupNode = getDomElementsGroupNode(view);
    return groupNode == null ? DomCollectionChildDescription.EMPTY_ARRAY : new DomCollectionChildDescription[] { groupNode.getChildDescription() };
}
Also used : BaseDomElementNode(com.intellij.util.xml.tree.BaseDomElementNode) DomModelTreeView(com.intellij.util.xml.tree.DomModelTreeView) DomElementsGroupNode(com.intellij.util.xml.tree.DomElementsGroupNode) DomCollectionChildDescription(com.intellij.util.xml.reflect.DomCollectionChildDescription) SimpleNode(com.intellij.ui.treeStructure.SimpleNode) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with DomElementsGroupNode

use of com.intellij.util.xml.tree.DomElementsGroupNode in project intellij-community by JetBrains.

the class AddElementInCollectionAction method getActionText.

@Override
protected String getActionText(final AnActionEvent e) {
    String text = ApplicationBundle.message("action.add");
    if (e.getPresentation().isEnabled()) {
        final DomElementsGroupNode selectedNode = getDomElementsGroupNode(getTreeView(e));
        if (selectedNode != null) {
            final Type type = selectedNode.getChildDescription().getType();
            text += " " + TypePresentationService.getService().getTypePresentableName(ReflectionUtil.getRawType(type));
        }
    }
    return text;
}
Also used : Type(java.lang.reflect.Type) DomElementsGroupNode(com.intellij.util.xml.tree.DomElementsGroupNode)

Aggregations

DomElementsGroupNode (com.intellij.util.xml.tree.DomElementsGroupNode)3 SimpleNode (com.intellij.ui.treeStructure.SimpleNode)2 BaseDomElementNode (com.intellij.util.xml.tree.BaseDomElementNode)2 DomModelTreeView (com.intellij.util.xml.tree.DomModelTreeView)2 DomCollectionChildDescription (com.intellij.util.xml.reflect.DomCollectionChildDescription)1 Type (java.lang.reflect.Type)1 NotNull (org.jetbrains.annotations.NotNull)1