Bug 537416 - UI Freeze for 15 minutes when starting Eclipse IDE

 - On startup the selection is seen as the workspace root
 - When the actions are testing if they relate to this selection the
CloseUnrelatedProjectsAction creates a map of project relations to see
which projects do not relate to the selection
 - When the workspace is huge (1100 projects) this is a long process
 - Instead, knowing that the root relates to everything, no projects can
returned

Change-Id: Ied2e2cd0dab76198527289d755f127d958cb8ca0
Signed-off-by: Lucas Bullen <lbullen@redhat.com>
diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java
index 908d838..1d0e5d1 100644
--- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java
+++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java
@@ -195,11 +195,17 @@
 	 * Computes the related projects of the selection.
 	 */
 	private List<IResource> computeRelated(List<? extends IResource> selection) {
+		if (selection.contains(ResourcesPlugin.getWorkspace().getRoot())) {
+			return new ArrayList<>();
+		}
 		//build the connected component set for all projects in the workspace
 		DisjointSet<IProject> set = buildConnectedComponents(ResourcesPlugin.getWorkspace().getRoot().getProjects());
 		//remove the connected components that the selected projects are in
 		for (IResource resource : selection) {
-			set.removeSet(resource);
+			IProject project = resource.getProject();
+			if (project != null) {
+				set.removeSet(project);
+			}
 		}
 		//the remainder of the projects in the disjoint set are unrelated to the selection
 		List<IResource> projects = new ArrayList<>();