Program: 148429
Project: 148429
Buggy source:
public void pageChanged(PageChangedEvent event){
  if (xobject != null) {
    try {
      if (getSelectedPage() instanceof DataModelMainPage) {
        curContributionID=CONTRUIBUTIONID_DATAMODELPAGE;
        String xsd=getTextEditor().getTextViewer().getDocument().get();
        IEditorPart[] editors=findEditors(xsdInput);
        if (editors.length == 1 && editors[0] instanceof DataModelMainPage) {
          DataModelMainPage mainPage=(DataModelMainPage)editors[0];
          getEditorSite().setSelectionProvider(mainPage.getSelectionProvider());
          XSDSchema schema=Util.createXsdSchema(xsd,xobject);
          mainPage.setXsdSchema(schema);
          mainPage.getTypeContentProvider().setXsdSchema(schema);
          mainPage.getSchemaContentProvider().setXsdSchema(schema);
          mainPage.refresh();
        }
      }
 else {
        curContributionID=CONTRUIBUTIONID_XSDEDITOR;
        getEditorSite().setSelectionProvider(getSelectionManager());
        IEditorPart[] editors=findEditors(xsdInput);
        if (editors.length == 1 && editors[0] instanceof DataModelMainPage) {
          DataModelMainPage mainPage=(DataModelMainPage)editors[0];
          if (mainPage.isDirty()) {
            String xsd=mainPage.getXSDSchemaString();
            xsd=Util.formatXsdSource(xsd);
            WSDataModel wsDataModel=(WSDataModel)xobject.getWsObject();
            wsDataModel.setXsdSchema(xsd);
            IFile file=XSDEditorUtil.createFile(xobject);
            file.setContents(new ByteArrayInputStream(xsd.getBytes()),IFile.FORCE,null);
          }
        }
      }
      refreshPropertyView();
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public void pageChanged(PageChangedEvent event){
  if (xobject != null) {
    try {
      if (getSelectedPage() instanceof DataModelMainPage) {
        curContributionID=CONTRUIBUTIONID_DATAMODELPAGE;
        String xsd=getTextEditor().getTextViewer().getDocument().get();
        IEditorPart[] editors=findEditors(xsdInput);
        if (editors.length == 1 && editors[0] instanceof DataModelMainPage) {
          DataModelMainPage mainPage=(DataModelMainPage)editors[0];
          getEditorSite().setSelectionProvider(mainPage.getSelectionProvider());
          XSDSchema schema=Util.createXsdSchema(xsd,xobject);
          mainPage.setXsdSchema(schema);
          mainPage.getTypeContentProvider().setXsdSchema(schema);
          mainPage.getSchemaContentProvider().setXsdSchema(schema);
          mainPage.refresh();
        }
      }
 else {
        curContributionID=CONTRUIBUTIONID_XSDEDITOR;
        getEditorSite().setSelectionProvider(getSelectionManager());
        IEditorPart[] editors=findEditors(xsdInput);
        if (editors.length == 1 && editors[0] instanceof DataModelMainPage) {
          DataModelMainPage mainPage=(DataModelMainPage)editors[0];
          if (mainPage.isDirty()) {
            String xsd=mainPage.getXSDSchemaString();
            xsd=Util.formatXsdSource(xsd);
            WSDataModel wsDataModel=(WSDataModel)xobject.getWsObject();
            wsDataModel.setXsdSchema(xsd);
            IFile file=XSDEditorUtil.createFile(xobject);
            file.setCharset("String_Node_Str",null);
            file.setContents(new ByteArrayInputStream(xsd.getBytes("String_Node_Str")),IFile.FORCE,null);
          }
        }
      }
      refreshPropertyView();
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}