Programmatically launching a Java editor

The JDT UI plug-in provides a utility class, JavaUI, which allows you to programmatically invoke the JDT user interface.

The following snippet causes a Java editor to show a specific member of a Java compilation unit.

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


The methods openInEditor and revealInEditor also work for class files and for members contained in class files.

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