Program: 148833
Project: 148833
Buggy source:
public IStatus doAction(){
  List<XSDComplexTypeDefinition> list=new ArrayList<XSDComplexTypeDefinition>();
  EList<XSDTypeDefinition> types=schema.getTypeDefinitions();
  for (  XSDTypeDefinition type : types) {
    if (type instanceof XSDComplexTypeDefinition)     list.add((XSDComplexTypeDefinition)type);
  }
  dialog=new ComplexTypeInputDialog(this,page.getSite().getShell(),schema,list,false);
  dialog.setBlockOnOpen(true);
  int ret=dialog.open();
  if (ret == Dialog.CANCEL) {
    return Status.CANCEL_STATUS;
  }
  XSDFactory factory=XSDSchemaBuildingTools.getXSDFactory();
  XSDModelGroup group=factory.createXSDModelGroup();
  XSDParticle subParticle=null;
  XSDElementDeclaration subElement=null;
  subElement=factory.createXSDElementDeclaration();
  subElement.setName("String_Node_Str");
  subElement.setTypeDefinition(schema.resolveSimpleTypeDefinition(schema.getSchemaForSchemaNamespace(),"String_Node_Str"));
  subParticle=factory.createXSDParticle();
  subParticle.setMinOccurs(1);
  subParticle.setMaxOccurs(1);
  subParticle.setContent(subElement);
  subParticle.updateElement();
  if (isChoice)   group.setCompositor(XSDCompositor.CHOICE_LITERAL);
 else   if (isAll)   group.setCompositor(XSDCompositor.ALL_LITERAL);
 else   group.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
  group.getContents().add(0,subParticle);
  group.updateElement();
  XSDComplexTypeDefinition complexType=factory.createXSDComplexTypeDefinition();
  complexType.setName(typeName);
  schema.getContents().add(complexType);
  complexType.updateElement();
  XSDParticle groupParticle=factory.createXSDParticle();
  groupParticle.setMinOccurs(1);
  groupParticle.setMaxOccurs(1);
  groupParticle.setContent(group);
  groupParticle.updateElement();
  complexType.setContent(groupParticle);
  complexType.updateElement();
  page.refresh();
  page.markDirty();
  return Status.OK_STATUS;
}

Fixed version (ground truth):
public IStatus doAction(){
  List<XSDComplexTypeDefinition> list=new ArrayList<XSDComplexTypeDefinition>();
  EList<XSDTypeDefinition> types=schema.getTypeDefinitions();
  for (  XSDTypeDefinition type : types) {
    if (type instanceof XSDComplexTypeDefinition)     list.add((XSDComplexTypeDefinition)type);
  }
  dialog=new ComplexTypeInputDialog(this,page.getSite().getShell(),schema,null,list,false);
  dialog.setBlockOnOpen(true);
  int ret=dialog.open();
  if (ret == Dialog.CANCEL) {
    return Status.CANCEL_STATUS;
  }
  XSDFactory factory=XSDSchemaBuildingTools.getXSDFactory();
  XSDModelGroup group=factory.createXSDModelGroup();
  XSDParticle subParticle=null;
  XSDElementDeclaration subElement=null;
  subElement=factory.createXSDElementDeclaration();
  subElement.setName("String_Node_Str");
  subElement.setTypeDefinition(schema.resolveSimpleTypeDefinition(schema.getSchemaForSchemaNamespace(),"String_Node_Str"));
  subParticle=factory.createXSDParticle();
  subParticle.setMinOccurs(1);
  subParticle.setMaxOccurs(1);
  subParticle.setContent(subElement);
  subParticle.updateElement();
  if (isChoice)   group.setCompositor(XSDCompositor.CHOICE_LITERAL);
 else   if (isAll)   group.setCompositor(XSDCompositor.ALL_LITERAL);
 else   group.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
  group.getContents().add(0,subParticle);
  group.updateElement();
  XSDComplexTypeDefinition complexType=factory.createXSDComplexTypeDefinition();
  complexType.setName(typeName);
  schema.getContents().add(complexType);
  complexType.updateElement();
  XSDParticle groupParticle=factory.createXSDParticle();
  groupParticle.setMinOccurs(1);
  groupParticle.setMaxOccurs(1);
  groupParticle.setContent(group);
  groupParticle.updateElement();
  complexType.setContent(groupParticle);
  complexType.updateElement();
  page.refresh();
  page.markDirty();
  return Status.OK_STATUS;
}