As an Enterprise Architect user, you may have had the need to apply several times more or less the same set of elements on a given diagram, leading to numerous uses of copy and paste as new.
The "copy and paste" feature on a selection of elements, including their associations and layout works ok, but there could be a more suitable way to go about this. Given a context where we have our set of elements i.e. a pattern of modelling elements available from one or several diagrams within our model, we need to apply them several times onto a new diagram. Once the new diagram is created, the elements that need to be duplicated aren't available from this blank diagram. Hence the diagram that contains those elements has got to be opened first, followed by a selection on the elements of interest, copied to the clipboard (Ctrl+C). Then the newly created diagram needs to be displayed again so the paste as new command can be executed (Ctrl+Maj/Shift+V). We also need to ensure that any specific element or information, e.g. an activity description or a child composite diagram and its sub-elements, mustn't be re-used, hence they need to be deleted.
Enterprise Architect makes it possible to re-use a set of elements, their associations, any notes, and their layout on the diagram by creating UML patterns. Similarly to the use of design patterns (GoF), the aim is to define a set of elements that can be applied for modelling purposes.
In the following example, a test case has been represented by modelling each step to follow as a node within a UML activity diagram, e.g. : pre-conditions / initial context, expected result, test result (OK/KO).
We can abstract these elements to be represented as re-usable steps, shown here :
Once our pattern is defined in a standard diagram, such as the UML activity diagram above, we can save it into an Enterprise Architect UML pattern : open the Diagram menu > Advanced > Save UML Pattern, and save into a new XML file (e.g. C:\basic tests patterns.xml). Enable the "Merge" option if you need in some cases to merge a given activity (or another node) from your pattern with an existing activity from the target diagram (active diagram).
To import and have this pattern available from an EA project, open the Resources view (use the Project menu > Resources if this view is not displayed on your EA client), and right click onto UML patterns, choose "Import UML pattern", and browse to the UML pattern's XML file.
Your UML pattern is now available to use on your Enterprise Architect project ; it should be displayed within the list of UML Patterns. Simply drag and drop this pattern onto the current diagram to create a new test step with expected and test results, as defined in this UML pattern. This window lets you rename each element before it is created.
Of course UML patterns can be applied from any type of diagram (UML class, UML state machine, BPMN, SysML BDD, etc.) or model (analysis, design, tests, architecture, etc.).