Program: 148910
Project: 148910
Buggy source:
public IStatus doAction(){
  try {
    IStructuredSelection selection=(TreeSelection)page.getTreeViewer().getSelection();
    XSDComponent xSDCom=null;
    if (selection.getFirstElement() instanceof Element) {
      TreePath tPath=((TreeSelection)selection).getPaths()[0];
      for (int i=0; i < tPath.getSegmentCount(); i++) {
        if (tPath.getSegment(i) instanceof XSDAnnotation)         xSDCom=(XSDAnnotation)(tPath.getSegment(i));
      }
    }
 else     xSDCom=(XSDComponent)selection.getFirstElement();
    XSDAnnotationsStructure struc=new XSDAnnotationsStructure(xSDCom);
    if (struc.getAnnotation() == null) {
      throw new RuntimeException("String_Node_Str" + xSDCom.getClass().getName());
    }
    dlg=new AnnotationOrderedListsDialog(new ArrayList(struc.getForeignKeyInfos().values()),new SelectionListener(){
      public void widgetDefaultSelected(      SelectionEvent e){
      }
      public void widgetSelected(      SelectionEvent e){
        dlg.close();
      }
    }
,page.getSite().getShell(),"String_Node_Str","String_Node_Str",page,AnnotationOrderedListsDialog.AnnotationForeignKeyInfo_ActionType,dataModelName);
    dlg.setBlockOnOpen(true);
    int ret=dlg.open();
    if (ret == Window.CANCEL) {
      return Status.CANCEL_STATUS;
    }
    struc.setForeignKeyInfos(dlg.getXPaths());
    if (struc.hasChanged()) {
      page.refresh();
      page.getTreeViewer().expandToLevel(xSDCom,2);
      page.markDirty();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    MessageDialog.openError(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + e.getLocalizedMessage());
    return Status.CANCEL_STATUS;
  }
  return Status.OK_STATUS;
}

Fixed version (ground truth):
public IStatus doAction(){
  try {
    if (page.isDirty()) {
      boolean save=MessageDialog.openConfirm(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + page.getXObject().getDisplayName() + "String_Node_Str");
      if (save)       page.getEditor().doSave(new NullProgressMonitor());
 else       return Status.CANCEL_STATUS;
    }
    IStructuredSelection selection=(TreeSelection)page.getTreeViewer().getSelection();
    XSDComponent xSDCom=null;
    if (selection.getFirstElement() instanceof Element) {
      TreePath tPath=((TreeSelection)selection).getPaths()[0];
      for (int i=0; i < tPath.getSegmentCount(); i++) {
        if (tPath.getSegment(i) instanceof XSDAnnotation)         xSDCom=(XSDAnnotation)(tPath.getSegment(i));
      }
    }
 else     xSDCom=(XSDComponent)selection.getFirstElement();
    XSDAnnotationsStructure struc=new XSDAnnotationsStructure(xSDCom);
    if (struc.getAnnotation() == null) {
      throw new RuntimeException("String_Node_Str" + xSDCom.getClass().getName());
    }
    dlg=new AnnotationOrderedListsDialog(new ArrayList(struc.getForeignKeyInfos().values()),new SelectionListener(){
      public void widgetDefaultSelected(      SelectionEvent e){
      }
      public void widgetSelected(      SelectionEvent e){
        dlg.close();
      }
    }
,page.getSite().getShell(),"String_Node_Str","String_Node_Str",page,AnnotationOrderedListsDialog.AnnotationForeignKeyInfo_ActionType,dataModelName);
    dlg.setBlockOnOpen(true);
    int ret=dlg.open();
    if (ret == Window.CANCEL) {
      return Status.CANCEL_STATUS;
    }
    struc.setForeignKeyInfos(dlg.getXPaths());
    if (struc.hasChanged()) {
      page.refresh();
      page.getTreeViewer().expandToLevel(xSDCom,2);
      page.markDirty();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    MessageDialog.openError(page.getSite().getShell(),"String_Node_Str","String_Node_Str" + e.getLocalizedMessage());
    return Status.CANCEL_STATUS;
  }
  return Status.OK_STATUS;
}