Program: 121707
Project: 121707
Buggy source:
@Override public void run(){
  String prefix=null;
  String defaultValue=null;
  NameSpaceDialog nsDialog=new NameSpaceDialog(null);
  nsDialog.setParentNode(parent);
  int status=nsDialog.open();
  if (status == nsDialog.OK) {
    defaultValue=nsDialog.getNSValue();
    if (defaultValue != null) {
      defaultValue=defaultValue.trim();
    }
    prefix=nsDialog.getPrefix().trim();
  }
  if (status == nsDialog.CANCEL) {
    return;
  }
  TreeNode createdNode=null;
  if (input) {
    createdNode=XmlmapFactory.eINSTANCE.createTreeNode();
  }
 else {
    createdNode=XmlmapFactory.eINSTANCE.createOutputTreeNode();
  }
  createdNode.setName(prefix);
  createdNode.setNodeType(NodeType.NAME_SPACE);
  createdNode.setDefaultValue(defaultValue);
  createdNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
  String label=createdNode.getName();
  if (prefix == null || "String_Node_Str".equals(prefix)) {
    label=XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX;
    createdNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
  }
  String parentXpath=parent.getXpath();
  if (parent.isChoice() || parent.isSubstitution()) {
    TreeNode realPrant=XmlMapUtil.getRealParentNode(parent);
    if (realPrant != null) {
      parentXpath=realPrant.getXpath();
    }
  }
  createdNode.setXpath(XmlMapUtil.getXPath(parentXpath,label,NodeType.NAME_SPACE));
  final EList<TreeNode> children=parent.getChildren();
  int index=0;
  for (int i=0; i < children.size(); i++) {
    final TreeNode treeNode=children.get(i);
    if (treeNode.getNodeType() == NodeType.NAME_SPACE) {
      if (i == children.size() - 1) {
        index=children.size();
      }
      continue;
    }
 else {
      index=i;
      break;
    }
  }
  children.add(index,createdNode);
  TreeNode docRoot=XmlMapUtil.getTreeNodeRoot(parent);
  if (docRoot != null && docRoot.eContainer() instanceof OutputXmlTree) {
    mapperManager.refreshOutputTreeSchemaEditor((OutputXmlTree)docRoot.eContainer());
  }
 else   if (docRoot != null && docRoot.eContainer() instanceof InputXmlTree) {
    mapperManager.refreshInputTreeSchemaEditor((InputXmlTree)docRoot.eContainer());
  }
}

Fixed version (ground truth):
@Override public void run(){
  String prefix=null;
  String defaultValue=null;
  NameSpaceDialog nsDialog=new NameSpaceDialog(null);
  nsDialog.setParentNode(parent);
  int status=nsDialog.open();
  if (status == nsDialog.OK) {
    defaultValue=nsDialog.getNSValue();
    if (defaultValue != null) {
      defaultValue=defaultValue.trim();
    }
    prefix=nsDialog.getPrefix().trim();
  }
  if (status == nsDialog.CANCEL) {
    return;
  }
  TreeNode createdNode=null;
  if (input) {
    createdNode=XmlmapFactory.eINSTANCE.createTreeNode();
  }
 else {
    createdNode=XmlmapFactory.eINSTANCE.createOutputTreeNode();
  }
  createdNode.setName(prefix);
  createdNode.setNodeType(NodeType.NAME_SPACE);
  createdNode.setDefaultValue(defaultValue);
  createdNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
  String label=createdNode.getName();
  if (prefix == null || "String_Node_Str".equals(prefix)) {
    label=XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX;
    createdNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
  }
  String parentXpath=parent.getXpath();
  if (parent.isChoice() || parent.isSubstitution()) {
    TreeNode realPrant=XmlMapUtil.getRealParentNode(parent);
    if (realPrant != null) {
      parentXpath=realPrant.getXpath();
    }
  }
  createdNode.setXpath(XmlMapUtil.getXPath(parentXpath,label,NodeType.NAME_SPACE));
  final EList<TreeNode> children=parent.getChildren();
  int index=0;
  for (int i=0; i < children.size(); i++) {
    final TreeNode treeNode=children.get(i);
    if (treeNode.getNodeType() == NodeType.NAME_SPACE) {
      if (i == children.size() - 1) {
        index=children.size();
      }
      continue;
    }
 else {
      index=i;
      break;
    }
  }
  children.add(index,createdNode);
  Object object=graphicViewer.getEditPartRegistry().get(createdNode);
  if (object instanceof TreeNodeEditPart) {
    graphicViewer.select((TreeNodeEditPart)object);
  }
}