Java 类com.intellij.util.xml.tree.DomFileElementNode 实例源码

项目:intellij-ce-playground    文件:DeleteDomElement.java   
@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();
    }
  }
}
项目:tools-idea    文件:DeleteDomElement.java   
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) + "?", ApplicationBundle.message("action.remove"),
                                                Messages.getQuestionIcon());
    if (ret == 0) {
    new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) {
      protected void run(final Result result) throws Throwable {
        domElement.undefine();
      }
    }.execute();
    }
  }
}
项目:consulo-xml    文件:DeleteDomElement.java   
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) + "?", ApplicationBundle.message("action.remove"),
                                                Messages.getQuestionIcon());
    if (ret == 0) {
    new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) {
      protected void run(final Result result) throws Throwable {
        domElement.undefine();
      }
    }.execute();
    }
  }
}
项目:intellij-ce-playground    文件:DeleteDomElement.java   
@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);
}
项目:tools-idea    文件:DeleteDomElement.java   
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));
  }
  else {
    e.getPresentation().setText(ApplicationBundle.message("action.remove"));
  }

  e.getPresentation().setIcon(AllIcons.General.Remove);
}
项目:consulo-xml    文件:DeleteDomElement.java   
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));
  }
  else {
    e.getPresentation().setText(ApplicationBundle.message("action.remove"));
  }

  e.getPresentation().setIcon(AllIcons.General.Remove);
}