Program: 125843
Project: 125843
Buggy source:
private void regisitPerspectiveListener(){
  PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveAdapter(){
    @Override public void perspectiveActivated(    IWorkbenchPage page,    IPerspectiveDescriptor perspective){
      String pId=perspective.getId();
      if (IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(pId)) {
        IRepositoryView view=RepositoryManager.getRepositoryView();
        if (view != null) {
          view.refresh();
          TalendPaletteHelper.checkAndInitToolBar();
        }
      }
 else       if (IBrandingConfiguration.PERSPECTIVE_DQ_ID.equals(pId)) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
          ITDQRepositoryService tdqRepositoryService=(ITDQRepositoryService)GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
          if (tdqRepositoryService != null) {
            tdqRepositoryService.refresh();
          }
        }
      }
    }
    @Override public void perspectiveDeactivated(    IWorkbenchPage page,    IPerspectiveDescriptor perspective){
      String pId=perspective.getId();
      if (IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(pId)) {
        IComponentSettingsView viewer=(IComponentSettingsView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IComponentSettingsView.ID);
        if (viewer != null) {
          viewer.cleanDisplay();
        }
      }
    }
  }
);
  PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new CheatSheetPerspectiveAdapter());
  PlatformUI.getWorkbench().addWorkbenchListener(new IWorkbenchListener(){
    @Override public boolean preShutdown(    IWorkbench workbench,    boolean forced){
      TokenCollectorFactory.getFactory().process();
      ProxyRepositoryFactory.getInstance().logOffProject();
      return true;
    }
    @Override public void postShutdown(    IWorkbench workbench){
    }
  }
);
}

Fixed version (ground truth):
private void regisitPerspectiveListener(){
  PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveAdapter(){
    @Override public void perspectiveActivated(    IWorkbenchPage page,    IPerspectiveDescriptor perspective){
      String pId=perspective.getId();
      if (IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(pId)) {
        IRepositoryView view=RepositoryManager.getRepositoryView();
        if (view != null) {
          view.refresh();
          TalendPaletteHelper.checkAndInitToolBar();
        }
      }
 else       if (IBrandingConfiguration.PERSPECTIVE_DQ_ID.equals(pId)) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
          ITDQRepositoryService tdqRepositoryService=(ITDQRepositoryService)GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
          if (tdqRepositoryService != null) {
            tdqRepositoryService.refresh();
          }
        }
      }
    }
    @Override public void perspectiveDeactivated(    IWorkbenchPage page,    IPerspectiveDescriptor perspective){
      String pId=perspective.getId();
      if (IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(pId)) {
        IComponentSettingsView viewer=(IComponentSettingsView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IComponentSettingsView.ID);
        if (viewer != null) {
          viewer.cleanDisplay();
        }
      }
    }
  }
);
  PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new CheatSheetPerspectiveAdapter());
  PlatformUI.getWorkbench().addWorkbenchListener(new IWorkbenchListener(){
    @Override public boolean preShutdown(    IWorkbench workbench,    boolean forced){
      TokenCollectorFactory.getFactory().process();
      return true;
    }
    @Override public void postShutdown(    IWorkbench workbench){
      ProxyRepositoryFactory.getInstance().logOffProject();
    }
  }
);
}