JDT UI 插件提供了实用程序类 JavaUI,该类允许您使用程序调用 JDT 用户界面。
以下代码片段将打开类型提示对话框:
public IType selectType() throws JavaModelException
{
SelectionDialog dialog=
JavaUI.createTypeDialog(parent,
new ProgressMonitorDialog(parent),
SearchEngine.createWorkspaceScope(),
IJavaElementSearchConstants.CONSIDER_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];
}