Eclipse“Open Type”对话框仅限于特定接口

我正在尝试创建一个JavaUI.createTypeDialog(),它限制用户只选择属于特定接口的类型。 我怎么能这样做?

此答案显示如何获取特定类型的类型层次结构。 您可以使用类似的处理来获取接口的TypeHierarchy,然后使用结果类型填充列表。

IProject project; //currently selected project //get the java project and locate the interface type JavaProject javaProject = JavaCore.create(project); IType myInterface = javaProject.findType("MyInterface","name.seller.rich"); //get the sub types from the interface's type hierarchy ITypeHierarchy hierarchy = myInterface .newTypeHierarchy(new NullProgressMonitor()); IType[] subTypes = hierarchy.getAllSubtypes(myInterface ); //do something with the sub types ...