/* (non-Javadoc)
   * @see org.eclipse.egit.core.op.IEGitOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
   */
  public void execute(IProgressMonitor m) throws CoreException {
    if (m == null) {
      m = new NullProgressMonitor();
    }

    m.beginTask(CoreText.ConnectProviderOperation_connecting, 100 * projects.size());
    try {

      for (Iterator iterator = projects.keySet().iterator(); iterator.hasNext(); ) {
        IProject project = (IProject) iterator.next();
        m.setTaskName(
            NLS.bind(CoreText.ConnectProviderOperation_ConnectingProject, project.getName()));
        // TODO is this the right location?
        if (GitTraceLocation.CORE.isActive())
          GitTraceLocation.getTrace()
              .trace(
                  GitTraceLocation.CORE.getLocation(),
                  "Locating repository for " + project); // $NON-NLS-1$

        Collection<RepositoryMapping> repos =
            new RepositoryFinder(project).find(new SubProgressMonitor(m, 40));
        File suggestedRepo = projects.get(project);
        RepositoryMapping actualMapping = findActualRepository(repos, suggestedRepo);
        if (actualMapping != null) {
          GitProjectData projectData = new GitProjectData(project);
          try {
            projectData.setRepositoryMappings(Arrays.asList(actualMapping));
            projectData.store();
          } catch (CoreException ce) {
            GitProjectData.delete(project);
            throw ce;
          } catch (RuntimeException ce) {
            GitProjectData.delete(project);
            throw ce;
          }
          RepositoryProvider.map(project, GitProvider.class.getName());
          projectData = GitProjectData.get(project);
          project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(m, 50));
          m.worked(10);
        } else {
          // TODO is this the right location?
          if (GitTraceLocation.CORE.isActive())
            GitTraceLocation.getTrace()
                .trace(
                    GitTraceLocation.CORE.getLocation(),
                    "Attempted to share project without repository ignored :" //$NON-NLS-1$
                        + project);
          m.worked(60);
        }
      }
    } finally {
      m.done();
    }
  }
 private void unmarkTeamPrivate(final IContainer p) throws CoreException {
   final IResource[] c;
   c = p.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
   if (c != null) {
     for (int k = 0; k < c.length; k++) {
       if (c[k] instanceof IContainer) {
         unmarkTeamPrivate((IContainer) c[k]);
       }
       if (c[k].isTeamPrivateMember()) {
         // TODO is this the right location?
         if (GitTraceLocation.CORE.isActive())
           GitTraceLocation.getTrace()
               .trace(
                   GitTraceLocation.CORE.getLocation(), "notTeamPrivate " + c[k]); // $NON-NLS-1$
         c[k].setTeamPrivateMember(false);
       }
     }
   }
 }
  /* (non-Javadoc)
   * @see org.eclipse.egit.core.op.IEGitOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
   */
  public void execute(IProgressMonitor m) throws CoreException {
    IProgressMonitor monitor;
    if (m == null) monitor = new NullProgressMonitor();
    else monitor = m;

    monitor.beginTask(CoreText.DisconnectProviderOperation_disconnecting, projectList.size() * 200);
    try {
      for (IProject p : projectList) {
        // TODO is this the right location?
        if (GitTraceLocation.CORE.isActive())
          GitTraceLocation.getTrace()
              .trace(
                  GitTraceLocation.CORE.getLocation(), "disconnect " + p.getName()); // $NON-NLS-1$
        unmarkTeamPrivate(p);
        RepositoryProvider.unmap(p);
        monitor.worked(100);

        p.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 100));
      }
    } finally {
      monitor.done();
    }
  }
Example #4
0
 static void trace(final String m) {
   // TODO is this the right location?
   if (GitTraceLocation.CORE.isActive())
     GitTraceLocation.getTrace()
         .trace(GitTraceLocation.CORE.getLocation(), "(GitProjectData) " + m); // $NON-NLS-1$
 }