Chapter 8. Editors


Editors are the primary mechanism for users to create and modify resources (e.g., files). Eclipse provides some basic editors such as text and Java source editors, along with some more complex multipage editors such as the plug-in manifest editor. Products that need to present their own editors can use the same extension points used by the built-in Eclipse editors. This chapter discusses creating a new Properties editor, hooking up actions to it, and linking the editor to the Outline view.

Editors must implement the org.eclipse.ui.IEditorPart interface. Typically, views are subclasses of org.eclipse.ui.part.EditorPart and thus indirectly subclasses of org.eclipse.ui.part.WorkbenchPart, inheriting much of the behavior needed to implement the IEditorPart interface (see Figure 8-1).

Figure 8-1. EditorPart classes.


Editors are contained in an org.eclipse.ui.IEditorSite, which in turn is contained in an org.eclipse.ui.IWorkbenchPage. In the spirit of lazy initialization, IWorkbenchPage holds on to instances of org.eclipse.ui.IEditorReference rather than the editor itself so that editors can be enumerated and referenced without actually loading the plug-in defining the editor.

Editors share a common set of behaviors with views via the org.eclipse.ui.part.WorkbenchPart superclass and org.eclipse.ui. IWorkbenchPart interface, but have some very important differences. Editors follow the classic open-modify-save paradigm, whereas any action performed in a view should immediately affect the state of the workspace and underlying resource(s).

Editors appear in one area of Eclipse, while views are arranged around the outside of the editor area. Editors are typically resource-based, while views can show information about one resource, multiple resources, or even something totally unrelated to resources such as available memory, network status, or builder errors.



Eclipse(c) Building Commercial-Quality Plug-ins
Eclipse: Building Commercial-Quality Plug-ins (2nd Edition)
ISBN: 032142672X
EAN: 2147483647
Year: 2004
Pages: 200

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net