Une image contenant texte, signe

Description générée automatiquement

Create Model Elements from Copy Buffer

 

Overview

This helper automates the process of creating model elements by allowing the user to copy plain text from any application and create new model elements based on that text.

 

Applicable To

Table Layout, Table View

Menu Entry

Power Pack Create Model Elements from Copy Buffer

Demonstration

Watch the Video

 

The helper first checks where to create new model elements. If the selection is a table layout, then the owning package is used. If the selection is a table view, then the scope of the table view is checked – if that is a single package then that package is used, otherwise the owner of the table view is used.

 

Next the helper checks what type of model element to create. The table layout (either the selected one or the layout of the selected table) should have a single model element type as its criteria – if not then an error is thrown.    

 

Lastly the helper takes every line of text in the copy buffer and attempts to create a new model element from it (providing there is not already a model element with that name). The following properties may be used to configure the creation (they may be set at package or project level):

A screenshot of a computer

Description automatically generated

Creating Valid Names

In order to create valid names for the new model elements, the helper first checks the type of element to create against the property below:

RhapsodyPowerPack.ImportFromCopyBuffer.NonExecutableElements

Non-executable elements are those that Rhapsody by default allows spaces and (some) special characters in their names, for example Rhapsody will not allow a Block to be named 1. Introduction but it will allow a Use Case with that name. To use the helper on your own new term names you need to add them to this property if you want them to use the non-executable patterns (see below).

 

Based on the above property, one the two following properties is then selected:

RhapsodyPowerPack.ImportFromCopyBuffer.IllegalCharacterRegexExecutable

RhapsodyPowerPack.ImportFromCopyBuffer.IllegalCharacterRegexNonExecutable

 

Both properties behave in the same way; they both define a series of regular expression patterns (one on each line of the multi-line property) that the helper will run on the imported line of text before attempting to use it as a name.

 

The default patterns for executable items are:

 

Pattern

Purpose

^[0-9.]+

Strips off any number-dot sequence at the start of the text (such as those found in a table of contents or headings)

(?<!\d)\.+\s*\d+$

Strips off any trailing dots followed by white space/numbers – such as those found at the end of a table of contents entry.

[\\.\\(\\)&,\\-;:\\s\\t\?']

Finds any illegal characters in the remaining string including white spaces, tabs and characters such as ; and -

 

The default patterns for non-executable items are:

 

Pattern

Purpose

^[0-9.]+

Strips off any number-dot sequence at the start of the text (such as those found in a table of contents or headings)

(?<!\d)\.+\s*\d+$

Strips off any trailing dots followed by white space/numbers – such as those found at the end of a table of contents entry.

[\\(\\)&,;:\\t\?']

Finds any illegal characters in the remaining string including tabs and characters such as ; and :

 

Text matched by the pattern(s) is then removed / replaced according to the following properties:

RhapsodyPowerPack.ImportFromCopyBuffer.IllegalCharacterAction

RhapsodyPowerPack.ImportFromCopyBuffer.IllegalCharacterReplacementText