repositoryFinder.setFindInChildren(false);
try {
Collection<RepositoryMapping> mappings;
mappings = repositoryFinder.find(new NullProgressMonitor());
Iterator<RepositoryMapping> mi = mappings.iterator();
RepositoryMapping m = mi.hasNext() ? mi.next() : null;
if (m == null) {
// no mapping found, enable repository creation
TreeItem treeItem = new TreeItem(tree, SWT.NONE);
updateProjectTreeItem(treeItem, project);
treeItem.setText(1, project.getLocation().toOSString());
treeItem.setText(2, ""); //$NON-NLS-1$
treeItem.setData(new ProjectAndRepo(project, "")); //$NON-NLS-1$
allProjectsInExistingRepos = false;
} else if (!mi.hasNext()) {
// exactly one mapping found
TreeItem treeItem = new TreeItem(tree, SWT.NONE);
updateProjectTreeItem(treeItem, project);
treeItem.setText(1, project.getLocation().toOSString());
fillTreeItemWithGitDirectory(m, treeItem, false);
treeItem.setData(new ProjectAndRepo(project, m
.getGitDirAbsolutePath().toOSString()));
treeItem.setChecked(true);
}
else {
TreeItem treeItem = new TreeItem(tree, SWT.NONE);
updateProjectTreeItem(treeItem, project);
treeItem.setText(1, project.getLocation().toOSString());
treeItem.setData(new ProjectAndRepo(project, "")); //$NON-NLS-1$
TreeItem treeItem2 = new TreeItem(treeItem, SWT.NONE);
updateProjectTreeItem(treeItem2, project);
fillTreeItemWithGitDirectory(m, treeItem2, true);
treeItem2.setData(new ProjectAndRepo(project, m
.getGitDirAbsolutePath().toOSString()));
while (mi.hasNext()) { // fill in additional mappings
m = mi.next();
treeItem2 = new TreeItem(treeItem, SWT.NONE);
updateProjectTreeItem(treeItem2, project);
fillTreeItemWithGitDirectory(m, treeItem2, true);
treeItem2.setData(new ProjectAndRepo(m.getContainer()
.getProject(), m.getGitDirAbsolutePath()
.toOSString()));
}
treeItem.setExpanded(true);
allProjectsInExistingRepos = false;
}