Une image contenant texte, signe

Description générée automatiquement

Context Pattern Editor – Plugin Tokens

 

Plugin Tokens

Plugin tokens allow the use of Java to provide more complex parsing of a model. When the Context Pattern Editor launches it populates the available Plugin helper list (see below) and makes the helpers available in the Combo box:

 

A screenshot of a computer

Description automatically generated

 

Elements returned by the plugin helper are tokens so you may also apply Constraints and use the Target.

Available Plugin Helpers - Context Pattern Plugin Methods

Creation of plugin helpers is not discussed here but they are added to Rhapsody in the usual way (Jar files, Hep files and so on). To make the helper methods available to the Context Pattern Editor, add Context Pattern Plugin Methods:

A black text on a white background

Description automatically generated

Context Pattern Plugin Methods have the following tags:

·       displayText* : This is the name that is presented in the Context Pattern Editor combo box

·       pluginMethod : The name of the Java plugin method to call*

·       pluginName : The name of the plugin that loads the method (optional – see below)

 

*The displayText tag is optional – if left empty then the name of the Context Pattern Plugin Method is used as the displayed name in the combo box.

 

When the Editor loads, it looks for Context Pattern Plugin Methods in all loaded profiles. To exclude a profile from this list, add its name to the comma separated list in the property below (either at package or project level):

RhapsodyPowerPack.ContextPatternEditor.ExcludeProfilesFromPluginList

To have the Editor look in additional packages, add dependencies stereotyped <<includePluginsFrom>> from the project to the packages containing the methods.

Packages and profiles are searched recursively.

 

Plugin Names

The syntax for plugin methods in context patterns is:

pluginMethod:methodName

For example:

pluginMethod:getIncomingDependencies

An additional syntax allows the name of the plugin to be additionally specified:

pluginMethod:pluginName:methodName

Where pluginName is the named entry from the HEP file that loads it, for example:

 

HEP Entry:

name20=ContextPatternAndTableLayoutFunctions

JavaMainClass20=com.ibm.rhapsody.sowi.RhapsodyPowerPack.ContextPatternAndTableLayoutFunctions.ContextPatternAndTableLayoutFunctions_Launcher

JavaClassPath20=.\helpers\RhapsodyPowerpackPlugin.jar

isPlugin20=1

 

Context Pattern Syntax:

pluginMethod:ContextPatternAndTableLayoutFunctions:getIncomingDependencies

 

There are two advantages to specifying the plugin:

·       If there are multiple plugins that load public functions with the same name you can be specific about which ones to load

·       Since Rhapsody does not have to search all its loaded plugins for the public method it runs much faster.

 

Sample Model

 

The sample model (Samples/ContextPatternEditor) includes an example of using custom plugin functions. The sample contains:

·       A table layout with a pattern that uses a custom function to show operations of call operations on activity diagrams.

·       A profile that defines a Context Pattern Plugin Method and a HEP file to load the functions .

·       An Eclipse project that builds the custom function(s).

 

Table Layout with Context Pattern

 

A screenshot of a computer program

Description automatically generated

Profile with Context Pattern Plugin Method

A computer screen shot of a computer code

Description automatically generated

HEP File to Load the Functions

A screenshot of a computer

Description automatically generated

Location of Eclipse Project