1

ユーザーが特定のインターフェースに属するタイプのみを選択するように制限するJavaUI.createTypeDialog()を作成しようとしています。どうすればこれを行うことができますか?

4

1 に答える 1

2

この回答は、特定の型の型階層を取得する方法を示しています。同様の処理を使用してインターフェイスの 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
...
于 2009-09-25T14:27:02.673 に答える