Editparts and figures

GEF employs a model-view-controller architecture as illustrated in figure 4.7. The model layer has the role of the model that provides all data to display it in the view with the help of the controller. That part is delivered by GEF which also provides interaction with the user. To use GEF and its architecture some conditions have to be accomplished.

Figure 4.7: Model-view-controller.
Image mvc

First of all, you need editparts. Editparts present an intermediate layer between the model and the figures, that finally display and layout the diagrams. Each model element has a corresponding editpart and figure. Editparts are responsible for creating and deleting figures, as well as adapting them when the model changes. They are created with the help of PartFactory which constructs the correct editpart for a given model element.

Editparts derive from the IPropertyListener interface and add themselves as listeners of their corresponding model element. Thus, they get called when changes in the model occur and can propagate them to the figures.

Another requirement is that so-called edit policies are defined by the editparts. They are used as a reaction on requests from the user, e.g. to create a new element or to reconnect a connection. The policies also serve to fix the layout of the view, as well as its behaviour. Behavioral edit policies describe for example which editparts can be used as container for others, and between which editparts connections can exist. Several edit policies build and execute commands that are defined in the model. Their execution changes the model which again may cause an adaption of the view.

Figure 4.8: Class diagram of the editparts and figures.
Image overview_parts_figures

Figures are the third condition for the use of GEF. They build the lowest layer of the Jupe architecture. They are based on Draw2D. Created and controlled by the editparts, they simply draw the diagrams. The figures also form a composite structure with ClassDiagramFigure as root element.

Michael Pradel 2006-06-01