import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
/**
* Shows the UI for configuring a javadoc location attribute of the classpath entry. null
is returned
* if the user cancels the dialog. The dialog does not apply any changes.
*
* @param shell The parent shell for the dialog.
* @param initialEntry The entry to edit. The kind of the classpath entry must be either
* IClasspathEntry.CPE_LIBRARY
or IClasspathEntry.CPE_VARIABLE
.
* @return Returns the resulting classpath entry containing a potentially modified javadoc location attribute
* The resulting entry can be used to replace the original entry on the classpath.
* Note that the dialog does not make any changes on the passed entry nor on the classpath that
* contains it.
*
* @since 3.1
*/
public static IClasspathEntry configureJavadocLocation(Shell shell, IClasspathEntry initialEntry) {
if (initialEntry == null) {
throw new IllegalArgumentException();
}
int entryKind= initialEntry.getEntryKind();
if (entryKind != IClasspathEntry.CPE_LIBRARY && entryKind != IClasspathEntry.CPE_VARIABLE) {
throw new IllegalArgumentException();
}
URL location= JavaUI.getLibraryJavadocLocation(initialEntry);
JavadocLocationDialog dialog= new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location);
if (dialog.open() == Window.OK) {
CPListElement element= CPListElement.createFromExisting(initialEntry, null);
URL res= dialog.getResult();
element.setAttribute(CPListElement.JAVADOC, res != null ? res.toExternalForm() : null);
return element.getClasspathEntry();
}
return null;
}