-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deep copy for packages and diagrams #2475
Conversation
This way `copy()` can focus on copying a single element with mandatory related elements, while `copy_full()` copies whole hierarchies.
Now, if you do a full paste, the whole hierarchy is copied. NB. Diagrams are not populated correctly at this point.
Use model linked to diagram by default.
You can now make a full copy of a diagram (from a diagram) and paste it. This is done by recording the original diagram id(s). When pasting the original diagram ids are mapped to the new diagram. The Presentation paste function does a lookup for the target diagram, which can now also be a newly created diagram.
Place singledispatch functions together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with both class and activity diagrams, copy-paste between models works as expected: creates a copy of all elements as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great upgrade to the copy/paste system, nice one @amolenaar!
@amolenaar / @danyeaw this works great for elements. I noticed that when copying packages, the sub-packages are empty. Also, see how "Existing Package" takes on the name "New Package" in the new model. Not sure what I was expecting, perhaps that ExistingModel becomes a sub package of NewModel. |
In addition, this crash report after closing the above example may be relevant. I closed the new model without saving and then saved the existing model.
|
I couldn't get the crash to happen again. So maybe unrelated. |
Thanks for testing, @mikekidner. I'll have another look at copying to other models. |
It looks like our Hypothesis tests ran into the same issue you experienced: #2536 / https://github.com/gaphor/gaphor/actions/runs/5634866266/job/15265216692. |
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Packages are only copied as is, without content.
Diagrams can be put on a diagram, and they can be copied. However, the contents of the diagram is not copied.
This is especially useful if you copy content between models.
Issue Number: #2422
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Cleaned up the copy and paste interfaces.
Copying is now done via the
copy_full()
function. This function copies the elements, and their owned elements.NB. Copying is still supposed to happen from diagram to diagram. You cannot copy content in the model browser. This is something we can support in the future, but I deliberately kept it out of scope for this feature.