Program: 148094
Project: 148094
Buggy source:
public IStatus doAction(){
  try {
    IStructuredSelection selections=(TreeSelection)page.getTreeViewer().getSelection();
    XSDComponent xSDCom=null;
    XSDAnnotationsStructure struc=new XSDAnnotationsStructure(xSDCom);
    if (selections.isEmpty())     return Status.CANCEL_STATUS;
    dlg=new AnnotationOrderedListsDialog(new ArrayList(),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.AnnotationWrite_ActionType,null);
    dlg.setBlockOnOpen(true);
    int ret=dlg.open();
    if (ret == Window.CANCEL) {
      return Status.CANCEL_STATUS;
    }
    for (Iterator iterator=selections.iterator(); iterator.hasNext(); ) {
      Object toWri=(Object)iterator.next();
      UndoAction wriExecute=null;
      boolean isElem=true;
      if (toWri instanceof Element) {
        TreePath tPath=((TreeSelection)toWri).getPaths()[0];
        for (int i=0; i < tPath.getSegmentCount(); i++) {
          if (tPath.getSegment(i) instanceof XSDAnnotation)           xSDCom=(XSDAnnotation)(tPath.getSegment(i));
        }
      }
 else       xSDCom=(XSDComponent)toWri;
      struc=new XSDAnnotationsStructure(xSDCom);
      if (struc.getAnnotation() == null) {
        throw new RuntimeException("String_Node_Str" + xSDCom.getClass().getName());
      }
      struc.setAccessRole(dlg.getXPaths(),dlg.getRecursive(),(IStructuredContentProvider)page.getTreeViewer().getContentProvider(),"String_Node_Str");
      if (struc.hasChanged())       isChanged=true;
    }
    if (isChanged) {
      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 {
    IStructuredSelection selections=(TreeSelection)page.getTreeViewer().getSelection();
    XSDComponent xSDCom=null;
    XSDAnnotationsStructure struc=new XSDAnnotationsStructure(xSDCom);
    if (selections.isEmpty())     return Status.CANCEL_STATUS;
    dlg=getNewAnnotaionOrderedListsDialog(Collections.EMPTY_LIST);
    dlg.setBlockOnOpen(true);
    int ret=dlg.open();
    if (ret == Window.CANCEL) {
      return Status.CANCEL_STATUS;
    }
    for (Iterator iterator=selections.iterator(); iterator.hasNext(); ) {
      Object toWri=(Object)iterator.next();
      UndoAction wriExecute=null;
      boolean isElem=true;
      if (toWri instanceof Element) {
        TreePath tPath=((TreeSelection)toWri).getPaths()[0];
        for (int i=0; i < tPath.getSegmentCount(); i++) {
          if (tPath.getSegment(i) instanceof XSDAnnotation)           xSDCom=(XSDAnnotation)(tPath.getSegment(i));
        }
      }
 else       xSDCom=(XSDComponent)toWri;
      struc=new XSDAnnotationsStructure(xSDCom);
      if (struc.getAnnotation() == null) {
        throw new RuntimeException("String_Node_Str" + xSDCom.getClass().getName());
      }
      struc.setAccessRole(dlg.getXPaths(),dlg.getRecursive(),(IStructuredContentProvider)page.getTreeViewer().getContentProvider(),"String_Node_Str");
      if (struc.hasChanged())       isChanged=true;
    }
    if (isChanged) {
      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;
}