Graphical Editing Framework

This is an old revision of this page, as edited by 122.169.10.57 (talk) at 19:27, 1 March 2007 (GEF Design patterns frequently). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Just a quick writeup, please review

Graphical Editing Framework (GEF) is a framework that was developed for the Eclipse platform. It is known as a framework with a very steep learning curve, but it offers some benefits.

GEF consists of the following components

  • draw2d has to be used for the View components
  • Requests/Commands have to be used to edit the model
  • Palette of Tools that are offered to the user

Benefits

  • Having a Graphical Representation and being able to edit it
  • Predefined Tools for Selection, Connection Creation and others.
  • MVC (Model View Controller) Concept

MVC Concept

Model: The model has to be implemented by the user or it exists already in case of a legacy software.

Controller: The EditPart acts as a controller. Usually a GraphicalEditPart is chosen. For each model element, including connections, a specific EditPart has to be implemented. Listeners for the model have to be registered in the function EditPart.activate() and have to be unregistered within EditPart.deactivate(). If a model change is detected the view has to be updated accordingly. The EditPart knows both the model and the view. The view has to be created within .createFigure().

View: For each element within the model, including connections, a View has to be implemented, using draw2d. In order to implement the view, an implementation of IFigure of the draw2d library has to be used.

GEF Design patterns

In addition to MVC, GEF developers/enthusiasts need to have a good under standing of Design Patterns. The most recurring design patterns under GEF are Factory, Chain of responsibility, Command, Observer and State. These patterns are often mandatory under GEF, for instance EditPartFactory implementation. Certain aspects of GEF code can be correlated to these. The jargon(italicized text) is strictly GEF specific.

  • Factory : Creating models from palette, creating editparts and creating figures
  • Observer : Typically a controller (read editpart) listening on Model and View.
  • Chain of Responsibility : To decide which EditPolicy should handle a Request.
  • State pattern: A typical example of which is opening editors for an input model .

Note that the usage of patterns is not restricted to those listed here.

GMF and EMF

The Graphical Modeling Framework offers the ability to create diagrams for Eclipse Modeling Framework models based on GEF.