Eclipse“开放类型”对话框限于特定的界面 [英] Eclipse "Open Type" dialog restricted to a particular interface
本文介绍了Eclipse“开放类型”对话框限于特定的界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个JavaUI.createTypeDialog(),它限制用户仅选择属于特定接口的类型。我该怎么做?
I'm trying to create a JavaUI.createTypeDialog() which restricts the user to selecting only types belonging to a particular interface. How could I do this?
推荐答案
此答案显示了如何获取特定类型的类型层次结构。您可以使用类似的处理来获取接口的TypeHierarchy,然后使用结果类型填充列表。
This answer shows how to obtain the type hierarchy for a particular type. You could use similar processing to obtain the TypeHierarchy for the interface, then populate the list with the resultant types.
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
...
这篇关于Eclipse“开放类型”对话框限于特定的界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文