While many GEF applications use connections (Connection), there are applications that do not need to be connected to express relationships, and the project we are currently working on is one such example. In such applications, the relationship between model objects is mainly expressed by the inclusion of graphs, so most of them are one-to-many relationships.
Figure 1 GEF applications that do not use connections
First of all, a brief description of our project, the project needs a graphical model editor, the main function is in a table with three rows n columns to add/remove nodes, nodes can be dragged between different cells, you can merge adjacent nodes, table columns can be added or subtracted, drag and so on. Since the tables provided by Swt/jface are difficult to implement, we have chosen to use GEF development, and it seems to be working well (see figure below), and here is a brief introduction to some of the problems associated with graphics and layout during implementation.
Before you start, consider the structure of the model. Since draw2d only provides very limited layout, such as Toolbarlayout, FlowLayout and Xylayout, and does not have a gridlayout, the entire table cannot be used as a editpart, Instead, you should think of each column as a editpart (because there are more operations on the column than the row, so you don't use the row as Editpart) to implement the drag of the column. In addition, as can be seen from the requirements, each node is contained in a column, but a closer look will find that the node is not directly contained in the column, but rather that there is a single Cell object as the middle bridge, that is, each column contains a fixed three cells, each cell can contain any node. Through the above analysis, our model, editpart and figure should have been preliminarily formed, see the following table:
  |
model |
editpart |
figure |
canvas |
diagram |
diagrampart |
columns |
column |
columnpart |
columnfigure |
cell |
c Ell |
cellfigure |
node |
node |
nodepart |
nodefigure |
The top to bottom of a table is a relationship, which is a one-to-many relationship, and the following illustration shows these relationships in simple terms:
Figure 2 Graph contains diagram