FAQ How do I dynamically register an editor to handle a given extension?

From Eclipsepedia

Revision as of 16:26, 14 March 2006 by Claffra (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can’t. Editors, like most other extensions to the platform, must be specified declaratively in the plug-in manifest file. You cannot dynamically install a new editor except by dynamically installing a new plug-in containing the new editor.


The only thing you can currently do programmatically is specify the default editor to use for a given file name or extension. The editor must already be registered with the platform through a plug-in and must already declare that it supports files with that name or extension.

Here is an example snippet that sets the default editor for text files to be the built-in platform text editor:

   IEditorRegistry registry = 
           PlatformUI.getWorkbench().getEditorRegistry();
   registry.setDefaultEditor("*.txt", 
           "org.eclipse.ui.DefaultTextEditor");


See Also:

FAQ_How_do_I_create_my_own_editor?


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.