/**
* Show a dialog that lists all main types.
*/
protected void handleSearchButtonSelected() {
IJavaProject javaProject = getJavaProject();
IJavaSearchScope searchScope = null;
if ((javaProject == null) || !javaProject.exists()) {
searchScope = SearchEngine.createWorkspaceScope();
} else {
searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject}, false);
}
int constraints = IJavaElementSearchConstants.CONSIDER_BINARIES;
MainMethodSearchEngine engine = new MainMethodSearchEngine();
IType[] types = null;
try {
types = engine.searchMainMethods(getLaunchConfigurationDialog(), searchScope, constraints);
} catch (InvocationTargetException e) {
setErrorMessage(e.getMessage());
return;
} catch (InterruptedException e) {
setErrorMessage(e.getMessage());
return;
}
SelectionDialog dialog;
try {
dialog = JavaUI.createTypeDialog(
getShell(),
getLaunchConfigurationDialog(),
SearchEngine.createJavaSearchScope(types),
IJavaElementSearchConstants.CONSIDER_CLASSES,
false,
"**");
} catch (JavaModelException e) {
setErrorMessage(e.getMessage());
return;
}
dialog.setTitle("Choose Main Type");
dialog.setMessage("Choose Main Type");
if (dialog.open() == Window.CANCEL) { return; }
Object[] results = dialog.getResult();
if ((results == null) || (results.length < 1)) { return; }
IType type = (IType) results[0];
if (type != null) {
fMainText.setText(type.getFullyQualifiedName());
javaProject = type.getJavaProject();
fProjText.setText(javaProject.getElementName());
}
}