Program: 123390
Project: 123390
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) {
    covertJobscriptOnPageChange();
    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);
        }
        if (propertyListener == null) {
          propertyListener=new IPropertyListener(){
            @Override public void propertyChanged(            Object source,            int propId){
              if (getEditor(2).isDirty()) {
                getProcess().setProcessModified(true);
                getProcess().setNeedRegenerateCode(true);
              }
            }
          }
;
          getEditor(2).addPropertyListener(propertyListener);
        }
      }
 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();
    }
    changeContextsViewStatus(true);
  }
 else   if (newPageIndex == 0 && oldPageIndex == 2) {
    covertJobscriptOnPageChange();
    changeContextsViewStatus(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);
        }
        if (propertyListener == null) {
          propertyListener=new IPropertyListener(){
            @Override public void propertyChanged(            Object source,            int propId){
              if (getEditor(2).isDirty()) {
                getProcess().setProcessModified(true);
                getProcess().setNeedRegenerateCode(true);
              }
            }
          }
;
          getEditor(2).addPropertyListener(propertyListener);
        }
      }
 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);
      }
      changeContextsViewStatus(false);
    }
  }
  oldPageIndex=getActivePage();
}