final Set<ProjectRecord> projectsToCreate, final boolean open,
final IWorkingSet[] selectedWorkingSets, IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
public void run(IProgressMonitor actMonitor) throws CoreException {
IWorkingSetManager workingSetManager = PlatformUI
.getWorkbench().getWorkingSetManager();
try {
actMonitor.beginTask("", projectsToCreate.size() * 2 + 1); //$NON-NLS-1$
if (actMonitor.isCanceled())
throw new OperationCanceledException();
Map<IProject, File> projectsToConnect = new HashMap<IProject, File>();
for (ProjectRecord projectRecord : projectsToCreate) {
if (actMonitor.isCanceled())
throw new OperationCanceledException();
actMonitor.subTask(projectRecord.getProjectLabel());
IProject project = createExistingProject(projectRecord,
open, new SubProgressMonitor(actMonitor, 1));
if (project == null)
continue;
RepositoryFinder finder = new RepositoryFinder(project);
finder.setFindInChildren(false);
Collection<RepositoryMapping> mappings = finder
.find(new SubProgressMonitor(actMonitor, 1));
if (!mappings.isEmpty()) {
RepositoryMapping mapping = mappings.iterator()
.next();
projectsToConnect.put(project, mapping
.getGitDirAbsolutePath().toFile());
}
if (selectedWorkingSets != null
&& selectedWorkingSets.length > 0)
workingSetManager.addToWorkingSets(project,
selectedWorkingSets);
}
if (!projectsToConnect.isEmpty()) {
ConnectProviderOperation connect = new ConnectProviderOperation(