JetBrains / MPS-extensions

MPS-extensions aims to ease language development within MPS.
https://jetbrains.github.io/MPS-extensions/
Apache License 2.0
83 stars 52 forks source link

When cloning a model with a graphical editor, layout is not preserved #86

Closed kbirken closed 3 months ago

kbirken commented 6 years ago

From mbeddr.core created by eugenschindler : mbeddr/mbeddr.core#1421

Steps to reproduce: -Make a model with a graphical editor in it -Layout the model manually -Clone the model

Result: the layout in the cloned model is completely lost with respect to the original model

Some ideas: -why is the layout not part of the model contents? is that a conscious choice? -in how far can layout be seen as something with meaning? -is it necessary to force the user to auto-layout or is the layout also seen as something that adds hints to understand the model?

alexanderpann commented 3 months ago

Workaround with MPS 2022.3 and 2023.2.2 based on experimental UUIDS assuming we have a diagram BaseDiagram with boxes Box and edges Edge. Node identity support must be enabled in mps.vmoptions: -Dmps.nodeuid=true

Set the ID of the diagram, box, and edge cell to thisNode.get uuid in the inspector of the corresponding diagram cell (you have to import jetbrains.mps.lang.smodel). Create a new plugin solution with the following content:

When cutting and pasting the diagram node, using the action Clone Root, or cloning the model, the layout data will be preserved.

When copying and pasting a new ID will be issued and the layout data won't be preserved.