创建特定于 Java 的提示对话框

以下代码片段使用 JavaUI 类来打开“打开类型”对话框:

    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];
    }

JavaUI 提供了附加方法来创建“打开包”和“打开主要类型”对话框。

Copyright IBM Corporation and others 2000, 2003. All Rights Reserved.