Good tutorials:
GEF uses Model-View-Controller model:
- Model - Your model clesses extend ModelElement. This includes both the notational model and semantic model (notational model needs to define things like location and size on the screen). The Model can be created using Eclipse EMF.
- View - GEF provides two viewer types: graphical and tree-based.
- The graphical viewer uses figures that paint on an SWT Canvas. Figures are defined in the Draw2D plug-in, which is included as part of GEF.
- The TreeViewer uses an SWT Tree and TreeItems for its view
- Controller - (or EditPart)Responsible both for mapping the model to its view, and for making changes to the model. The EditPart also observes the model, and updates the view to reflect changes in the model's state. EditParts are the objects with which the user interacts
Model
ModelElement extends Java's Object class, adding three features:
- Persistence - Simple model persistence is guaranteed by implementing tag the java.io.Serializable interface together with tag the readObject method. This solution permits one to save the editor's model in a binary format. While it may work for certain applications, it does not provide format portability. In more complex cases, one may implement saving the model in XML or similar format.
- Property change - Model changes are communicated using property change events. The base class allows edit parts to tag register and tag unregister as receivers of property change notifications. Those are posted by calling tag the firePropertyChange method.
- Property source support - In order to aid integration with the Properties view of the workbench, tag the IPropertySource interface is implemented.