다음 스니펫은 JavaUI 클래스를 사용하여 유형 열기 대화 상자를 엽니다.
public IType selectType() throws JavaModelException {
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];
}
JavaUI는 패키지 열기 및 기본 유형 열기 대화 상자를 작성하기 위한 추가 메소드를 제공합니다.