Program: 121703
Project: 121703
Buggy source:
@Override public void run(){
  TreeNode treeNode=null;
  if (input) {
    treeNode=XmlmapFactory.eINSTANCE.createTreeNode();
  }
 else {
    treeNode=XmlmapFactory.eINSTANCE.createOutputTreeNode();
  }
  String label="String_Node_Str";
  InputDialog dialog=new InputDialog(null,"String_Node_Str","String_Node_Str","String_Node_Str",null);
  int open=-1;
  while (!StringUtil.validateLabelForXML(label)) {
    open=dialog.open();
    if (open == InputDialog.OK) {
      label=dialog.getValue().trim();
    }
    if (open == InputDialog.CANCEL) {
      return;
    }
  }
  if (open == Window.OK) {
    treeNode.setName(label);
    treeNode.setNodeType(NodeType.ATTRIBUT);
    String parentXpath=parent.getXpath();
    if (parent.isChoice() || parent.isSubstitution()) {
      TreeNode realPrant=XmlMapUtil.getRealParentNode(parent);
      if (realPrant != null) {
        parentXpath=realPrant.getXpath();
      }
    }
    treeNode.setXpath(XmlMapUtil.getXPath(parentXpath,treeNode.getName(),treeNode.getNodeType()));
    treeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
    final EList<TreeNode> children=parent.getChildren();
    int index=0;
    for (int i=0; i < children.size(); i++) {
      final TreeNode child=children.get(i);
      if (child.getNodeType() == NodeType.NAME_SPACE || child.getNodeType() == NodeType.ATTRIBUT) {
        if (i == children.size() - 1) {
          index=children.size();
        }
        continue;
      }
 else {
        index=i;
        break;
      }
    }
    children.add(index,treeNode);
  }
  if (open == Window.OK && mapperManager != null) {
    TreeNode docRoot=XmlMapUtil.getTreeNodeRoot(parent);
    if (input) {
      if (docRoot != null && docRoot.eContainer() instanceof InputXmlTree) {
        mapperManager.refreshInputTreeSchemaEditor((InputXmlTree)docRoot.eContainer());
      }
    }
 else {
      if (docRoot != null && docRoot.eContainer() instanceof OutputXmlTree) {
        mapperManager.refreshOutputTreeSchemaEditor((OutputXmlTree)docRoot.eContainer());
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  TreeNode treeNode=null;
  if (input) {
    treeNode=XmlmapFactory.eINSTANCE.createTreeNode();
  }
 else {
    treeNode=XmlmapFactory.eINSTANCE.createOutputTreeNode();
  }
  String label="String_Node_Str";
  InputDialog dialog=new InputDialog(null,"String_Node_Str","String_Node_Str","String_Node_Str",null);
  int open=-1;
  while (!StringUtil.validateLabelForXML(label)) {
    open=dialog.open();
    if (open == InputDialog.OK) {
      label=dialog.getValue().trim();
    }
    if (open == InputDialog.CANCEL) {
      return;
    }
  }
  if (open == Window.OK) {
    treeNode.setName(label);
    treeNode.setNodeType(NodeType.ATTRIBUT);
    String parentXpath=parent.getXpath();
    if (parent.isChoice() || parent.isSubstitution()) {
      TreeNode realPrant=XmlMapUtil.getRealParentNode(parent);
      if (realPrant != null) {
        parentXpath=realPrant.getXpath();
      }
    }
    treeNode.setXpath(XmlMapUtil.getXPath(parentXpath,treeNode.getName(),treeNode.getNodeType()));
    treeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
    final EList<TreeNode> children=parent.getChildren();
    int index=0;
    for (int i=0; i < children.size(); i++) {
      final TreeNode child=children.get(i);
      if (child.getNodeType() == NodeType.NAME_SPACE || child.getNodeType() == NodeType.ATTRIBUT) {
        if (i == children.size() - 1) {
          index=children.size();
        }
        continue;
      }
 else {
        index=i;
        break;
      }
    }
    children.add(index,treeNode);
  }
  if (open == Window.OK && mapperManager != null) {
    Object object=graphicViewer.getEditPartRegistry().get(treeNode);
    if (object instanceof TreeNodeEditPart) {
      graphicViewer.select((TreeNodeEditPart)object);
    }
  }
}