public TFSRepository connectIfNecessary(final IProject project){
  Check.notNull(project,"project");
  waitForManagerStartup();
  ProjectRepositoryData projectData;
synchronized (projectDataLock) {
    projectData=projectDataMap.get(project);
    if (projectData == null) {
      Boolean shouldConnect=shouldConnect(project);
      if (shouldConnect == null) {
        return null;
      }
      projectData=new ProjectRepositoryData();
      projectDataMap.put(project,projectData);
      projectClosedSet.remove(project);
      if (shouldConnect.equals(Boolean.FALSE) && isAnyProjectOfStatus(ProjectRepositoryStatus.ONLINE)) {
        shouldConnect=Boolean.TRUE;
      }
 else       if (shouldConnect.equals(Boolean.TRUE) && isAnyProjectOfStatus(ProjectRepositoryStatus.OFFLINE)) {
        shouldConnect=Boolean.FALSE;
      }
      if (shouldConnect == Boolean.FALSE) {
        projectData.setStatus(ProjectRepositoryStatus.OFFLINE);
        return null;
      }
      projectData.setStatus(ProjectRepositoryStatus.CONNECTING);
    }
 else {
synchronized (projectData) {
        if (projectData.getStatus() == ProjectRepositoryStatus.INITIALIZING) {
          return null;
        }
 else         if (projectData.getStatus() != ProjectRepositoryStatus.CONNECTING) {
          return projectData.getRepository();
        }
      }
    }
  }
  return connectInternal(project,true,projectData);
}

public TFSRepository connectIfNecessary ( final IProject project ) { Check . notNull ( project , "project" ) ; waitForManagerStartup ( ) ; ProjectRepositoryData projectData ; synchronized ( projectDataLock ) { projectData = projectDataMap . get ( project ) ; if ( projectData == null ) { Boolean shouldConnect = shouldConnect ( project ) ; if ( shouldConnect == null ) { return null ; } projectData = new ProjectRepositoryData ( ) ; projectDataMap . put ( project , projectData ) ; projectClosedSet . remove ( project ) ; if ( shouldConnect . equals ( Boolean . FALSE ) && isAnyProjectOfStatus ( ProjectRepositoryStatus . ONLINE ) ) { shouldConnect = Boolean . TRUE ; } else if ( shouldConnect . equals ( Boolean . TRUE ) && isAnyProjectOfStatus ( ProjectRepositoryStatus . OFFLINE ) ) { shouldConnect = Boolean . FALSE ; } if ( shouldConnect == Boolean . FALSE ) { projectData . setStatus ( ProjectRepositoryStatus . OFFLINE ) ; return null ; } projectData . setStatus ( ProjectRepositoryStatus . CONNECTING ) ; } else { synchronized ( projectData ) { if ( projectData . getStatus ( ) == ProjectRepositoryStatus . INITIALIZING ) { return null ; } else if ( projectData . getStatus ( ) != ProjectRepositoryStatus . CONNECTING ) { return projectData . getRepository ( ) ; } } } } return connectInternal ( project , true , projectData ) ; }
connects the given iproject to its team foundation server if and only if it is not marked offline . this method will not reconnect offline projects . this manager need not have any previous knowledge of this project . this is most useful when a project was closed and is now opened .
