Program: 77982
Project: 77982
Buggy source:
public void partActivated(IWorkbenchPart 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) {
    if (getEditorInput().exists()) {
      handleActivation();
      SessionHandleAdapter.getInstance().setReportDesignHandle(getModel());
    }
    if (getActivePageInstance() instanceof GraphicalEditorWithFlyoutPalette) {
      GraphicalEditorWithFlyoutPalette editor=(GraphicalEditorWithFlyoutPalette)getActivePageInstance();
      GraphicalViewer view=editor.getGraphicalViewer();
      UIUtil.resetViewSelection(view,true);
    }
  }
}

Fixed version (ground truth):
public void partActivated(IWorkbenchPart 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) {
    if (getEditorInput().exists()) {
      handleActivation();
      SessionHandleAdapter.getInstance().setReportDesignHandle(getModel());
    }
    if (getActivePageInstance() instanceof GraphicalEditorWithFlyoutPalette && getActivePageInstance() instanceof IReportEditorPage) {
      Display.getCurrent().asyncExec(new Runnable(){
        public void run(){
          ((IReportEditorPage)getActivePageInstance()).onBroughtToTop((IReportEditorPage)getActivePageInstance());
        }
      }
);
    }
  }
}