EMF/SinglePageEditor
From Eclipsepedia
This page gives you an overview of an unmodified EMF (single page) editor (inc. a wizard) generated with EMF 2.6
The example is created based on the Generating an EMF Model example. You can find the source code and in this context the "library.editor" plugin / project e.g. here.
Usually the example and the default setup of the genmodel produces a multiple page editor. For the generation of a singel page editor you have to set the attribute "Multiple Page Editor" to false. This attribute is on package level, in this case the Library package.
Contents |
Files
Classes
The code generator produces just the following 4 classes:
- LibraryEditor - The editor class itself.
- LibraryActionBarContributor - The ActionBarContributor of the editor.
- LibraryModelWizard - The wizard implementation ( find in File | New | Other... )
- LibraryEditorPlugin - The plugin class. A subclass of EMFPlugin.
Other Files
The related plug-in files files are created be the generator too.
- plugin.xml
- plugin.properties
- build.properties
- META-INF/MANIFEST.MF
- icons/*
LibraryEditor
Class definition
The generated file has the following class definition:
/** * This is an example of a Library model editor. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public class LibraryEditor extends MultiPageEditorPart implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker {
As you can see the Editor is a subclass of EditorPart (in this case MultiPageEditorPart even this is a singe page editor).
- IEditingDomainProvider
- ISelectionProvider - The editor implement the ISelectionProvider interfaces and all the related methodes.
- IMenuListener
- IViewerProvider
- IGotoMarker
IEditingDomainProvider
In EMF / EMF.Edit it is standard to use AdapterFactoryEditingDomain to track the changes in the model.
Therefor the first thing what is defined in the editor is a editingDomain.
public class LibraryEditor extends MultiPageEditorPart implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker { /** * This keeps track of the editing domain that is used to track all changes to the model. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected AdapterFactoryEditingDomain editingDomain;
The interface IEditingDomainProvider define the following methode.
/** * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EditingDomain getEditingDomain() { return editingDomain; }
Read more about this topics:
- http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.emf.doc/references/overview/EMF.Edit.html
- http://my.safaribooksonline.com/book/software-engineering-and-development/ide/9780321331885/emf-overview/ch03
to be continued ... :)
LibraryActionBarContributor
TODO
Improvements
see the discussion page