Chapter 12. Developing a Plug-in: Creating Editors and Views

In this chapter, we’re going to create custom editors and views in plug-ins. Plug-in development is a huge topic by itself, and it can take dozens of files to create a commercial plug-in. Fortunately, the Eclipse PDE comes with a number of wizards that will write up the plug-in’s code framework for you, saving significant time. We’ll see how to use those wizards in this chapter, rewriting the code they generate to make the plug-in do what we want.

Creating a Multi-Page Editor

The first example in this chapter is going to create a multi-page editor associated with the file extension we’re going to specify: .xyz. When the user double-clicks a file with that extension in the Package Explorer, Eclipse will use our editor to open and edit it. That editor will have two tabs corresponding to its two pages—the default tab will display the text contents of the file, and the Sorted tab will display those contents sorted in alphabetical order. You can create files with the .xyz extension using the New File menu item, but this plug-in example is also going to have a built-in wizard that will create .xyz files for the user and place default text in them.

Creating the Code

To create the code skeleton for this example, select New Project, and in the New project dialog, select Plug-in Development in the left box, Plug-in Project in the right box, and click Next. Give the name of the project as org.eclipsebook.ch12.Ch12_01 in the ...

Get Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.