Program: 71812
Project: 71812
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) {
    confirmSava();
    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();
      SessionHandleAdapter.getInstance().setReportDesignHandle(getModel());
    }
    if (getActivePageInstance() instanceof IReportEditorPage) {
      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 (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) {
    confirmSava();
    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();
      SessionHandleAdapter.getInstance().setReportDesignHandle(getModel());
    }
    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(){
          if (!tempDispatch) {
            return;
          }
          IReportEditorPage curPage=(IReportEditorPage)getActivePageInstance();
          if (needReload || needReset) {
            curPage.markPageStale(IPageStaleType.MODEL_RELOAD);
          }
          if (getActivePageInstance() != null) {
            curPage.onBroughtToTop((IReportEditorPage)getActivePageInstance());
          }
          if (needReload || needReset) {
            updateRelatedViews();
            curPage.markPageStale(IPageStaleType.NONE);
          }
          if (needReset) {
            SessionHandleAdapter.getInstance().resetReportDesign(oldHandle,getModel());
            oldHandle.close();
          }
          needReload=false;
          needReset=false;
        }
      }
);
    }
  }
}