Program: 124311
Project: 124311
Buggy source:
/** 
 * Calculates the contents of page 2 when the it is activated.
 */
@Override protected void pageChange(final int newPageIndex){
  super.pageChange(newPageIndex);
  setName();
  if (newPageIndex == 1) {
    if (codeEditor instanceof ISyntaxCheckableEditor) {
      moveCursorToSelectedComponent();
    }
    codeSync();
    if (codeEditor instanceof ISyntaxCheckableEditor && LanguageManager.getCurrentLanguage() == ECodeLanguage.PERL) {
      ((ISyntaxCheckableEditor)codeEditor).validateSyntax();
    }
  }
 else   if (newPageIndex == 0 && oldPageIndex == 2) {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICreateXtextProcessService.class)) {
      try {
        boolean isDirty=getEditor(2).isDirty();
        getEditor(2).doSave(null);
        IProcess2 oldProcess=getProcess();
        ICreateXtextProcessService n=CorePlugin.getDefault().getCreateXtextProcessService();
        URI uri=URI.createFileURI(((IFile)getEditor(2).getEditorInput().getAdapter(IResource.class)).getLocation().toOSString());
        Resource resource=new ResourceSetImpl().getResource(uri,true);
        ProcessType processTypeTemp=(ProcessType)resource.getContents().get(0);
        if (processTypeTemp.getAuthor() != null) {
          ProcessType processType=n.convertDesignerEditorInput(((IFile)getEditor(2).getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(),oldProcess.getProperty());
          Item item=oldProcess.getProperty().getItem();
          if (item instanceof ProcessItem) {
            ((Process)oldProcess).updateProcess(processType);
          }
 else           if (item instanceof JobletProcessItem) {
            ((Process)oldProcess).updateProcess(processType);
          }
          oldProcess.getUpdateManager().updateAll();
          designerEditor.setDirty(isDirty);
        }
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
      IWorkbenchPage workbenchPage=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if (workbenchPage != null) {
        IViewPart view=workbenchPage.findView(ContextsView.ID);
        if (view != null) {
          ContextsView contextsView=(ContextsView)view;
          contextsView.getContextViewComposite().setTabEnable(true);
          contextsView.getContextViewComposite().getContextTemplateComposite().getViewer().getTree().setEnabled(true);
        }
      }
    }
  }
 else   if (newPageIndex == 2) {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICreateXtextProcessService.class)) {
      ICreateXtextProcessService convertJobtoScriptService=CorePlugin.getDefault().getCreateXtextProcessService();
      String scriptValue;
      try {
        scriptValue=convertJobtoScriptService.convertJobtoScript(getProcess().saveXmlFile());
        IFile file=(IFile)getEditor(2).getEditorInput().getAdapter(IResource.class);
        ByteArrayInputStream byteArrayInputStream=new ByteArrayInputStream(scriptValue.getBytes());
        if (file.exists()) {
          ((AbstractDecoratedTextEditor)getEditor(2)).getDocumentProvider().getDocument(getEditor(2).getEditorInput()).set(scriptValue);
          IProxyRepositoryFactory rFactory=ProxyRepositoryFactory.getInstance();
          if (rFactory.isUserReadOnlyOnCurrentProject()) {
            IDocumentProvider provider=((AbstractDecoratedTextEditor)getEditor(2)).getDocumentProvider();
            Class p=provider.getClass();
            Class[] type=new Class[1];
            type[0]=Boolean.TYPE;
            Object[] para=new Object[1];
            para[0]=Boolean.TRUE;
            Method method=p.getMethod("String_Node_Str",type);
            method.invoke(provider,para);
          }
          IAction action=((AbstractDecoratedTextEditor)getEditor(2)).getAction("String_Node_Str");
          action.run();
          getEditor(2).doSave(null);
        }
 else {
          file.create(byteArrayInputStream,true,null);
        }
      }
 catch (      PartInitException e) {
        ExceptionHandler.process(e);
      }
catch (      CoreException e) {
        ExceptionHandler.process(e);
      }
catch (      IOException e) {
        ExceptionHandler.process(e);
      }
catch (      SecurityException e) {
        ExceptionHandler.process(e);
      }
catch (      NoSuchMethodException e) {
        ExceptionHandler.process(e);
      }
catch (      IllegalArgumentException e) {
        ExceptionHandler.process(e);
      }
catch (      IllegalAccessException e) {
        ExceptionHandler.process(e);
      }
catch (      InvocationTargetException e) {
        ExceptionHandler.process(e);
      }
      IWorkbenchPage workbenchPage=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if (workbenchPage != null) {
        IViewPart view=workbenchPage.findView(ContextsView.ID);
        if (view != null) {
          ContextsView contextsView=(ContextsView)view;
          contextsView.getContextViewComposite().setTabEnable(false);
          contextsView.getContextViewComposite().getContextTemplateComposite().getViewer().getTree().setEnabled(false);
        }
      }
    }
  }
  oldPageIndex=getActivePage();
}

Fixed version (ground truth):
/** 
 * Calculates the contents of page 2 when the it is activated.
 */
@Override protected void pageChange(final int newPageIndex){
  super.pageChange(newPageIndex);
  setName();
  if (newPageIndex == 1) {
    if (codeEditor instanceof ISyntaxCheckableEditor) {
      moveCursorToSelectedComponent();
    }
    codeSync();
    if (codeEditor instanceof ISyntaxCheckableEditor && LanguageManager.getCurrentLanguage() == ECodeLanguage.PERL) {
      ((ISyntaxCheckableEditor)codeEditor).validateSyntax();
    }
  }
 else   if (newPageIndex == 0 && oldPageIndex == 2) {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICreateXtextProcessService.class)) {
      try {
        boolean isDirty=getEditor(2).isDirty();
        getEditor(2).doSave(null);
        IProcess2 oldProcess=getProcess();
        ICreateXtextProcessService n=CorePlugin.getDefault().getCreateXtextProcessService();
        URI uri=URI.createFileURI(((IFile)getEditor(2).getEditorInput().getAdapter(IResource.class)).getLocation().toOSString());
        Resource resource=new ResourceSetImpl().getResource(uri,true);
        ProcessType processTypeTemp=(ProcessType)resource.getContents().get(0);
        if (processTypeTemp.getAuthor() != null) {
          ProcessType processType=n.convertDesignerEditorInput(((IFile)getEditor(2).getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(),oldProcess.getProperty());
          Item item=oldProcess.getProperty().getItem();
          if (item instanceof ProcessItem) {
            ((Process)oldProcess).updateProcess(processType);
          }
 else           if (item instanceof JobletProcessItem) {
            ((Process)oldProcess).updateProcess(processType);
          }
          oldProcess.getUpdateManager().updateAll();
          designerEditor.setDirty(isDirty);
        }
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
      IWorkbenchPage workbenchPage=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if (workbenchPage != null) {
        IViewPart view=workbenchPage.findView(ContextsView.ID);
        if (view != null) {
          ContextsView contextsView=(ContextsView)view;
          contextsView.getContextViewComposite().setTabEnable(true);
          contextsView.getContextViewComposite().getContextTemplateComposite().getViewer().getTree().setEnabled(true);
        }
      }
    }
  }
 else   if (newPageIndex == 2) {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICreateXtextProcessService.class)) {
      ICreateXtextProcessService convertJobtoScriptService=CorePlugin.getDefault().getCreateXtextProcessService();
      String scriptValue;
      try {
        scriptValue=convertJobtoScriptService.convertJobtoScript(getProcess().saveXmlFile());
        IFile file=(IFile)getEditor(2).getEditorInput().getAdapter(IResource.class);
        ByteArrayInputStream byteArrayInputStream=new ByteArrayInputStream(scriptValue.getBytes());
        if (file.exists()) {
          ((AbstractDecoratedTextEditor)getEditor(2)).getDocumentProvider().getDocument(getEditor(2).getEditorInput()).set(scriptValue);
          boolean isReadjob=((JobEditorInput)getEditor(0).getEditorInput()).isReadOnly();
          IProxyRepositoryFactory rFactory=ProxyRepositoryFactory.getInstance();
          if (isReadjob || rFactory.isUserReadOnlyOnCurrentProject()) {
            IDocumentProvider provider=((AbstractDecoratedTextEditor)getEditor(2)).getDocumentProvider();
            Class p=provider.getClass();
            Class[] type=new Class[1];
            type[0]=Boolean.TYPE;
            Object[] para=new Object[1];
            para[0]=Boolean.TRUE;
            Method method=p.getMethod("String_Node_Str",type);
            method.invoke(provider,para);
          }
          IAction action=((AbstractDecoratedTextEditor)getEditor(2)).getAction("String_Node_Str");
          action.run();
          getEditor(2).doSave(null);
        }
 else {
          file.create(byteArrayInputStream,true,null);
        }
      }
 catch (      PartInitException e) {
        ExceptionHandler.process(e);
      }
catch (      CoreException e) {
        ExceptionHandler.process(e);
      }
catch (      IOException e) {
        ExceptionHandler.process(e);
      }
catch (      SecurityException e) {
        ExceptionHandler.process(e);
      }
catch (      NoSuchMethodException e) {
        ExceptionHandler.process(e);
      }
catch (      IllegalArgumentException e) {
        ExceptionHandler.process(e);
      }
catch (      IllegalAccessException e) {
        ExceptionHandler.process(e);
      }
catch (      InvocationTargetException e) {
        ExceptionHandler.process(e);
      }
      IWorkbenchPage workbenchPage=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if (workbenchPage != null) {
        IViewPart view=workbenchPage.findView(ContextsView.ID);
        if (view != null) {
          ContextsView contextsView=(ContextsView)view;
          contextsView.getContextViewComposite().setTabEnable(false);
          contextsView.getContextViewComposite().getContextTemplateComposite().getViewer().getTree().setEnabled(false);
        }
      }
    }
  }
  oldPageIndex=getActivePage();
}