Program: 65298
Project: 65298
Buggy source:
public void partActivated(IWorkbenchPart part){
  if (lastActivtedPart == part) {
    return;
  }
  lastActivtedPart=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 (resolveList != null && resetList(resolveList)) {
        getProvider().getReportModuleHandle(getEditorInput(),true);
      }
 else {
        needReset=false;
      }
      needReload=false;
    }
    if (needReload) {
      if (!waitReload) {
        waitReload=true;
        if (resolveList != null && reloadList(resolveList)) {
        }
 else {
          needReload=false;
        }
        waitReload=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();
            UIUtil.refreshCurrentEditorMarkers();
            curPage.markPageStale(IPageStaleType.NONE);
          }
          if (needReset) {
            SessionHandleAdapter.getInstance().resetReportDesign(oldHandle,getModel());
            oldHandle.close();
          }
          needReload=false;
          needReset=false;
          resolveList.clear();
        }
      }
);
    }
  }
}

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 (resolveList != null && resetList(resolveList)) {
        getProvider().getReportModuleHandle(getEditorInput(),true);
      }
 else {
        needReset=false;
      }
      needReload=false;
    }
    if (needReload) {
      if (resolveList != null && reloadList(resolveList)) {
      }
 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();
            UIUtil.refreshCurrentEditorMarkers();
            curPage.markPageStale(IPageStaleType.NONE);
          }
          if (needReset) {
            SessionHandleAdapter.getInstance().resetReportDesign(oldHandle,getModel());
            oldHandle.close();
          }
          needReload=false;
          needReset=false;
          resolveList.clear();
        }
      }
);
    }
  }
}