使用程序启动 Java 编辑器

JDT UI 插件提供了实用程序类 JavaUI,该类允许您使用程序调用 JDT 用户界面。

下列代码片段导致 Java 编辑器显示 Java 编译单元的特定成员。

void showMethod(IMember member) {
    ICompilationUnit cu = member.getCompilationUnit();
    IEditorPart javaEditor = JavaUI.openInEditor(cu);
    JavaUI.revealInEditor(javaEditor, member);
}


方法 openInEditorrevealInEditor 还适用于类文件和类文件中包含的成员。

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