Program: 149012
Project: 149012
Buggy source:
public IStatus doAction(){
  try {
    schema=((XSDTreeContentProvider)page.getTreeViewer().getContentProvider()).getXsdSchema();
    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());
    }
    String conceptName=null;
    if (xSDCom instanceof XSDAnnotation) {
      conceptName=xSDCom.getContainer().getElement().getAttributes().getNamedItem("String_Node_Str").getNodeValue();
    }
    if (xSDCom instanceof XSDElementDeclaration) {
      conceptName=xSDCom.getElement().getAttributes().getNamedItem("String_Node_Str").getNodeValue();
      InputDialog input=new InputDialog(null,"String_Node_Str","String_Node_Str","String_Node_Str",null);
      input.open();
      if (input.getReturnCode() == InputDialog.OK) {
        String pattern="String_Node_Str" + input.getValue() + "String_Node_Str";
        struc.addSchematron(pattern);
        page.refresh();
        page.getTreeViewer().expandToLevel(xSDCom,2);
        page.markDirty();
        return Status.OK_STATUS;
      }
    }
    if (!(selection.getFirstElement() instanceof Element)) {
      return Status.CANCEL_STATUS;
    }
    Element e=(Element)selection.getFirstElement();
    if (!"String_Node_Str".equals(e.getAttribute("String_Node_Str")))     return Status.CANCEL_STATUS;
    dlg=new ValidationRuleDialog(page.getSite().getShell(),"String_Node_Str",e.getFirstChild().getTextContent(),page,conceptName);
    dlg.setBlockOnOpen(true);
    dlg.create();
    int ret=dlg.open();
    if (ret == Window.CANCEL) {
      return Status.CANCEL_STATUS;
    }
    e.getFirstChild().setTextContent(dlg.getPattern());
    e.getFirstChild().setUserData("String_Node_Str",dlg.getName(),null);
    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 {
    schema=((XSDTreeContentProvider)page.getTreeViewer().getContentProvider()).getXsdSchema();
    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));
      }
      conceptName=xSDCom.getContainer().getElement().getAttributes().getNamedItem("String_Node_Str").getNodeValue();
      Element e=(Element)selection.getFirstElement();
      if (!"String_Node_Str".equals(e.getAttribute("String_Node_Str")))       return Status.CANCEL_STATUS;
      dlg=new ValidationRuleDialog(page.getSite().getShell(),"String_Node_Str",e.getFirstChild().getTextContent(),page,conceptName);
      dlg.setBlockOnOpen(true);
      dlg.create();
      int ret=dlg.open();
      if (ret == Window.CANCEL) {
        return Status.CANCEL_STATUS;
      }
      e.getFirstChild().setTextContent(dlg.getPattern());
      e.getFirstChild().setUserData("String_Node_Str",dlg.getName(),null);
    }
 else {
      xSDCom=(XSDComponent)selection.getFirstElement();
      XSDAnnotationsStructure struc=new XSDAnnotationsStructure(xSDCom);
      if (struc.getAnnotation() == null) {
        throw new RuntimeException("String_Node_Str" + xSDCom.getClass().getName());
      }
      if (xSDCom instanceof XSDElementDeclaration) {
        conceptName=xSDCom.getElement().getAttributes().getNamedItem("String_Node_Str").getNodeValue();
      }
      if (xSDCom instanceof XSDAnnotation || xSDCom instanceof XSDElementDeclaration) {
        InputDialog input=new InputDialog(null,"String_Node_Str","String_Node_Str","String_Node_Str",null);
        input.open();
        if (input.getReturnCode() == InputDialog.OK) {
          String pattern="String_Node_Str" + input.getValue() + "String_Node_Str";
          struc.addSchematron(pattern);
          page.refresh();
          page.getTreeViewer().expandToLevel(xSDCom,2);
          page.markDirty();
          return Status.OK_STATUS;
        }
        return Status.CANCEL_STATUS;
      }
    }
    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;
}