}
private IJavaProject chooseJavaProject() {
ILabelProvider labelProvider = new JavaElementLabelProvider(
JavaElementLabelProvider.SHOW_DEFAULT);
ElementListSelectionDialog dialog = new ElementListSelectionDialog(
getShell(), labelProvider);
dialog.setTitle("Project Selection");
dialog.setMessage("Select a project to constrain your search.");
try {
dialog.setElements(JavaCore.create(
ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects());
} catch (JavaModelException jme) {
Plugin.logError(jme);
}
IJavaProject javaProject = null;
String projectName = fProjText.getText().trim();
if (projectName.length() > 0) {
javaProject = JavaCore.create(getWorkspaceRoot()).getJavaProject(
projectName);
}
if (javaProject != null) {
dialog.setInitialSelections(new Object[] { javaProject });
}
if (dialog.open() == Window.OK) {
return (IJavaProject) dialog.getFirstResult();
}
return null;
}