Tuesday, September 22, 2015

FXDiagram - Diagram Repair

FXDiagram allows the user to choose which elements appear in a diagram and to arrange them individually. As this usually involves quite a bit of work diagrams can be saved. An obvious challenge is how to deal with model changes that happen after a diagram has been created. So here's a demo of FXDiagram's new feature for diagram repair:



Because in Xtext the EMF model gets partly replaced on model change, element identities usually get lost on change and traditional EMF transaction frameworks are not applicable. This is why there is a reconcile button, allowing the user to choose when it is worth to reconcile the diagram with the model.

In Xtext, elements are usually identified by their name property, while EMF uses URIs. Both schemes have their pros and cons: Names are independent of the element position in the model, but some elements don't have a name, e.g. the transactions in the statemachine example. URIs on the other hand usually refer to a fixed position in a model, which is in many cases to strict – imagine the order of Java class's methods would matter. Therefore FXDiagram uses a mix of both ideas.

To make the diagram repair action undoable, it is essential that the diagram stores all required information for display, independent of whether the source element still exists or not. For this purpose, I added LabelMappings to the mapping API. So if you want to leverage diagram repair for your own diagrams, you have to enhance your XDiagramConfigs. Have a look at the examples to get the idea,

The API changes that were necessary to implement this feature have effect the persistence format. Maybe old diagrams can no longer be loaded. If you have problems migrating old diagrams, let me know.


No comments: