How to implement Copy-Paste feature on diagram elements?

I want to implement a copy-paste feature with which we can copy selected diagram elements and paste them in the editor using Ctrl+C and Ctrl+V

1 Like

The basic approach is simple, select a number of elements and clone them, traversing from root to leaf, adding each element into the target element (or a newly created parent).

It gets a bit more complicated if we consider some details

  • copy the businessObject with each diagram element
  • copy connections after elements
  • implement copy / paste rules based on context (active selection)

Element creation is done via ElementFactory and adding elements needs to be performed via our Modeling API. I am not sure if copy/paste is an issue you can quickly implement. Feel free to try it though.

I added a GitHub issue for this as well. We appreciate pull requests :wink:.