以下代码段说明如何使用JavaUI打开Java编辑器以显示Java编译单元的特定成员。
voidshowmethod(Imembermember ) {
icompilationunitcu=member.getcompilationunit (;
ieditorpartjavaeditor=Java ui.open in editor (Cu;
Java ui.revealineditor (Java editor,member );
}
方法openInEditor和revealInEditor也适用于类文件和类文件中包含的成员。
也可以通过以下方式实现:
IJavaElement element=;
boolean activateOnOpen=fEditor!=null? true : open strategy.activateonopen (;
iditorpartpart=editor utility.open in editor (element,activateOnOpen );
if (部件!=nullelementinstanceofijavaelement ) {
JavaUI.revealineditor(part,) IJavaElement (元素);
}