Difference between revisions of "EMF/SinglePageEditor"

From Eclipsepedia

< EMF
Jump to: navigation, search
(IEditingDomainProvider)
(IEditingDomainProvider)
 
(One intermediate revision by one user not shown)
Line 70: Line 70:
 
protected AdapterFactoryEditingDomain editingDomain;
 
protected AdapterFactoryEditingDomain editingDomain;
 
</source>
 
</source>
 +
 +
The interface IEditingDomainProvider define the following methode.
 +
 +
<source lang="java">
 +
      /**
 +
* 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;
 +
}
 +
</source>
 +
  
 
Read more about this topics:
 
Read more about this topics:

Latest revision as of 07:02, 4 January 2011

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

[edit] Files

[edit] 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.

[edit] 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/*

[edit] LibraryEditor

[edit] 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

[edit] 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:


to be continued ... :)

[edit] LibraryActionBarContributor

TODO

[edit] Improvements

see the discussion page