### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.jeview Index: src/org/eclipse/jdt/jeview/views/JEClasspathEntry.java =================================================================== RCS file: /cvsroot/eclipse/jdt-ui-home/plugins/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/views/JEClasspathEntry.java,v retrieving revision 1.1 diff -u -r1.1 JEClasspathEntry.java --- src/org/eclipse/jdt/jeview/views/JEClasspathEntry.java 2 Oct 2009 10:05:40 -0000 1.1 +++ src/org/eclipse/jdt/jeview/views/JEClasspathEntry.java 26 Feb 2010 19:31:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ import org.eclipse.jdt.core.IAccessRule; import org.eclipse.jdt.core.IClasspathAttribute; import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; @@ -124,6 +125,25 @@ return children; } }); + result.add(create(this, "REFERENCING ENTRY", fEntry.getReferencingEntry())); + result.add(new JavaElementChildrenProperty(this, "JavaCore.getReferencedClasspathEntries(this)") { + @Override protected JEAttribute[] computeChildren() throws CoreException { + IJavaProject project= null; + JEAttribute parent= JEClasspathEntry.this; + while ((parent= parent.getParent()) != null) { + if (parent instanceof JavaElement) { + project= ((JavaElement) parent).getJavaElement().getJavaProject(); + break; + } + } + IClasspathEntry[] referencedEntries= JavaCore.getReferencedClasspathEntries(fEntry, project); + JEAttribute[] children= new JEAttribute[referencedEntries.length]; + for (int i= 0; i < referencedEntries.length; i++) { + children[i]= new JEClasspathEntry(this, null, referencedEntries[i]); + } + return children; + } + }); result.add(new JEClasspathEntry(this, "JavaCore.getResolvedClasspathEntry(this)", JavaCore.getResolvedClasspathEntry(fEntry))); return result.toArray(new JEAttribute[result.size()]); Index: src/org/eclipse/jdt/jeview/views/JavaElement.java =================================================================== RCS file: /cvsroot/eclipse/jdt-ui-home/plugins/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/views/JavaElement.java,v retrieving revision 1.15 diff -u -r1.15 JavaElement.java --- src/org/eclipse/jdt/jeview/views/JavaElement.java 24 Feb 2010 14:04:30 -0000 1.15 +++ src/org/eclipse/jdt/jeview/views/JavaElement.java 26 Feb 2010 19:31:19 -0000 @@ -274,6 +274,12 @@ return createCPEntries(this, project.getRawClasspath()); } }); + result.add(new JavaElementChildrenProperty(this, "REFERENCED CLASSPATH ENTRIES") { + @Override + protected JEAttribute[] computeChildren() throws JavaModelException { + return createCPEntries(this, project.getReferencedClasspathEntries()); + } + }); result.add(new JavaElementChildrenProperty(this, "RESOLVED CLASSPATH") { @Override protected JEAttribute[] computeChildren() throws JavaModelException { @@ -294,6 +300,11 @@ return packageFragmentRoot.getRawClasspathEntry(); } })); + result.add(JEClasspathEntry.compute(this, "RESOLVED CLASSPATH ENTRY", new Callable() { + public IClasspathEntry call() throws JavaModelException { + return packageFragmentRoot.getResolvedClasspathEntry(); + } + })); } private void addPackageFragmentChildren(ArrayList result, final IPackageFragment packageFragment) { #P org.eclipse.jdt.ui Index: ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocLinkRef.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocLinkRef.java,v retrieving revision 1.8 diff -u -r1.8 JavadocLinkRef.java --- ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocLinkRef.java 31 Dec 2008 21:13:25 -0000 1.8 +++ ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocLinkRef.java 26 Feb 2010 19:31:20 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -65,7 +65,7 @@ String location= url != null ? url.toExternalForm() : null; element.setAttribute(CPListElement.JAVADOC, location); String[] changedAttributes= { CPListElement.JAVADOC }; - BuildPathSupport.modifyClasspathEntry(null, element.getClasspathEntry(), changedAttributes, fProject, fContainerPath, monitor); + BuildPathSupport.modifyClasspathEntry(null, element.getClasspathEntry(), changedAttributes, fProject, fContainerPath, fClasspathEntry.getReferencingEntry() != null, monitor); fClasspathEntry= element.getClasspathEntry(); } } Index: ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java,v retrieving revision 1.110 diff -u -r1.110 ClassFileEditor.java --- ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java 5 Aug 2009 10:20:36 -0000 1.110 +++ ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java 26 Feb 2010 19:31:20 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -216,6 +216,8 @@ IClasspathEntry entry; try { entry= root.getRawClasspathEntry(); + if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) + entry= root.getResolvedClasspathEntry(); } catch (JavaModelException ex) { if (ex.isDoesNotExist()) entry= null; @@ -282,7 +284,7 @@ try { IClasspathEntry result= BuildPathDialogAccess.configureSourceAttachment(shell, entry); if (result != null) { - applySourceAttachment(shell, result, jproject, containerPath); + applySourceAttachment(shell, result, jproject, containerPath, entry.getReferencingEntry() != null); verifyInput(getEditorInput()); } } catch (CoreException e) { @@ -296,9 +298,9 @@ }; } - protected void applySourceAttachment(Shell shell, IClasspathEntry newEntry, IJavaProject project, IPath containerPath) { + protected void applySourceAttachment(Shell shell, IClasspathEntry newEntry, IJavaProject project, IPath containerPath, boolean isReferencedEntry) { try { - IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(shell, newEntry, project, containerPath); + IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(shell, newEntry, project, containerPath, isReferencedEntry); PlatformUI.getWorkbench().getProgressService().run(true, true, runnable); } catch (InvocationTargetException e) { Index: ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java,v retrieving revision 1.36 diff -u -r1.36 JavadocConfigurationPropertyPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java 11 Aug 2009 10:40:59 -0000 1.36 +++ ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java 26 Feb 2010 19:31:20 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -241,7 +241,7 @@ cpElem.setAttribute(CPListElement.JAVADOC, loc); IClasspathEntry newEntry= cpElem.getClasspathEntry(); String[] changedAttributes= { CPListElement.JAVADOC }; - BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, monitor); + BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, entry.getReferencingEntry() != null, monitor); } else { JavaUI.setProjectJavadocLocation(project, javadocLocation); } Index: ui/org/eclipse/jdt/internal/ui/preferences/NativeLibrariesPropertyPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NativeLibrariesPropertyPage.java,v retrieving revision 1.9 diff -u -r1.9 NativeLibrariesPropertyPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/NativeLibrariesPropertyPage.java 11 Sep 2008 11:59:32 -0000 1.9 +++ ui/org/eclipse/jdt/internal/ui/preferences/NativeLibrariesPropertyPage.java 26 Feb 2010 19:31:20 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -178,7 +178,7 @@ IJavaElement elem= getJavaElement(); try { - IRunnableWithProgress runnable= getRunnable(getShell(), elem, nativeLibraryPath, fEntry, fContainerPath); + IRunnableWithProgress runnable= getRunnable(getShell(), elem, nativeLibraryPath, fEntry, fContainerPath, fEntry.getReferencingEntry() != null); PlatformUI.getWorkbench().getProgressService().run(true, true, runnable); } catch (InvocationTargetException e) { String title= PreferencesMessages.NativeLibrariesPropertyPage_errorAttaching_title; @@ -193,7 +193,7 @@ return true; } - private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final String nativeLibraryPath, final IClasspathEntry entry, final IPath containerPath) { + private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final String nativeLibraryPath, final IClasspathEntry entry, final IPath containerPath, final boolean isReferencedEntry) { return new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { @@ -203,7 +203,7 @@ cpElem.setAttribute(CPListElement.NATIVE_LIB_PATH, nativeLibraryPath); IClasspathEntry newEntry= cpElem.getClasspathEntry(); String[] changedAttributes= { CPListElement.NATIVE_LIB_PATH }; - BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, monitor); + BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, isReferencedEntry, monitor); } } catch (CoreException e) { throw new InvocationTargetException(e); Index: ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java,v retrieving revision 1.43 diff -u -r1.43 SourceAttachmentPropertyPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java 11 Sep 2008 11:59:32 -0000 1.43 +++ ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java 26 Feb 2010 19:31:20 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -101,7 +101,8 @@ // use a dummy entry to use for initialization entry= JavaCore.newLibraryEntry(fRoot.getPath(), null, null); } else { - if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { + int kind= entry.getEntryKind(); + if (kind == IClasspathEntry.CPE_CONTAINER) { containerPath= entry.getPath(); ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); @@ -119,6 +120,8 @@ } entry= JavaModelUtil.findEntryInContainer(container, fRoot.getPath()); Assert.isNotNull(entry); + } else if (kind == IClasspathEntry.CPE_LIBRARY) { + entry= fRoot.getResolvedClasspathEntry(); } } fContainerPath= containerPath; @@ -161,7 +164,7 @@ return true; // no change } - IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(getShell(), entry, fRoot.getJavaProject(), fContainerPath); + IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(getShell(), entry, fRoot.getJavaProject(), fContainerPath, fEntry.getReferencingEntry() != null); PlatformUI.getWorkbench().getProgressService().run(true, true, runnable); } catch (InvocationTargetException e) { String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title; Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java,v retrieving revision 1.24 diff -u -r1.24 BuildPathSupport.java --- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java 14 Feb 2009 07:57:06 -0000 1.24 +++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java 26 Feb 2010 19:31:20 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -192,31 +192,20 @@ * @param changedAttributes The attributes that have changed. See {@link CPListElement} for constants values. * @param jproject Project where the entry belongs to * @param containerPath The path of the entry's parent container or null if the entry is not in a container + * @param isReferencedEntry * @param monitor The progress monitor to use * @throws CoreException if the update failed */ - public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, String[] changedAttributes, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException { + public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, String[] changedAttributes, IJavaProject jproject, IPath containerPath, boolean isReferencedEntry, IProgressMonitor monitor) throws CoreException { if (containerPath != null) { updateContainerClasspath(jproject, containerPath, newEntry, changedAttributes, monitor); + } else if (isReferencedEntry) { + updateReferencedClasspathEntry(jproject, newEntry, changedAttributes, monitor); } else { updateProjectClasspath(shell, jproject, newEntry, changedAttributes, monitor); } } - - /** - * Apply a modified classpath entry to the classpath. The classpath entry can also be from a classpath container. - * @param shell If not null and the entry could not be found on the projects classpath, a dialog will ask to put the entry on the classpath - * @param newEntry The modified entry. The entry's kind or path must be unchanged. - * @param jproject Project where the entry belongs to - * @param containerPath The path of the entry's parent container or null if the entry is not in a container - * @param monitor The progress monitor to use - * @throws CoreException if the update failed - */ - public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException { - modifyClasspathEntry(shell, newEntry, null, jproject, containerPath, monitor); - } - private static void updateContainerClasspath(IJavaProject jproject, IPath containerPath, IClasspathEntry newEntry, String[] changedAttributes, IProgressMonitor monitor) throws CoreException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); if (container == null) { @@ -310,6 +299,39 @@ } /** + * Apply a modified referenced classpath entry to the classpath. + * @param newReferencedEntry the modified entry. The entry's kind or path must be unchanged. + * @param changedAttributes the attributes that have changed. See {@link CPListElement} for constants values. + * @param jproject project where the entry belongs to + * @param monitor the progress monitor to use + * @throws CoreException if the update failed + */ + private static void updateReferencedClasspathEntry(IJavaProject jproject, IClasspathEntry newReferencedEntry, String[] changedAttributes, IProgressMonitor monitor) throws CoreException { + IClasspathEntry[] oldReferencedClasspath= jproject.getReferencedClasspathEntries(); + int nEntries= oldReferencedClasspath.length; + ArrayList newReferencedEntries= new ArrayList(nEntries + 1); + int entryKind= newReferencedEntry.getEntryKind(); + IPath jarPath= newReferencedEntry.getPath(); + boolean found= false; + for (int i= 0; i < nEntries; i++) { + IClasspathEntry curr= oldReferencedClasspath[i]; + if (curr.getEntryKind() == entryKind && curr.getPath().equals(jarPath)) { + // add modified entry + newReferencedEntries.add(getUpdatedEntry(curr, newReferencedEntry, changedAttributes, jproject)); + found= true; + } else { + newReferencedEntries.add(curr); + } + } + if (!found) { + newReferencedEntries.add(newReferencedEntry); + } + IClasspathEntry[] newReferencedClasspath= (IClasspathEntry[]) newReferencedEntries.toArray(new IClasspathEntry[newReferencedEntries.size()]); + + jproject.setRawClasspath(jproject.getRawClasspath(), newReferencedClasspath, jproject.getOutputLocation(), monitor); + } + + /** * Sets the default compiler compliance options iff modifiedClassPathEntries * contains a classpath container entry that is modified or new and that points to an execution * environment. Does nothing if the EE or the options could not be resolved. Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java,v retrieving revision 1.137 diff -u -r1.137 LibrariesWorkbookPage.java --- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java 18 Mar 2009 11:09:33 -0000 1.137 +++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java 26 Feb 2010 19:31:20 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -532,7 +532,7 @@ try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { - BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, monitor); + BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, false, monitor); } }; PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceAttachmentBlock.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceAttachmentBlock.java,v retrieving revision 1.95 diff -u -r1.95 SourceAttachmentBlock.java --- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceAttachmentBlock.java 18 Mar 2009 11:09:33 -0000 1.95 +++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceAttachmentBlock.java 26 Feb 2010 19:31:20 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -580,12 +580,12 @@ * @param containerPath the path of the parent container or null if the element is not in a container * @return return the runnable */ - public static IRunnableWithProgress getRunnable(final Shell shell, final IClasspathEntry newEntry, final IJavaProject jproject, final IPath containerPath) { + public static IRunnableWithProgress getRunnable(final Shell shell, final IClasspathEntry newEntry, final IJavaProject jproject, final IPath containerPath, final boolean isReferencedEntry) { return new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { String[] changedAttributes= { CPListElement.SOURCEATTACHMENT }; - BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, jproject, containerPath, monitor); + BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, jproject, containerPath, isReferencedEntry, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); }