### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/IClasspathAttribute.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathAttribute.java,v retrieving revision 1.14 diff -u -r1.14 IClasspathAttribute.java --- model/org/eclipse/jdt/core/IClasspathAttribute.java 11 May 2010 18:47:10 -0000 1.14 +++ model/org/eclipse/jdt/core/IClasspathAttribute.java 7 Feb 2011 14:47:24 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 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 @@ -60,6 +60,21 @@ String JAVADOC_LOCATION_ATTRIBUTE_NAME = "javadoc_location"; //$NON-NLS-1$ /** + * Constant for the name of the "prefer attached Javadoc over attached + * source" attribute. + *

+ * The possible values + * for this attribute are "true" or "false". + * When not present, "false" is assumed. + * If the value of this attribute is "true", then Javadoc + * from {@link #JAVADOC_LOCATION_ATTRIBUTE_NAME} should be preferred over + * Javadoc from {@link IClasspathEntry#getSourceAttachmentPath()}. + * + * @since 3.7 + */ + String JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME = "javadoc_preferred"; //$NON-NLS-1$ + + /** * Constant for the name of the optional attribute. The possible values * for this attribute are "true" or "false". * When not present, "false" is assumed. #P org.eclipse.jdt.ui Index: ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocStandardWizardPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocStandardWizardPage.java,v retrieving revision 1.41 diff -u -r1.41 JavadocStandardWizardPage.java --- ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocStandardWizardPage.java 11 Sep 2008 11:59:44 -0000 1.41 +++ ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocStandardWizardPage.java 7 Feb 2011 14:47:25 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -533,7 +533,7 @@ fElement= selection; URL initialLocation= selection.getURL(); - fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, this, initialLocation, selection.isProjectRef()); + fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, this, initialLocation, false, selection.isProjectRef()); } protected Control createDialogArea(Composite parent) { Index: ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java,v retrieving revision 1.58 diff -u -r1.58 JavadocConfigurationBlock.java --- ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java 18 Nov 2009 09:53:20 -0000 1.58 +++ ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java 7 Feb 2011 14:47:25 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -88,6 +88,7 @@ private StringDialogField fArchiveField; private StringDialogField fArchivePathField; private URL fInitialURL; + private boolean fInitialPreferJavadocLocation; private SelectionButtonDialogField fValidateURLButton; private SelectionButtonDialogField fValidateArchiveButton; private SelectionButtonDialogField fBrowseFolder; @@ -96,6 +97,7 @@ private SelectionButtonDialogField fBrowseArchive; private SelectionButtonDialogField fExternalRadio, fWorkspaceRadio; private SelectionButtonDialogField fBrowseArchivePath; + private SelectionButtonDialogField fPreferJavadocLocationButton; private Shell fShell; private IStatusChangeListener fContext; @@ -109,10 +111,11 @@ boolean fIsForSource; - public JavadocConfigurationBlock(Shell shell, IStatusChangeListener context, URL initURL, boolean forSource) { + public JavadocConfigurationBlock(Shell shell, IStatusChangeListener context, URL initURL, boolean initPreferJavadocLocation, boolean forSource) { fShell= shell; fContext= context; fInitialURL= initURL; + fInitialPreferJavadocLocation= initPreferJavadocLocation; fIsForSource= forSource; JDocConfigurationAdapter adapter= new JDocConfigurationAdapter(); @@ -167,6 +170,10 @@ fValidateArchiveButton= new SelectionButtonDialogField(SWT.PUSH); fValidateArchiveButton.setDialogFieldListener(adapter); fValidateArchiveButton.setLabelText(PreferencesMessages.JavadocConfigurationBlock_validate_button); + + fPreferJavadocLocationButton= new SelectionButtonDialogField(SWT.CHECK); + fPreferJavadocLocationButton.setDialogFieldListener(adapter); + fPreferJavadocLocationButton.setLabelText("&Prefer attached Javadoc over Javadoc from attached source"); } fURLStatus= new StatusInfo(); @@ -244,6 +251,8 @@ fURLRadioButton.attachDialogFields(new DialogField[] {fURLField, fBrowseFolder, fValidateURLButton }); fArchiveRadioButton.attachDialogFields(new DialogField[] {fArchiveField, fBrowseArchive, fExternalRadio, fWorkspaceRadio, fArchivePathField, fBrowseArchivePath, fValidateArchiveButton }); + + fPreferJavadocLocationButton.doFillIntoGrid(topComp, 1); } @@ -301,6 +310,7 @@ fExternalRadio.setSelection(!isWorkspaceArchive); fWorkspaceRadio.setSelection(isWorkspaceArchive); + fPreferJavadocLocationButton.setSelection(fInitialPreferJavadocLocation); } public void setFocus() { @@ -317,6 +327,10 @@ } return fArchiveURLResult; } + + public boolean getPreferJavadocLocation() { + return fPreferJavadocLocationButton.isSelected(); + } private class EntryValidator implements Runnable { 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.38 diff -u -r1.38 JavadocConfigurationPropertyPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java 3 Feb 2011 18:32:52 -0000 1.38 +++ ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java 7 Feb 2011 14:47:25 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -12,6 +12,7 @@ import java.lang.reflect.InvocationTargetException; import java.net.URL; +import java.util.ArrayList; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -58,6 +59,7 @@ import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; +import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; @@ -79,6 +81,7 @@ private IPath fContainerPath; private IClasspathEntry fEntry; private URL fInitalLocation; + private boolean finitialPreferAttachedJavadoc; public JavadocConfigurationPropertyPage() { } @@ -185,13 +188,14 @@ if (elem != null) { try { fInitalLocation= JavaUI.getJavadocBaseLocation(elem); + finitialPreferAttachedJavadoc= JavadocContentAccess2.getPreferAttachedJavadoc(elem); } catch (JavaModelException e) { JavaPlugin.log(e); } } boolean isProject= (elem instanceof IJavaProject); - fJavadocConfigurationBlock= new JavadocConfigurationBlock(getShell(), this, fInitalLocation, isProject); + fJavadocConfigurationBlock= new JavadocConfigurationBlock(getShell(), this, fInitalLocation, finitialPreferAttachedJavadoc, isProject); Control control= fJavadocConfigurationBlock.createContents(parent); control.setVisible(elem != null); @@ -236,16 +240,45 @@ */ public boolean performOk() { if (fJavadocConfigurationBlock != null) { - URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation(); - if (javadocLocation == null && fInitalLocation == null - || javadocLocation != null && fInitalLocation != null && javadocLocation.toExternalForm().equals(fInitalLocation.toExternalForm())) { + final URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation(); + final boolean preferAttachedJavadoc= fJavadocConfigurationBlock.getPreferJavadocLocation(); + + final boolean javadocLocationModified= !(javadocLocation == null && fInitalLocation == null + || javadocLocation != null && fInitalLocation != null && javadocLocation.toExternalForm().equals(fInitalLocation.toExternalForm())); + final boolean preferAttachedJavadocModified= preferAttachedJavadoc != finitialPreferAttachedJavadoc; + if (javadocLocationModified && preferAttachedJavadocModified) return true; // no change - } - - IJavaElement elem= getJavaElement(); + final Shell shell= getShell(); + final IJavaElement elem= getJavaElement(); try { - IRunnableWithProgress runnable= getRunnable(getShell(), elem, javadocLocation, fEntry, fContainerPath); + IRunnableWithProgress runnable= new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + IJavaProject project= elem.getJavaProject(); + if (elem instanceof IPackageFragmentRoot) { + ArrayList changedAttributes= new ArrayList(2); + CPListElement cpElem= CPListElement.createFromExisting(fEntry, project); + IClasspathEntry newEntry= cpElem.getClasspathEntry(); + if (javadocLocationModified) { + String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null; + cpElem.setAttribute(CPListElement.JAVADOC, loc); + changedAttributes.add(CPListElement.JAVADOC); + } + if (preferAttachedJavadocModified) { + cpElem.setAttribute(CPListElement.PREFER_JAVADOC, Boolean.valueOf(preferAttachedJavadoc)); + changedAttributes.add(CPListElement.PREFER_JAVADOC); + } + String[] changedAttributes2= (String[]) changedAttributes.toArray(new String[changedAttributes.size()]); + BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes2, project, fContainerPath, fEntry.getReferencingEntry() != null, monitor); + } else { + JavaUI.setProjectJavadocLocation(project, javadocLocation); + } + } catch (CoreException e) { + throw new InvocationTargetException(e); + } + } + }; PlatformUI.getWorkbench().getProgressService().run(true, true, runnable); } catch (InvocationTargetException e) { String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title; @@ -261,29 +294,6 @@ } - private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final URL javadocLocation, final IClasspathEntry entry, final IPath containerPath) { - return new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - IJavaProject project= elem.getJavaProject(); - if (elem instanceof IPackageFragmentRoot) { - CPListElement cpElem= CPListElement.createFromExisting(entry, project); - String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null; - cpElem.setAttribute(CPListElement.JAVADOC, loc); - IClasspathEntry newEntry= cpElem.getClasspathEntry(); - String[] changedAttributes= { CPListElement.JAVADOC }; - BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, entry.getReferencingEntry() != null, monitor); - } else { - JavaUI.setProjectJavadocLocation(project, javadocLocation); - } - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - }; - } - - /** * @see IStatusChangeListener#statusChanged(IStatus) */ Index: ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java,v retrieving revision 1.28 diff -u -r1.28 JavadocContentAccess2.java --- ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java 29 Oct 2010 15:38:21 -0000 1.28 +++ ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java 7 Feb 2011 14:47:25 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2011 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 @@ -31,7 +31,10 @@ import org.eclipse.jface.internal.text.html.HTMLPrinter; import org.eclipse.jdt.core.IBuffer; +import org.eclipse.jdt.core.IClasspathAttribute; +import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IField; +import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMethod; @@ -447,31 +450,52 @@ * @throws JavaModelException is thrown when the element's Javadoc can not be accessed */ public static String getHTMLContent(IMember member, boolean useAttachedJavadoc) throws JavaModelException { + //TODO: remove unused useAttachedJavadoc + boolean preferAttached= getPreferAttachedJavadoc(member); + if (preferAttached) { + String attached= member.getAttachedJavadoc(null); + if (attached != null) + return attached; + } String sourceJavadoc= getHTMLContentFromSource(member); if (sourceJavadoc == null || sourceJavadoc.length() == 0 || sourceJavadoc.trim().equals("{@inheritDoc}")) { //$NON-NLS-1$ - if (useAttachedJavadoc) { - if (member.getOpenable().getBuffer() == null) { // only if no source available - return member.getAttachedJavadoc(null); - } - if (canInheritJavadoc(member)) { - IMethod method= (IMethod) member; - String attachedDocInHierarchy= findAttachedDocInHierarchy(method); - - // Prepend "Overrides:" / "Specified by:" reference headers to make clear - // that description has been copied from super method. - if (attachedDocInHierarchy == null) - return sourceJavadoc; - StringBuffer superMethodReferences= createSuperMethodReferences(method); - if (superMethodReferences == null) - return attachedDocInHierarchy; - superMethodReferences.append(attachedDocInHierarchy); - return superMethodReferences.toString(); - } + if (!preferAttached && member.getOpenable().getBuffer() == null) { // only if no source available + return member.getAttachedJavadoc(null); + } + if (canInheritJavadoc(member)) { + IMethod method= (IMethod) member; + String attachedDocInHierarchy= findAttachedDocInHierarchy(method); + + // Prepend "Overrides:" / "Specified by:" reference headers to make clear + // that description has been copied from super method. + if (attachedDocInHierarchy == null) + return sourceJavadoc; + StringBuffer superMethodReferences= createSuperMethodReferences(method); + if (superMethodReferences == null) + return attachedDocInHierarchy; + superMethodReferences.append(attachedDocInHierarchy); + return superMethodReferences.toString(); } } return sourceJavadoc; } + public static boolean getPreferAttachedJavadoc(IJavaElement element) throws JavaModelException { + IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(element); + if (root == null) + return false; + + IClasspathEntry classpathEntry= root.getRawClasspathEntry(); + IClasspathAttribute[] extraAttributes= classpathEntry.getExtraAttributes(); + for (int i= 0; i < extraAttributes.length; i++) { + IClasspathAttribute attribute= extraAttributes[i]; + if (IClasspathAttribute.JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME.equals(attribute.getName())) { + return "true".equals(attribute.getValue()); //$NON-NLS-1$ + } + } + return false; + } + private static StringBuffer createSuperMethodReferences(final IMethod method) throws JavaModelException { IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= SuperTypeHierarchyCache.getTypeHierarchy(type); Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java,v retrieving revision 1.80 diff -u -r1.80 CPListElement.java --- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java 21 Jul 2010 06:24:17 -0000 1.80 +++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java 7 Feb 2011 14:47:25 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -54,6 +54,7 @@ public static final String COMBINE_ACCESSRULES= "combineaccessrules"; //$NON-NLS-1$ public static final String JAVADOC= IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME; + public static final String PREFER_JAVADOC= IClasspathAttribute.JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME; public static final String NATIVE_LIB_PATH= JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY; private IJavaProject fProject; Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JavadocLocationDialog.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JavadocLocationDialog.java,v retrieving revision 1.10 diff -u -r1.10 JavadocLocationDialog.java --- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JavadocLocationDialog.java 31 Dec 2008 21:13:23 -0000 1.10 +++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JavadocLocationDialog.java 7 Feb 2011 14:47:25 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -23,6 +23,8 @@ import org.eclipse.ui.PlatformUI; +import org.eclipse.jdt.core.IClasspathAttribute; + import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; @@ -44,8 +46,9 @@ * @param parent The parent shell for the dialog. * @param libraryName Name of of the library to which configured javadoc location belongs. * @param initialURL The initial URL or null. + * @param preferJavadocLocation The initial value for {@link IClasspathAttribute#JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME}. */ - public JavadocLocationDialog(Shell parent, String libraryName, URL initialURL) { + public JavadocLocationDialog(Shell parent, String libraryName, URL initialURL, boolean preferJavadocLocation) { super(parent); IStatusChangeListener listener= new IStatusChangeListener() { @@ -55,7 +58,7 @@ }; setTitle(Messages.format(NewWizardMessages.LibrariesWorkbookPage_JavadocPropertyDialog_title, libraryName)); - fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, listener, initialURL, false); + fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, listener, initialURL, preferJavadocLocation, false); } /* @@ -86,6 +89,18 @@ return fJavadocConfigurationBlock.getJavadocLocation(); } + /** + * Returns whether attached Javadoc is preferred over source attachments. + * The result is only valid after the dialog has been opened and has not been cancelled by the user. + * + * @return the configured value + * + * @since 3.7 + */ + public boolean getPreferJavadocLocation() { + return fJavadocConfigurationBlock.getPreferJavadocLocation(); + } + /* * @see org.eclipse.jface.window.Window#configureShell(Shell) */ Index: ui/org/eclipse/jdt/ui/wizards/BuildPathDialogAccess.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/BuildPathDialogAccess.java,v retrieving revision 1.23 diff -u -r1.23 BuildPathDialogAccess.java --- ui/org/eclipse/jdt/ui/wizards/BuildPathDialogAccess.java 11 Sep 2008 11:59:20 -0000 1.23 +++ ui/org/eclipse/jdt/ui/wizards/BuildPathDialogAccess.java 7 Feb 2011 14:47:25 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -36,6 +36,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.ui.views.navigator.ResourceComparator; +import org.eclipse.jdt.core.IClasspathAttribute; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; @@ -130,7 +131,7 @@ throw new IllegalArgumentException(); } - JavadocLocationDialog dialog= new JavadocLocationDialog(shell, libraryName, initialURL); + JavadocLocationDialog dialog= new JavadocLocationDialog(shell, libraryName, initialURL, false); if (dialog.open() == Window.OK) { return new URL[] { dialog.getResult() }; } @@ -161,15 +162,29 @@ } URL location= JavaUI.getLibraryJavadocLocation(initialEntry); - JavadocLocationDialog dialog= new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location); + boolean preferJavadocLocation= getPreferAttachedJavadoc(initialEntry); + JavadocLocationDialog dialog= new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location, preferJavadocLocation); if (dialog.open() == Window.OK) { CPListElement element= CPListElement.createFromExisting(initialEntry, null); URL res= dialog.getResult(); element.setAttribute(CPListElement.JAVADOC, res != null ? res.toExternalForm() : null); + boolean preferJavadoc= dialog.getPreferJavadocLocation(); + element.setAttribute(CPListElement.PREFER_JAVADOC, Boolean.valueOf(preferJavadoc)); return element.getClasspathEntry(); } return null; } + + private static boolean getPreferAttachedJavadoc(IClasspathEntry entry) { + IClasspathAttribute[] extraAttributes= entry.getExtraAttributes(); + for (int i= 0; i < extraAttributes.length; i++) { + IClasspathAttribute attrib= extraAttributes[i]; + if (IClasspathAttribute.JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME.equals(attrib.getName())) { + return Boolean.valueOf(attrib.getValue()).booleanValue(); + } + } + return false; + } /** * Shows the UI for configuring a variable classpath entry. See {@link IClasspathEntry#CPE_VARIABLE} for