Program: 68433
Project: 68433
Buggy source:
public void partActivated(IWorkbenchPart part){
  fActivePart=part;
  if (part != this) {
    if (part instanceof PageBookView) {
      PageBookView view=(PageBookView)part;
      if (view.getCurrentPage() instanceof DesignerOutlinePage) {
        ISelectionProvider provider=(ISelectionProvider)view.getCurrentPage();
        ReportRequest request=new ReportRequest(view.getCurrentPage());
        List list=new ArrayList();
        if (provider.getSelection() instanceof IStructuredSelection) {
          list=((IStructuredSelection)provider.getSelection()).toList();
        }
        request.setSelectionObject(list);
        request.setType(ReportRequest.SELECTION);
        SessionHandleAdapter.getInstance().getMediator().notifyRequest(request);
        SessionHandleAdapter.getInstance().getMediator().pushState();
      }
    }
    if (getActivePageInstance() instanceof GraphicalEditorWithFlyoutPalette) {
      if (((GraphicalEditorWithFlyoutPalette)getActivePageInstance()).getGraphicalViewer().getEditDomain().getPaletteViewer() != null) {
        GraphicalEditorWithFlyoutPalette editor=(GraphicalEditorWithFlyoutPalette)getActivePageInstance();
        GraphicalViewer view=editor.getGraphicalViewer();
        view.getEditDomain().loadDefaultTool();
      }
    }
    return;
  }
  if (part == this) {
    confirmSave();
    final ModuleHandle oldHandle=getModel();
    if (needReset) {
      if (MessageDialog.openConfirm(UIUtil.getDefaultShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
        getProvider().getReportModuleHandle(getEditorInput(),true);
      }
 else {
        needReset=false;
      }
      needReload=false;
    }
    if (needReload) {
      if (MessageDialog.openConfirm(UIUtil.getDefaultShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
        UIUtil.reloadModuleHandleLibraries(getModel());
      }
 else {
        needReload=false;
      }
    }
    if (getEditorInput().exists()) {
      handleActivation();
      ModuleHandle currentModel=getModel();
      SessionHandleAdapter.getInstance().setReportDesignHandle(currentModel);
      String str=SessionHandleAdapter.getInstance().getSessionHandle().getResourceFolder();
      UIUtil.processSessionResourceFolder(getEditorInput(),UIUtil.getProjectFromInput(getEditorInput()),currentModel);
      if (!str.equals(SessionHandleAdapter.getInstance().getSessionHandle().getResourceFolder()) && getActivePageInstance() instanceof GraphicalEditorWithFlyoutPalette) {
        ((GraphicalEditorWithFlyoutPalette)getActivePageInstance()).getGraphicalViewer().getRootEditPart();
        refreshGraphicalEditor();
      }
    }
    if (getActivePageInstance() instanceof IReportEditorPage) {
      boolean isDispatch=false;
      if (getActivePageInstance() instanceof GraphicalEditorWithFlyoutPalette) {
        isDispatch=true;
      }
 else       if (needReload || needReset) {
        isDispatch=true;
      }
      final boolean tempDispatch=isDispatch;
      Display.getCurrent().asyncExec(new Runnable(){
        public void run(){
          IReportEditorPage curPage=(IReportEditorPage)getActivePageInstance();
          if (needReload || needReset) {
            curPage.markPageStale(IPageStaleType.MODEL_RELOAD);
          }
          if (getActivePageInstance() != null) {
            curPage.onBroughtToTop((IReportEditorPage)getActivePageInstance());
          }
          if (!tempDispatch) {
            return;
          }
          if (needReload || needReset) {
            updateRelatedViews();
            curPage.markPageStale(IPageStaleType.NONE);
          }
          if (needReset) {
            SessionHandleAdapter.getInstance().resetReportDesign(oldHandle,getModel());
            oldHandle.close();
          }
          needReload=false;
          needReset=false;
        }
      }
);
    }
  }
}

Fixed version (ground truth):
public void partActivated(IWorkbenchPart part){
  fActivePart=part;
  if (part != this) {
    if (part instanceof PageBookView) {
      PageBookView view=(PageBookView)part;
      if (view.getCurrentPage() instanceof DesignerOutlinePage) {
        ISelectionProvider provider=(ISelectionProvider)view.getCurrentPage();
        ReportRequest request=new ReportRequest(view.getCurrentPage());
        List list=new ArrayList();
        if (provider.getSelection() instanceof IStructuredSelection) {
          list=((IStructuredSelection)provider.getSelection()).toList();
        }
        request.setSelectionObject(list);
        request.setType(ReportRequest.SELECTION);
        SessionHandleAdapter.getInstance().getMediator().notifyRequest(request);
        SessionHandleAdapter.getInstance().getMediator().pushState();
      }
    }
    if (getActivePageInstance() instanceof GraphicalEditorWithFlyoutPalette) {
      if (((GraphicalEditorWithFlyoutPalette)getActivePageInstance()).getGraphicalViewer().getEditDomain().getPaletteViewer() != null) {
        GraphicalEditorWithFlyoutPalette editor=(GraphicalEditorWithFlyoutPalette)getActivePageInstance();
        GraphicalViewer view=editor.getGraphicalViewer();
        view.getEditDomain().loadDefaultTool();
      }
    }
    return;
  }
  if (part == this) {
    confirmSave();
    final ModuleHandle oldHandle=getModel();
    if (needReset) {
      if (MessageDialog.openConfirm(UIUtil.getDefaultShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
        getProvider().getReportModuleHandle(getEditorInput(),true);
      }
 else {
        needReset=false;
      }
      needReload=false;
    }
    if (needReload) {
      if (MessageDialog.openConfirm(UIUtil.getDefaultShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
        UIUtil.reloadModuleHandleLibraries(getModel());
      }
 else {
        needReload=false;
      }
    }
    if (getEditorInput().exists()) {
      handleActivation();
      ModuleHandle currentModel=getModel();
      SessionHandleAdapter.getInstance().setReportDesignHandle(currentModel);
      String str=SessionHandleAdapter.getInstance().getSessionHandle().getResourceFolder();
      UIUtil.processSessionResourceFolder(getEditorInput(),UIUtil.getProjectFromInput(getEditorInput()),currentModel);
      if (!str.equals(SessionHandleAdapter.getInstance().getSessionHandle().getResourceFolder()) && getActivePageInstance() instanceof GraphicalEditorWithFlyoutPalette) {
        ((GraphicalEditorWithFlyoutPalette)getActivePageInstance()).getGraphicalViewer().getRootEditPart();
        refreshGraphicalEditor();
      }
    }
    if (getActivePageInstance() instanceof IReportEditorPage) {
      boolean isDispatch=false;
      if (getActivePageInstance() instanceof GraphicalEditorWithFlyoutPalette) {
        isDispatch=true;
      }
 else       if (needReload || needReset) {
        isDispatch=true;
      }
      final boolean tempDispatch=isDispatch;
      Display.getCurrent().asyncExec(new Runnable(){
        public void run(){
          IReportEditorPage curPage=(IReportEditorPage)getActivePageInstance();
          if (needReload || needReset) {
            curPage.markPageStale(IPageStaleType.MODEL_RELOAD);
          }
          if (getActivePageInstance() != null) {
            if (curPage instanceof IAdvanceReportEditorPage) {
              if (((IAdvanceReportEditorPage)curPage).isSensitivePartChange()) {
                curPage.onBroughtToTop((IReportEditorPage)getActivePageInstance());
              }
            }
 else {
              curPage.onBroughtToTop((IReportEditorPage)getActivePageInstance());
            }
          }
          if (!tempDispatch) {
            return;
          }
          if (needReload || needReset) {
            updateRelatedViews();
            curPage.markPageStale(IPageStaleType.NONE);
          }
          if (needReset) {
            SessionHandleAdapter.getInstance().resetReportDesign(oldHandle,getModel());
            oldHandle.close();
          }
          needReload=false;
          needReset=false;
        }
      }
);
    }
  }
}