In previous versions of the DSL Tools, the copy/cut/paste of model elements did not work very well. There were limitations, and even bugs that prevented very elaborate scenarios. In case you are interested, you can have to the posts on the forum describing these problems, and the pain there was in this area. Some people in the community were successful on some models (See for instance Pascal Recchia and Anthony Guérot’s article on toolbox prototypes, which uses the copy/paste mechanism: http://netfxfactory.org/blogs/papers/archive/2008/06/25/snip-your-dsl-into-prototypes.aspx), but the feature needed reworking and this is what we had done.
From the VS2010 DSL SDK, the copy/paste as an image is available to all the new designers, and it’s easy to provide the feature for existing migrated designers.
The DSL user will be able to copy model elements, compartments items, or anything that the DSL Author thought about, or cut them, and paste them in a compatible shape, in the same, or in different designers. and this in a very natural way.
If you create a new graphical designer, you don’t need to do anything, the copy/paste is enabled by default.
If you migrate an existing designer, you can benefit from this new feature very simply:
More concretely. Let’s take the example of a class diagram unfolded form a Class diagram DSL template. The following screen shot shows a portion of the domain model (Class has attributes), and you can see that being an embedding, by default, Propagates Copy is set for the Attributes role to Propagates Copy To Link And Opposite Role Player.
What this means is each time you copy a ModelClass, you’ll copy its attributes at the same time, which is, really what most people expect.
Now let’s go a bit further, and change the behavior a bit. Let’s assume we have a base class Moveable, and copy the derived class (Plane), and paste it on the diagram. By default, you end up with a new class (Plane1) whose attributes and methods were cloned:
Now let’s assume that, as a DSL author, I want, each time we copy and paste a class (such as Plane), the inheritance, if any, to be copied as well (thus keeping the link with the base class):
To achieve this I need to:
Now, when the designer user copies the class “Plane”, he gets a clone, with the inheritance relationship still linking to the same base class … just what I wanted.