| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> |
| <html> |
| <head> |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2007. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| <title>Opening a Java editor</title> |
| <link rel="stylesheet" type="text/css" href="../book.css"> |
| </head> |
| <body> |
| <h3>Opening a Java editor</h3> |
| <p>The following snippet shows how <b><a href="../reference/api/org/eclipse/jdt/ui/JavaUI.html"> |
| JavaUI</a></b> can be used to open a Java editor and display a specific member of a |
| Java compilation unit.</p> |
| <pre><font color="#4444cc"> void showMethod(IMember member) throws PartInitException, JavaModelException { |
| ICompilationUnit cu = member.getCompilationUnit(); |
| IEditorPart javaEditor = JavaUI.openInEditor(cu); |
| JavaUI.revealInEditor(javaEditor, (IJavaElement)member); |
| } |
| </font></pre> |
| <p> The methods <code>openInEditor</code> and <code>revealInEditor</code> also |
| work for class files and for members contained in class files. </p> |
| |
| </body> |
| </html> |