Difference between revisions of "EMF/SinglePageEditor"

From Eclipsepedia

< EMF
Jump to: navigation, search
(IEditingDomainProvider)
 
(20 intermediate revisions by one user not shown)
Line 1: Line 1:
This page gives you an overview of a unmodified generated EMF (single page) editor (inc. a wizard).  
+
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 [http://help.eclipse.org/helios/topic/org.eclipse.emf.doc/tutorials/clibmod/clibmod.htm Generating an EMF Model]
+
The example is created based on the [http://help.eclipse.org/helios/topic/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html Generating an EMF Model] example. You can find the source code and in this context the "library.editor" plugin / project e.g. [http://code.google.com/a/eclipselabs.org/p/emf-examples/source/browse/ here].
  
You can find the source code e.g. [http://code.google.com/a/eclipselabs.org/p/emf-examples/source/browse/ here] and in this context the "library.editor" plugin / project.
+
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.
  
= Files  =
+
= 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/*
  
 
[[Category:Modeling]] [[Category:EMF]]
 
[[Category:Modeling]] [[Category:EMF]]
 +
 +
= LibraryEditor  =
 +
 +
== Class definition  ==
 +
 +
The generated file has the following class definition:
 +
 +
<source lang="java">
 +
/**
 +
* 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 {
 +
 +
</source>
 +
 +
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.
 +
 +
<source lang="java">
 +
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;
 +
</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:
 +
* 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 ...&nbsp;:)
 +
 +
= LibraryActionBarContributor =
 +
 +
TODO
 +
 +
= Improvements =
 +
 +
see the [[Talk:EMF/SinglePageEditor | discussion page]]

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