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
return null;
	}
			
	/* (non-Javadoc)
	 * Method declared in SelectionDispatchAction
	 */
	public void run(IStructuredSelection selection) {
		try {
			final IFile[] files= getJARFiles(selection);	
			
			IWorkspaceRunnable operation= new IWorkspaceRunnable() {
				public void run(IProgressMonitor monitor) throws CoreException {
					monitor.beginTask(ActionMessages.getString("AddToClasspathAction.progressMessage"), files.length); 
					for (int i= 0; i < files.length; i++) {
						monitor.subTask(files[i].getFullPath().toString());
						IJavaProject project= JavaCore.create(files[i].getProject());
						addToClassPath(project, files[i].getFullPath(), new SubProgressMonitor(monitor, 1));
					}
				}
				
				private void addToClassPath(IJavaProject project, IPath jarPath, IProgressMonitor monitor) throws JavaModelException {
					if (monitor.isCanceled())
						throw new OperationCanceledException();
					IClasspathEntry[] entries= project.getRawClasspath();
					IClasspathEntry[] newEntries= new IClasspathEntry[entries.length + 1];
					System.arraycopy(entries, 0, newEntries, 0, entries.length);
					newEntries[entries.length]= JavaCore.newLibraryEntry(jarPath, null, null, false);
					project.setRawClasspath(newEntries, monitor);
				}
			};