Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "FAQ How do I open an editor programmatically?"

 
m
Line 1: Line 1:
Use the <tt>openEditor</tt> methods on <tt>org.eclipse.ui.IWorkbenchPage</tt> to
+
Use the <tt>openEditor</tt> methods on <tt>org.eclipse.ui.IWorkbenchPage</tt> to open an editor on a given input. The <tt>openEditor</tt> methods require you to supply the ID of the editor to open.  You can use the editor registry to find out what editor ID is appropriate for a given file name, using the <tt>getDefaultEditor</tt> method on <tt>IEditorRegistry</tt>. In Eclipse 3.0, the editor opening methods that were specific to <tt>IFile</tt> were moved to the <tt>IDE</tt> class.
open an editor on a given input. The <tt>openEditor</tt> methods  
+
require you to supply the ID of the editor to open.  You can use the editor
+
registry to find out what editor ID is appropriate for a given file name,  
+
using the <tt>getDefaultEditor</tt> method on <tt>IEditorRegistry</tt>.  
+
In Eclipse 3.0, the editor opening methods that were specific to  
+
<tt>IFile</tt> were moved to the <tt>IDE</tt> class.
+
  
 
<pre>
 
<pre>
Line 18: Line 12:
  
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ Is Eclipse 3.0 going to break all of my old plug-ins?]]
 +
*[[FAQ How do I find the active workbench page?]]
 +
*[[FAQ How do I open an editor on a file in the workspace?]]
  
[[FAQ_Is_Eclipse_3.0_going_to_break_all_of_my_old_plug-ins%3F]]
+
{{Template:FAQ_Tagline}}
 
+
[[FAQ_How_do_I_find_the_active_workbench_page%3F]]
+
 
+
[[FAQ_How_do_I_open_an_editor_on_a_file_in_the_workspace%3F]]
+
 
+
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+

Revision as of 20:05, 29 May 2006

Use the openEditor methods on org.eclipse.ui.IWorkbenchPage to open an editor on a given input. The openEditor methods require you to supply the ID of the editor to open. You can use the editor registry to find out what editor ID is appropriate for a given file name, using the getDefaultEditor method on IEditorRegistry. In Eclipse 3.0, the editor opening methods that were specific to IFile were moved to the IDE class.

   IWorkbenchPage page = ...;
   IFile file = ...;
   IEditorDescriptor desc = PlatformUI.getWorkbench().
      getEditorRegistry().getDefaultEditor(file.getName());
   page.openEditor(
      new FileEditorInput(file),
      desc.getId());

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Back to the top