Search in sources :

Example 1 with BaseDomElementNode

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

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

the class GotoDomElementDeclarationAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) {
    final SimpleNode simpleNode = treeView.getTree().getSelectedNode();
    if (simpleNode instanceof BaseDomElementNode) {
        final DomElement domElement = ((BaseDomElementNode) simpleNode).getDomElement();
        final DomElementNavigationProvider provider = DomElementsNavigationManager.getManager(domElement.getManager().getProject()).getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME);
        provider.navigate(domElement, true);
    }
}
Also used : BaseDomElementNode(com.intellij.util.xml.tree.BaseDomElementNode) DomElement(com.intellij.util.xml.DomElement) DomElementNavigationProvider(com.intellij.util.xml.DomElementNavigationProvider) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 3 with BaseDomElementNode

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

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

the class DeleteDomElement method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) {
    final SimpleNode selectedNode = treeView.getTree().getSelectedNode();
    if (selectedNode instanceof BaseDomElementNode) {
        if (selectedNode instanceof DomFileElementNode) {
            e.getPresentation().setVisible(false);
            return;
        }
        final DomElement domElement = ((BaseDomElementNode) selectedNode).getDomElement();
        final int ret = Messages.showOkCancelDialog(getPresentationText(selectedNode, "Remove") + "?", "Remove", Messages.getQuestionIcon());
        if (ret == Messages.OK) {
            new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) {

                @Override
                protected void run(@NotNull final Result result) throws Throwable {
                    domElement.undefine();
                }
            }.execute();
        }
    }
}
Also used : WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) BaseDomElementNode(com.intellij.util.xml.tree.BaseDomElementNode) DomElement(com.intellij.util.xml.DomElement) DomFileElementNode(com.intellij.util.xml.tree.DomFileElementNode) SimpleNode(com.intellij.ui.treeStructure.SimpleNode) Result(com.intellij.openapi.application.Result)

Example 5 with BaseDomElementNode

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

the class DeleteDomElement method update.

@Override
public void update(AnActionEvent e, DomModelTreeView treeView) {
    final SimpleNode selectedNode = treeView.getTree().getSelectedNode();
    if (selectedNode instanceof DomFileElementNode) {
        e.getPresentation().setVisible(false);
        return;
    }
    boolean enabled = false;
    if (selectedNode instanceof BaseDomElementNode) {
        final DomElement domElement = ((BaseDomElementNode) selectedNode).getDomElement();
        if (domElement.isValid() && DomUtil.hasXml(domElement) && !(domElement.getParent() instanceof DomFileElement)) {
            enabled = true;
        }
    }
    e.getPresentation().setEnabled(enabled);
    if (enabled) {
        e.getPresentation().setText(getPresentationText(selectedNode, ApplicationBundle.message("action.remove")));
    } else {
        e.getPresentation().setText(ApplicationBundle.message("action.remove"));
    }
    e.getPresentation().setIcon(AllIcons.General.Remove);
}
Also used : BaseDomElementNode(com.intellij.util.xml.tree.BaseDomElementNode) DomElement(com.intellij.util.xml.DomElement) DomFileElementNode(com.intellij.util.xml.tree.DomFileElementNode) DomFileElement(com.intellij.util.xml.DomFileElement) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Aggregations

SimpleNode (com.intellij.ui.treeStructure.SimpleNode)5 BaseDomElementNode (com.intellij.util.xml.tree.BaseDomElementNode)5 DomElement (com.intellij.util.xml.DomElement)3 DomElementsGroupNode (com.intellij.util.xml.tree.DomElementsGroupNode)2 DomFileElementNode (com.intellij.util.xml.tree.DomFileElementNode)2 DomModelTreeView (com.intellij.util.xml.tree.DomModelTreeView)2 Result (com.intellij.openapi.application.Result)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 DomElementNavigationProvider (com.intellij.util.xml.DomElementNavigationProvider)1 DomFileElement (com.intellij.util.xml.DomFileElement)1 DomCollectionChildDescription (com.intellij.util.xml.reflect.DomCollectionChildDescription)1 NotNull (org.jetbrains.annotations.NotNull)1