Bug 139700 Long delay on package explorer selection changes in large workspace
Build: Eclipse 3.2 RC2 I created a workspace with every callisto project added (600 projects). Clicking around in the Navigator, I found a long delay responding to selection changes (2-3 seconds on a dual 3 Ghz machine with 1024 MB RAM). The culprit is CloseUnrelatedProjectsAction.getSelectedResources. The algorithm it uses for computing the set of "unrelated projects" is O(N^3) on the number of projects in the worst case (the worst case being where all N projects are tightly related to each other, as in the Callisto project case). This should be fixed for 3.2, either by improving the algorithm, or not updating the set of unrelated projects when the selection changes. It currently does this in order to update the enablement of the action (disabling the action when there are no open unrelated projects).
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/CloseUnrelatedProjectsAction.java
/**
	 * The id of this action.
	 */
	public static final String ID = PlatformUI.PLUGIN_ID + ".CloseUnrelatedProjectsAction"; 
	private final List projectsToClose = new ArrayList();
	private boolean selectionDirty = true;
	private List oldSelection = Collections.EMPTY_LIST;
	/**
	 * Creates this action.
	 * 
	 * @param shell
	 *            The shell to use for parenting any dialogs created by this
	 *            action.
	 */
	public CloseUnrelatedProjectsAction(Shell shell) {
		super(shell, IDEWorkbenchMessages.CloseUnrelatedProjectsAction_text);
		setId(ID);
		setToolTipText(IDEWorkbenchMessages.CloseUnrelatedProjectsAction_toolTip);
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IIDEHelpContextIds.CLOSE_UNRELATED_PROJECTS_ACTION);
	}
	/**
	 * Adds the given project, and all related projects, to the given set.
	 * 
	 * @param relatedProjects
	 * @param project