在UI上的展现可能是这样的:
核心是JavaUI类的使用了,直接上代码:
public IType selectType() throws JavaModelException {
Shell parent = window.getShell();
SelectionDialog dialog= JavaUI.createTypeDialog(
parent, new ProgressMonitorDialog(parent),
SearchEngine.createWorkspaceScope(),
IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false);
dialog.setTitle("My Dialog Title");
dialog.setMessage("My Dialog Message");
if (dialog.open() == IDialogConstants.CANCEL_ID)
return null;
Object[] types= dialog.getResult();
if (types == null || types.length == 0)
return null;
return (IType)types[0];
}