Program: 148428
Project: 148428
Buggy source:
@Override protected void createPages(){
  super.createPages();
  addPageChangedListener(new IPageChangedListener(){
    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):
@Override protected void createPages(){
  super.createPages();
  addPageChangedListener(new IPageChangedListener(){
    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();
        }
      }
    }
  }
);
}