Program: 148803
Project: 148803
Buggy source:
public IStatus doAction(){
  IStructuredSelection selection=(IStructuredSelection)page.getTreeViewer().getSelection();
  XSDSchema schema=((ISchemaContentProvider)page.getTreeViewer().getContentProvider()).getXsdSchema();
  ArrayList<Object> objList=new ArrayList<Object>();
  Util.getAllObject(page.getSite(),objList,(IStructuredContentProvider)page.getSchemaContentProvider());
  Util.getAllObject(page.getSite(),objList,(IStructuredContentProvider)page.getTypeContentProvider());
  if (selection.getFirstElement() instanceof XSDSimpleTypeDefinition) {
    XSDSimpleTypeDefinition simpleType=(XSDSimpleTypeDefinition)selection.getFirstElement();
    if (xsdSimpType != null)     simpleType=xsdSimpType;
    boolean find=Util.findElementsUsingType(objList,simpleType);
    if (find) {
      boolean confirmed=MessageDialog.openConfirm(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + simpleType.getName() + "String_Node_Str"+ "String_Node_Str");
      if (!confirmed) {
        xsdSimpType=null;
        return Status.CANCEL_STATUS;
      }
    }
    schema.getContents().remove(simpleType);
  }
 else {
    XSDComplexTypeDefinition complxType=(XSDComplexTypeDefinition)selection.getFirstElement();
    if (xsdCmpexType != null) {
      complxType=xsdCmpexType;
    }
    boolean find=Util.findElementsUsingType(objList,complxType);
    if (find) {
      boolean confirmed=MessageDialog.openConfirm(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + complxType.getName() + "String_Node_Str"+ "String_Node_Str");
      if (!confirmed) {
        xsdCmpexType=null;
        return Status.CANCEL_STATUS;
      }
    }
    schema.getContents().remove(complxType);
  }
  xsdCmpexType=null;
  page.refresh();
  page.markDirty();
  return Status.OK_STATUS;
}

Fixed version (ground truth):
public IStatus doAction(){
  IStructuredSelection selection=(IStructuredSelection)page.getTreeViewer().getSelection();
  XSDSchema schema=((ISchemaContentProvider)page.getTreeViewer().getContentProvider()).getXsdSchema();
  ArrayList<Object> objList=new ArrayList<Object>();
  Util.getAllObject(page.getSite(),objList,(IStructuredContentProvider)page.getSchemaContentProvider());
  Util.getAllObject(page.getSite(),objList,(IStructuredContentProvider)page.getTypeContentProvider());
  for (Iterator<XSDTypeDefinition> iter=selection.iterator(); iter.hasNext(); ) {
    XSDTypeDefinition type=iter.next();
    if (type instanceof XSDSimpleTypeDefinition) {
      XSDSimpleTypeDefinition simpleType=(XSDSimpleTypeDefinition)type;
      if (xsdSimpType != null)       simpleType=xsdSimpType;
      boolean find=Util.findElementsUsingType(objList,simpleType);
      if (find) {
        boolean confirmed=MessageDialog.openConfirm(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + simpleType.getName() + "String_Node_Str"+ "String_Node_Str");
        if (!confirmed) {
          xsdSimpType=null;
          return Status.CANCEL_STATUS;
        }
      }
      schema.getContents().remove(simpleType);
    }
 else {
      XSDComplexTypeDefinition complxType=(XSDComplexTypeDefinition)type;
      if (xsdCmpexType != null) {
        complxType=xsdCmpexType;
      }
      boolean find=Util.findElementsUsingType(objList,complxType);
      if (find) {
        boolean confirmed=MessageDialog.openConfirm(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + complxType.getName() + "String_Node_Str"+ "String_Node_Str");
        if (!confirmed) {
          xsdCmpexType=null;
          return Status.CANCEL_STATUS;
        }
      }
      schema.getContents().remove(complxType);
    }
  }
  xsdCmpexType=null;
  page.refresh();
  page.markDirty();
  return Status.OK_STATUS;
}