Java Reference
In-Depth Information
Interaction Boundart
Model
Requests
Actions
User Input
Controller
SWT Events
Event Handlers
• Menus
• Toolbars
• Keybindings
Tools
View
Commands
Figure 9-8
GEF MVC overview
The controller aspect of GEF is responsible for updating the view and trans-
lating UI events into requests from which commands are executed on the under-
lying model. Model elements that are visualized have an associated EditPart ,
which act as the controller for the element. EditPart s contain a set of
EditPolicy classes, which provide behavior and handle most of the actual edit-
ing of the model. An EditPart 's lifecycle is managed by an EditPartViewer ,
which provides the EditPart 's view in either graphical or tree format.
9.2.1 EditParts
Although an EditPart forms the controller bridge between the view and the
model, it typically resembles the structure of both hierarchies. This is because the
model's hierarchical structure often is represented on a diagram with nested fig-
ures. This is not always the case; sometimes elements in the model are linked by
connections to sibling figure elements on the canvas. Nevertheless, we end up
with three similar object structures in memory representing the model, view, and
controller.
As mentioned, connections remain a special case in which the model and
view do not form complementary object structures. In the case of connections,
they have EditPart s of their own and are managed by the source and target
EditPart s. A connection's figure is added to a special layer above the primary
layer.
Two kinds of EditPart s exist in GEF: graphical and tree. Graphical
EditParts use Draw2d Figure objects for their view, while TreeEditParts
use SWT TreeItem objects for their view. Both extend from Abstract
EditPart and have the following main responsibilities:
Search WWH ::




Custom Search