Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

FAQ How do I create my own editor?

All editors start by making a subclass of EditorPart from the org.eclipse.ui.part package. At this basic level, editors are very generic. They take an input object that implements IEditorInput, they know how to draw themselves by implementing the createPartControl method, and they may know how to respond to a request to save their contents. To create a bare-bones editor, you have to implement only a small handful of methods. Figure 11.1 shows a working editor that displays a simple label.

    <img src=../images/minimal_editor.png>

    Figure 11.1   A minimal editor

Some required methods, declared abstract in EditorPart, have been omitted from this snippet, but the editor will work if their implementations are empty:

   public class MinimalEditor extends EditorPart {
      private Label contents;
      public void createPartControl(Composite parent) {
         contents = new Label(parent, SWT.NONE);
         contents.setText("Minimal Editor");
      public void init(IEditorSite site, IEditorInput input) {
      public void setFocus() {
         if (contents != null)

The plug-in manifest entry for defining this editor is as follows:

      name="Minimal Editor"

The extensions attribute describes what file types this editor will automatically be associated with. In this case, the editor will be associated with files ending in min. An editor can instead be associated with a particular file name by replacing the extensions attribute with a filenames attribute. Either of these attributes can specify a comma-separated list for associating an editor with multiple file name extensions and/or file names. A user can always choose to associate an editor with a different file name or extension from the Workbench > File Associations preference page.

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