View | Details | Raw Unified | Return to bug 178071
Collapse All | Expand All

(-)model/org/eclipse/jdt/core/IClasspathAttribute.java (-1 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 60-65 Link Here
60
	String JAVADOC_LOCATION_ATTRIBUTE_NAME = "javadoc_location"; //$NON-NLS-1$
60
	String JAVADOC_LOCATION_ATTRIBUTE_NAME = "javadoc_location"; //$NON-NLS-1$
61
61
62
	/**
62
	/**
63
	 * Constant for the name of the "prefer attached Javadoc over attached
64
	 * source" attribute.
65
	 * <p>
66
	 * The possible values
67
	 * for this attribute are <code>"true"</code> or <code>"false"</code>.
68
	 * When not present, <code>"false"</code> is assumed.
69
	 * If the value of this attribute is <code>"true"</code>, then Javadoc
70
	 * from {@link #JAVADOC_LOCATION_ATTRIBUTE_NAME} should be preferred over
71
	 * Javadoc from {@link IClasspathEntry#getSourceAttachmentPath()}.
72
	 * 
73
	 * @since 3.7
74
	 */
75
	String JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME = "javadoc_preferred"; //$NON-NLS-1$
76
	
77
	/**
63
	 * Constant for the name of the optional attribute. The possible values
78
	 * Constant for the name of the optional attribute. The possible values
64
	 * for this attribute are <code>"true"</code> or <code>"false"</code>.
79
	 * for this attribute are <code>"true"</code> or <code>"false"</code>.
65
	 * When not present, <code>"false"</code> is assumed.
80
	 * When not present, <code>"false"</code> is assumed.
(-)ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocStandardWizardPage.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 533-539 Link Here
533
533
534
			fElement= selection;
534
			fElement= selection;
535
			URL initialLocation= selection.getURL();
535
			URL initialLocation= selection.getURL();
536
			fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, this, initialLocation, selection.isProjectRef());
536
			fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, this, initialLocation, false, selection.isProjectRef());
537
		}
537
		}
538
538
539
		protected Control createDialogArea(Composite parent) {
539
		protected Control createDialogArea(Composite parent) {
(-)ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java (-2 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 88-93 Link Here
88
	private StringDialogField fArchiveField;
88
	private StringDialogField fArchiveField;
89
	private StringDialogField fArchivePathField;
89
	private StringDialogField fArchivePathField;
90
	private URL fInitialURL;
90
	private URL fInitialURL;
91
	private boolean fInitialPreferJavadocLocation;
91
	private SelectionButtonDialogField fValidateURLButton;
92
	private SelectionButtonDialogField fValidateURLButton;
92
	private SelectionButtonDialogField fValidateArchiveButton;
93
	private SelectionButtonDialogField fValidateArchiveButton;
93
	private SelectionButtonDialogField fBrowseFolder;
94
	private SelectionButtonDialogField fBrowseFolder;
Lines 96-101 Link Here
96
	private SelectionButtonDialogField fBrowseArchive;
97
	private SelectionButtonDialogField fBrowseArchive;
97
	private SelectionButtonDialogField fExternalRadio, fWorkspaceRadio;
98
	private SelectionButtonDialogField fExternalRadio, fWorkspaceRadio;
98
	private SelectionButtonDialogField fBrowseArchivePath;
99
	private SelectionButtonDialogField fBrowseArchivePath;
100
	private SelectionButtonDialogField fPreferJavadocLocationButton;
99
	private Shell fShell;
101
	private Shell fShell;
100
	private IStatusChangeListener fContext;
102
	private IStatusChangeListener fContext;
101
103
Lines 109-118 Link Here
109
	boolean fIsForSource;
111
	boolean fIsForSource;
110
112
111
113
112
	public JavadocConfigurationBlock(Shell shell,  IStatusChangeListener context, URL initURL, boolean forSource) {
114
	public JavadocConfigurationBlock(Shell shell,  IStatusChangeListener context, URL initURL, boolean initPreferJavadocLocation, boolean forSource) {
113
		fShell= shell;
115
		fShell= shell;
114
		fContext= context;
116
		fContext= context;
115
		fInitialURL= initURL;
117
		fInitialURL= initURL;
118
		fInitialPreferJavadocLocation= initPreferJavadocLocation;
116
		fIsForSource= forSource;
119
		fIsForSource= forSource;
117
120
118
		JDocConfigurationAdapter adapter= new JDocConfigurationAdapter();
121
		JDocConfigurationAdapter adapter= new JDocConfigurationAdapter();
Lines 167-172 Link Here
167
			fValidateArchiveButton= new SelectionButtonDialogField(SWT.PUSH);
170
			fValidateArchiveButton= new SelectionButtonDialogField(SWT.PUSH);
168
			fValidateArchiveButton.setDialogFieldListener(adapter);
171
			fValidateArchiveButton.setDialogFieldListener(adapter);
169
			fValidateArchiveButton.setLabelText(PreferencesMessages.JavadocConfigurationBlock_validate_button);
172
			fValidateArchiveButton.setLabelText(PreferencesMessages.JavadocConfigurationBlock_validate_button);
173
			
174
			fPreferJavadocLocationButton= new SelectionButtonDialogField(SWT.CHECK);
175
			fPreferJavadocLocationButton.setDialogFieldListener(adapter);
176
			fPreferJavadocLocationButton.setLabelText("&Prefer attached Javadoc over Javadoc from attached source");
170
		}
177
		}
171
178
172
		fURLStatus= new StatusInfo();
179
		fURLStatus= new StatusInfo();
Lines 244-249 Link Here
244
251
245
			fURLRadioButton.attachDialogFields(new DialogField[] {fURLField,  fBrowseFolder, fValidateURLButton });
252
			fURLRadioButton.attachDialogFields(new DialogField[] {fURLField,  fBrowseFolder, fValidateURLButton });
246
			fArchiveRadioButton.attachDialogFields(new DialogField[] {fArchiveField,  fBrowseArchive, fExternalRadio, fWorkspaceRadio, fArchivePathField, fBrowseArchivePath, fValidateArchiveButton });
253
			fArchiveRadioButton.attachDialogFields(new DialogField[] {fArchiveField,  fBrowseArchive, fExternalRadio, fWorkspaceRadio, fArchivePathField, fBrowseArchivePath, fValidateArchiveButton });
254
			
255
			fPreferJavadocLocationButton.doFillIntoGrid(topComp, 1);
247
		}
256
		}
248
257
249
258
Lines 301-306 Link Here
301
		fExternalRadio.setSelection(!isWorkspaceArchive);
310
		fExternalRadio.setSelection(!isWorkspaceArchive);
302
		fWorkspaceRadio.setSelection(isWorkspaceArchive);
311
		fWorkspaceRadio.setSelection(isWorkspaceArchive);
303
312
313
		fPreferJavadocLocationButton.setSelection(fInitialPreferJavadocLocation);
304
	}
314
	}
305
315
306
	public void setFocus() {
316
	public void setFocus() {
Lines 317-322 Link Here
317
		}
327
		}
318
		return fArchiveURLResult;
328
		return fArchiveURLResult;
319
	}
329
	}
330
	
331
	public boolean getPreferJavadocLocation() {
332
		return fPreferJavadocLocationButton.isSelected();
333
	}
320
334
321
	private class EntryValidator implements Runnable {
335
	private class EntryValidator implements Runnable {
322
336
(-)ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java (-32 / +42 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
12
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
import java.net.URL;
14
import java.net.URL;
15
import java.util.ArrayList;
15
16
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.layout.GridData;
Lines 58-63 Link Here
58
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
59
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
59
import org.eclipse.jdt.internal.ui.JavaPlugin;
60
import org.eclipse.jdt.internal.ui.JavaPlugin;
60
import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
61
import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
62
import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2;
61
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
63
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
62
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
64
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
63
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
65
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
Lines 79-84 Link Here
79
	private IPath fContainerPath;
81
	private IPath fContainerPath;
80
	private IClasspathEntry fEntry;
82
	private IClasspathEntry fEntry;
81
	private URL fInitalLocation;
83
	private URL fInitalLocation;
84
	private boolean finitialPreferAttachedJavadoc;
82
85
83
	public JavadocConfigurationPropertyPage() {
86
	public JavadocConfigurationPropertyPage() {
84
	}
87
	}
Lines 185-197 Link Here
185
		if (elem != null) {
188
		if (elem != null) {
186
			try {
189
			try {
187
				fInitalLocation= JavaUI.getJavadocBaseLocation(elem);
190
				fInitalLocation= JavaUI.getJavadocBaseLocation(elem);
191
				finitialPreferAttachedJavadoc= JavadocContentAccess2.getPreferAttachedJavadoc(elem);
188
			} catch (JavaModelException e) {
192
			} catch (JavaModelException e) {
189
				JavaPlugin.log(e);
193
				JavaPlugin.log(e);
190
			}
194
			}
191
		}
195
		}
192
196
193
		boolean isProject= (elem instanceof IJavaProject);
197
		boolean isProject= (elem instanceof IJavaProject);
194
		fJavadocConfigurationBlock= new JavadocConfigurationBlock(getShell(), this, fInitalLocation, isProject);
198
		fJavadocConfigurationBlock= new JavadocConfigurationBlock(getShell(), this, fInitalLocation, finitialPreferAttachedJavadoc, isProject);
195
		Control control= fJavadocConfigurationBlock.createContents(parent);
199
		Control control= fJavadocConfigurationBlock.createContents(parent);
196
		control.setVisible(elem != null);
200
		control.setVisible(elem != null);
197
201
Lines 236-251 Link Here
236
	 */
240
	 */
237
	public boolean performOk() {
241
	public boolean performOk() {
238
		if (fJavadocConfigurationBlock != null) {
242
		if (fJavadocConfigurationBlock != null) {
239
			URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation();
243
			final URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation();
240
			if (javadocLocation == null && fInitalLocation == null
244
			final boolean preferAttachedJavadoc= fJavadocConfigurationBlock.getPreferJavadocLocation();
241
					|| javadocLocation != null && fInitalLocation != null && javadocLocation.toExternalForm().equals(fInitalLocation.toExternalForm())) {
245
			
246
			final boolean javadocLocationModified= !(javadocLocation == null && fInitalLocation == null
247
					|| javadocLocation != null && fInitalLocation != null && javadocLocation.toExternalForm().equals(fInitalLocation.toExternalForm()));
248
			final boolean preferAttachedJavadocModified= preferAttachedJavadoc != finitialPreferAttachedJavadoc;
249
			if (javadocLocationModified && preferAttachedJavadocModified)
242
				return true; // no change
250
				return true; // no change
243
			}
244
245
251
246
			IJavaElement elem= getJavaElement();
252
			final Shell shell= getShell();
253
			final IJavaElement elem= getJavaElement();
247
			try {
254
			try {
248
				IRunnableWithProgress runnable= getRunnable(getShell(), elem, javadocLocation, fEntry, fContainerPath);
255
				IRunnableWithProgress runnable= new IRunnableWithProgress() {
256
					public void run(IProgressMonitor monitor) throws InvocationTargetException {
257
						try {
258
							IJavaProject project= elem.getJavaProject();
259
							if (elem instanceof IPackageFragmentRoot) {
260
								ArrayList changedAttributes= new ArrayList(2);
261
								CPListElement cpElem= CPListElement.createFromExisting(fEntry, project);
262
								IClasspathEntry newEntry= cpElem.getClasspathEntry();
263
								if (javadocLocationModified) {
264
									String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null;
265
									cpElem.setAttribute(CPListElement.JAVADOC, loc);
266
									changedAttributes.add(CPListElement.JAVADOC);
267
								}
268
								if (preferAttachedJavadocModified) {
269
									cpElem.setAttribute(CPListElement.PREFER_JAVADOC, Boolean.valueOf(preferAttachedJavadoc));
270
									changedAttributes.add(CPListElement.PREFER_JAVADOC);
271
								}
272
								String[] changedAttributes2= (String[]) changedAttributes.toArray(new String[changedAttributes.size()]);
273
								BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes2, project, fContainerPath, fEntry.getReferencingEntry() != null, monitor);
274
							} else {
275
								JavaUI.setProjectJavadocLocation(project, javadocLocation);
276
							}
277
						} catch (CoreException e) {
278
							throw new InvocationTargetException(e);
279
						}
280
					}
281
				};
249
				PlatformUI.getWorkbench().getProgressService().run(true, true, runnable);
282
				PlatformUI.getWorkbench().getProgressService().run(true, true, runnable);
250
			} catch (InvocationTargetException e) {
283
			} catch (InvocationTargetException e) {
251
				String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title;
284
				String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title;
Lines 261-289 Link Here
261
	}
294
	}
262
295
263
296
264
	private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final URL javadocLocation, final IClasspathEntry entry, final IPath containerPath) {
265
		return new IRunnableWithProgress() {
266
			public void run(IProgressMonitor monitor) throws InvocationTargetException {
267
				try {
268
					IJavaProject project= elem.getJavaProject();
269
					if (elem instanceof IPackageFragmentRoot) {
270
						CPListElement cpElem= CPListElement.createFromExisting(entry, project);
271
						String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null;
272
						cpElem.setAttribute(CPListElement.JAVADOC, loc);
273
						IClasspathEntry newEntry= cpElem.getClasspathEntry();
274
						String[] changedAttributes= { CPListElement.JAVADOC };
275
						BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, entry.getReferencingEntry() != null, monitor);
276
					} else {
277
						JavaUI.setProjectJavadocLocation(project, javadocLocation);
278
					}
279
				} catch (CoreException e) {
280
					throw new InvocationTargetException(e);
281
				}
282
			}
283
		};
284
	}
285
286
287
	/**
297
	/**
288
	 * @see IStatusChangeListener#statusChanged(IStatus)
298
	 * @see IStatusChangeListener#statusChanged(IStatus)
289
	 */
299
	 */
(-)ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java (-19 / +43 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2010 IBM Corporation and others.
2
 * Copyright (c) 2008, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 31-37 Link Here
31
import org.eclipse.jface.internal.text.html.HTMLPrinter;
31
import org.eclipse.jface.internal.text.html.HTMLPrinter;
32
32
33
import org.eclipse.jdt.core.IBuffer;
33
import org.eclipse.jdt.core.IBuffer;
34
import org.eclipse.jdt.core.IClasspathAttribute;
35
import org.eclipse.jdt.core.IClasspathEntry;
34
import org.eclipse.jdt.core.IField;
36
import org.eclipse.jdt.core.IField;
37
import org.eclipse.jdt.core.IJavaElement;
35
import org.eclipse.jdt.core.IJavaProject;
38
import org.eclipse.jdt.core.IJavaProject;
36
import org.eclipse.jdt.core.IMember;
39
import org.eclipse.jdt.core.IMember;
37
import org.eclipse.jdt.core.IMethod;
40
import org.eclipse.jdt.core.IMethod;
Lines 447-477 Link Here
447
	 * @throws JavaModelException is thrown when the element's Javadoc can not be accessed
450
	 * @throws JavaModelException is thrown when the element's Javadoc can not be accessed
448
	 */
451
	 */
449
	public static String getHTMLContent(IMember member, boolean useAttachedJavadoc) throws JavaModelException {
452
	public static String getHTMLContent(IMember member, boolean useAttachedJavadoc) throws JavaModelException {
453
		//TODO: remove unused useAttachedJavadoc
454
		boolean preferAttached= getPreferAttachedJavadoc(member);
455
		if (preferAttached) {
456
			String attached= member.getAttachedJavadoc(null);
457
			if (attached != null)
458
				return attached;
459
		}
450
		String sourceJavadoc= getHTMLContentFromSource(member);
460
		String sourceJavadoc= getHTMLContentFromSource(member);
451
		if (sourceJavadoc == null || sourceJavadoc.length() == 0 || sourceJavadoc.trim().equals("{@inheritDoc}")) { //$NON-NLS-1$
461
		if (sourceJavadoc == null || sourceJavadoc.length() == 0 || sourceJavadoc.trim().equals("{@inheritDoc}")) { //$NON-NLS-1$
452
			if (useAttachedJavadoc) {
462
			if (!preferAttached && member.getOpenable().getBuffer() == null) { // only if no source available
453
				if (member.getOpenable().getBuffer() == null) { // only if no source available
463
				return member.getAttachedJavadoc(null);
454
					return member.getAttachedJavadoc(null);
464
			}
455
				}
465
			if (canInheritJavadoc(member)) {
456
				if (canInheritJavadoc(member)) {
466
				IMethod method= (IMethod) member;
457
					IMethod method= (IMethod) member;
467
				String attachedDocInHierarchy= findAttachedDocInHierarchy(method);
458
					String attachedDocInHierarchy= findAttachedDocInHierarchy(method);
468
459
469
				// Prepend "Overrides:" / "Specified by:" reference headers to make clear
460
					// Prepend "Overrides:" / "Specified by:" reference headers to make clear
470
				// that description has been copied from super method.
461
					// that description has been copied from super method.
471
				if (attachedDocInHierarchy == null)
462
					if (attachedDocInHierarchy == null)
472
					return sourceJavadoc;
463
						return sourceJavadoc;
473
				StringBuffer superMethodReferences= createSuperMethodReferences(method);
464
					StringBuffer superMethodReferences= createSuperMethodReferences(method);
474
				if (superMethodReferences == null)
465
					if (superMethodReferences == null)
475
					return attachedDocInHierarchy;
466
						return attachedDocInHierarchy;
476
				superMethodReferences.append(attachedDocInHierarchy);
467
					superMethodReferences.append(attachedDocInHierarchy);
477
				return superMethodReferences.toString();
468
					return superMethodReferences.toString();
469
				}
470
			}
478
			}
471
		}
479
		}
472
		return sourceJavadoc;
480
		return sourceJavadoc;
473
	}
481
	}
474
482
483
	public static boolean getPreferAttachedJavadoc(IJavaElement element) throws JavaModelException {
484
		IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(element);
485
		if (root == null)
486
			return false;
487
		
488
		IClasspathEntry classpathEntry= root.getRawClasspathEntry();
489
		IClasspathAttribute[] extraAttributes= classpathEntry.getExtraAttributes();
490
		for (int i= 0; i < extraAttributes.length; i++) {
491
			IClasspathAttribute attribute= extraAttributes[i];
492
			if (IClasspathAttribute.JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME.equals(attribute.getName())) {
493
				return "true".equals(attribute.getValue()); //$NON-NLS-1$
494
			}
495
		}
496
		return false;
497
	}
498
475
	private static StringBuffer createSuperMethodReferences(final IMethod method) throws JavaModelException {
499
	private static StringBuffer createSuperMethodReferences(final IMethod method) throws JavaModelException {
476
		IType type= method.getDeclaringType();
500
		IType type= method.getDeclaringType();
477
		ITypeHierarchy hierarchy= SuperTypeHierarchyCache.getTypeHierarchy(type);
501
		ITypeHierarchy hierarchy= SuperTypeHierarchyCache.getTypeHierarchy(type);
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 54-59 Link Here
54
	public static final String COMBINE_ACCESSRULES= "combineaccessrules"; //$NON-NLS-1$
54
	public static final String COMBINE_ACCESSRULES= "combineaccessrules"; //$NON-NLS-1$
55
55
56
	public static final String JAVADOC= IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME;
56
	public static final String JAVADOC= IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME;
57
	public static final String PREFER_JAVADOC= IClasspathAttribute.JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME;
57
	public static final String NATIVE_LIB_PATH= JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY;
58
	public static final String NATIVE_LIB_PATH= JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY;
58
59
59
	private IJavaProject fProject;
60
	private IJavaProject fProject;
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JavadocLocationDialog.java (-3 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 23-28 Link Here
23
23
24
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.PlatformUI;
25
25
26
import org.eclipse.jdt.core.IClasspathAttribute;
27
26
import org.eclipse.jdt.internal.corext.util.Messages;
28
import org.eclipse.jdt.internal.corext.util.Messages;
27
29
28
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
30
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
Lines 44-51 Link Here
44
	 * @param parent The parent shell for the dialog.
46
	 * @param parent The parent shell for the dialog.
45
	 * @param libraryName Name of of the library to which configured javadoc location belongs.
47
	 * @param libraryName Name of of the library to which configured javadoc location belongs.
46
	 * @param initialURL The initial URL or <code>null</code>.
48
	 * @param initialURL The initial URL or <code>null</code>.
49
	 * @param preferJavadocLocation The initial value for {@link IClasspathAttribute#JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME}.
47
	 */
50
	 */
48
	public JavadocLocationDialog(Shell parent, String libraryName, URL initialURL) {
51
	public JavadocLocationDialog(Shell parent, String libraryName, URL initialURL, boolean preferJavadocLocation) {
49
		super(parent);
52
		super(parent);
50
53
51
		IStatusChangeListener listener= new IStatusChangeListener() {
54
		IStatusChangeListener listener= new IStatusChangeListener() {
Lines 55-61 Link Here
55
		};
58
		};
56
59
57
		setTitle(Messages.format(NewWizardMessages.LibrariesWorkbookPage_JavadocPropertyDialog_title, libraryName));
60
		setTitle(Messages.format(NewWizardMessages.LibrariesWorkbookPage_JavadocPropertyDialog_title, libraryName));
58
		fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, listener, initialURL, false);
61
		fJavadocConfigurationBlock= new JavadocConfigurationBlock(parent, listener, initialURL, preferJavadocLocation, false);
59
	}
62
	}
60
63
61
	/*
64
	/*
Lines 86-91 Link Here
86
		return fJavadocConfigurationBlock.getJavadocLocation();
89
		return fJavadocConfigurationBlock.getJavadocLocation();
87
	}
90
	}
88
91
92
	/**
93
	 * Returns whether attached Javadoc is preferred over source attachments.
94
	 * The result is only valid after the dialog has been opened and has not been cancelled by the user.
95
	 * 
96
	 * @return the configured value
97
	 * 
98
	 * @since 3.7
99
	 */
100
	public boolean getPreferJavadocLocation() {
101
		return fJavadocConfigurationBlock.getPreferJavadocLocation();
102
	}
103
	
89
	/*
104
	/*
90
	 * @see org.eclipse.jface.window.Window#configureShell(Shell)
105
	 * @see org.eclipse.jface.window.Window#configureShell(Shell)
91
	 */
106
	 */
(-)ui/org/eclipse/jdt/ui/wizards/BuildPathDialogAccess.java (-3 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 36-41 Link Here
36
import org.eclipse.ui.model.WorkbenchLabelProvider;
36
import org.eclipse.ui.model.WorkbenchLabelProvider;
37
import org.eclipse.ui.views.navigator.ResourceComparator;
37
import org.eclipse.ui.views.navigator.ResourceComparator;
38
38
39
import org.eclipse.jdt.core.IClasspathAttribute;
39
import org.eclipse.jdt.core.IClasspathEntry;
40
import org.eclipse.jdt.core.IClasspathEntry;
40
import org.eclipse.jdt.core.IJavaProject;
41
import org.eclipse.jdt.core.IJavaProject;
41
42
Lines 130-136 Link Here
130
			throw new IllegalArgumentException();
131
			throw new IllegalArgumentException();
131
		}
132
		}
132
133
133
		JavadocLocationDialog dialog=  new JavadocLocationDialog(shell, libraryName, initialURL);
134
		JavadocLocationDialog dialog=  new JavadocLocationDialog(shell, libraryName, initialURL, false);
134
		if (dialog.open() == Window.OK) {
135
		if (dialog.open() == Window.OK) {
135
			return new URL[] { dialog.getResult() };
136
			return new URL[] { dialog.getResult() };
136
		}
137
		}
Lines 161-175 Link Here
161
		}
162
		}
162
163
163
		URL location= JavaUI.getLibraryJavadocLocation(initialEntry);
164
		URL location= JavaUI.getLibraryJavadocLocation(initialEntry);
164
		JavadocLocationDialog dialog=  new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location);
165
		boolean preferJavadocLocation= getPreferAttachedJavadoc(initialEntry);
166
		JavadocLocationDialog dialog=  new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location, preferJavadocLocation);
165
		if (dialog.open() == Window.OK) {
167
		if (dialog.open() == Window.OK) {
166
			CPListElement element= CPListElement.createFromExisting(initialEntry, null);
168
			CPListElement element= CPListElement.createFromExisting(initialEntry, null);
167
			URL res= dialog.getResult();
169
			URL res= dialog.getResult();
168
			element.setAttribute(CPListElement.JAVADOC, res != null ? res.toExternalForm() : null);
170
			element.setAttribute(CPListElement.JAVADOC, res != null ? res.toExternalForm() : null);
171
			boolean preferJavadoc= dialog.getPreferJavadocLocation();
172
			element.setAttribute(CPListElement.PREFER_JAVADOC, Boolean.valueOf(preferJavadoc));
169
			return element.getClasspathEntry();
173
			return element.getClasspathEntry();
170
		}
174
		}
171
		return null;
175
		return null;
172
	}
176
	}
177
	
178
	private static boolean getPreferAttachedJavadoc(IClasspathEntry entry) {
179
		IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
180
		for (int i= 0; i < extraAttributes.length; i++) {
181
			IClasspathAttribute attrib= extraAttributes[i];
182
			if (IClasspathAttribute.JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME.equals(attrib.getName())) {
183
				return Boolean.valueOf(attrib.getValue()).booleanValue();
184
			}
185
		}
186
		return false;
187
	}
173
188
174
	/**
189
	/**
175
	 * Shows the UI for configuring a variable classpath entry. See {@link IClasspathEntry#CPE_VARIABLE} for
190
	 * Shows the UI for configuring a variable classpath entry. See {@link IClasspathEntry#CPE_VARIABLE} for

Return to bug 178071