Search in sources :

Example 1 with DomModelTreeView

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

the class AddElementInCollectionAction method isEnabled.

@Override
protected boolean isEnabled(final AnActionEvent e) {
    final DomModelTreeView treeView = getTreeView(e);
    final boolean enabled = treeView != null;
    e.getPresentation().setEnabled(enabled);
    return enabled;
}
Also used : DomModelTreeView(com.intellij.util.xml.tree.DomModelTreeView)

Example 2 with DomModelTreeView

use of com.intellij.util.xml.tree.DomModelTreeView 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 3 with DomModelTreeView

use of com.intellij.util.xml.tree.DomModelTreeView 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)

Aggregations

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