1
我试图创建一个JavaUI.createTypeDialog(),它限制用户只选择属于特定接口的类型。我怎么能这样做?Eclipse“打开类型”对话框限于特定接口
我试图创建一个JavaUI.createTypeDialog(),它限制用户只选择属于特定接口的类型。我怎么能这样做?Eclipse“打开类型”对话框限于特定接口
This answer显示如何获取特定类型的类型层次结构。您可以使用类似的处理来获取接口的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
...