Program: 148922
Project: 148922
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,null,simpleType.getName());
    if (find) {
      MessageDialog.openWarning(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + simpleType.getName() + "String_Node_Str");
      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,null,complxType.getName());
    if (find) {
      MessageDialog.openWarning(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + complxType.getName() + "String_Node_Str");
      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());
  if (selection.getFirstElement() instanceof XSDSimpleTypeDefinition) {
    XSDSimpleTypeDefinition simpleType=(XSDSimpleTypeDefinition)selection.getFirstElement();
    if (xsdSimpType != null)     simpleType=xsdSimpType;
    boolean find=Util.findElementsUsingType(objList,simpleType);
    if (find) {
      MessageDialog.openWarning(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + simpleType.getName() + "String_Node_Str");
      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) {
      MessageDialog.openWarning(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + complxType.getName() + "String_Node_Str");
      xsdCmpexType=null;
      return Status.CANCEL_STATUS;
    }
    schema.getContents().remove(complxType);
  }
  xsdCmpexType=null;
  page.refresh();
  page.markDirty();
  return Status.OK_STATUS;
}