Program: 125794
Project: 125794
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();
      return true;
    }
    @Override public void postShutdown(    IWorkbench workbench){
      ProxyRepositoryFactory.getInstance().logOffProject();
    }
  }
);
}

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(ITDQItemService.class)) {
          ITDQItemService tdqItemService=(ITDQItemService)GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
          if (tdqItemService != null) {
            tdqItemService.createDQStructor();
          }
        }
        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();
    }
  }
);
}