Program: 147837
Project: 147837
Buggy source:
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.SaveWithForce(new NullProgressMonitor());
 else       return Status.CANCEL_STATUS;
    }
    IStructuredSelection selection=(TreeSelection)page.getTreeViewer().getSelection();
    XSDComponent xSDCom=null;
    String conceptName=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();
    if (xSDCom instanceof XSDElementDeclaration) {
      conceptName=xSDCom.getElement().getAttributes().getNamedItem("String_Node_Str").getNodeValue();
    }
    if (xSDCom instanceof XSDParticle) {
    }
    XSDAnnotationsStructure struc=null;
    if (xSDCom != null)     struc=new XSDAnnotationsStructure(xSDCom);
    if (struc == null || struc.getAnnotation() == null) {
      throw new RuntimeException("String_Node_Str" + xSDCom.getClass().getName());
    }
    fkd=getNewFKFilterDialog(page.getSite().getShell(),struc.getFKFilter(),page,conceptName);
    fkd.setBlockOnOpen(true);
    int ret=fkd.open();
    if (ret == Window.CANCEL) {
      return Status.CANCEL_STATUS;
    }
    String fkfilter=fkd.getFilter();
    struc.setFKFilter(fkfilter);
    if (struc.hasChanged()) {
      page.refresh();
      page.getTreeViewer().expandToLevel(xSDCom,2);
      page.markDirty();
    }
  }
 catch (  Exception e) {
    log.error(e.getMessage(),e);
    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(),Messages.getString("String_Node_Str"),"String_Node_Str" + page.getXObject().getDisplayName() + "String_Node_Str"+ Messages.getString("String_Node_Str"));
      if (save) {
        IEditorPart part=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().saveEditor(part,false);
      }
 else       return Status.CANCEL_STATUS;
    }
    IStructuredSelection selection=(TreeSelection)page.getTreeViewer().getSelection();
    XSDComponent xSDCom=null;
    String conceptName=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();
    if (xSDCom instanceof XSDElementDeclaration) {
      conceptName=xSDCom.getElement().getAttributes().getNamedItem("String_Node_Str").getNodeValue();
    }
    if (xSDCom instanceof XSDParticle) {
    }
    XSDAnnotationsStructure struc=null;
    if (xSDCom != null)     struc=new XSDAnnotationsStructure(xSDCom);
    if (struc == null || struc.getAnnotation() == null) {
      throw new RuntimeException(Messages.getString("String_Node_Str") + xSDCom.getClass().getName());
    }
    fkd=getNewFKFilterDialog(page.getSite().getShell(),struc.getFKFilter(),page,conceptName);
    fkd.setBlockOnOpen(true);
    int ret=fkd.open();
    if (ret == Window.CANCEL) {
      return Status.CANCEL_STATUS;
    }
    String fkfilter=fkd.getFilter();
    struc.setFKFilter(fkfilter);
    if (struc.hasChanged()) {
      page.refresh();
      page.getTreeViewer().expandToLevel(xSDCom,2);
      page.markDirty();
    }
  }
 catch (  Exception e) {
    log.error(e.getMessage(),e);
    MessageDialog.openError(page.getSite().getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str") + e.getLocalizedMessage());
    return Status.CANCEL_STATUS;
  }
  return Status.OK_STATUS;
}