Bug 66947 'Add to build path' action available on CUs [build path]
RC2 1. Select a CU in the package explorer 2. Invoke 'Add to build path' Error dialog shows up, message printed to log Doesn't seem to make sense to add a CU to the build path... !ENTRY org.eclipse.jdt.ui 4 10001 Jun 14, 2004 16:22:21.355 !MESSAGE Internal Error !STACK 1 Java Model Exception: Java Model Status [Cannot nest 'org.eclipse.ui.examples.multipageeditor/Eclipse UI Examples MultiPageEditor/org/eclipse/ui/examples/multipageeditor/MessageUtil.java' inside 'org.eclipse.ui.examples.multipageeditor/Eclipse UI Examples MultiPageEditor'. To enable the nesting exclude 'org/' from 'org.eclipse.ui.examples.multipageeditor/Eclipse UI Examples MultiPageEditor'] at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:735) at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2650) at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:2666) at org.eclipse.jdt.ui.actions.AddToClasspathAction$1.addToClassPath(AddToClasspathAction.java:134) at org.eclipse.jdt.ui.actions.AddToClasspathAction$1.run(AddToClasspathAction.java:123) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1673) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3246) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:65) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddToClasspathAction.java
try {
			setEnabled(checkEnabled(selection));
		} catch (JavaModelException e) {
			
			if (JavaModelUtil.filterNotPresentException(e))
				JavaPlugin.log(e);
			setEnabled(false);
		}
	}
	
	private static boolean checkEnabled(IStructuredSelection selection) throws JavaModelException {
		if (selection.isEmpty())
			return false;
		for (Iterator iter= selection.iterator(); iter.hasNext();) {
			if (! canBeAddedToBuildPath(iter.next()))
				return false;
		}
		return true;
	}
	private static boolean canBeAddedToBuildPath(Object element) throws JavaModelException{
		return (element instanceof IAdaptable) && getCandidate((IAdaptable) element) != null;
	}
	private static IFile getCandidate(IAdaptable element) throws JavaModelException {
		IResource resource= (IResource)element.getAdapter(IResource.class);
		if (! (resource instanceof IFile))
			return null;
		
		IJavaProject project= JavaCore.create(resource.getProject());
		if (project != null && project.exists() && (project.findPackageFragmentRoot(resource.getFullPath()) == null))
			return (IFile) resource;