Creating module stereotypes

Stereotypes belong to a profile, therefore you should declare one as described above prior to create a stereotype.

JUnit Module specifications identify three stereotypes:

  • <<JUnit>> that is used to stereotype test classes that are created by the JUnit Module.
  • <<JUnitDependency>> that is used to stereotype dependency links that are established by the JUnit Module between the test classes and the model class they are testing.
  • <<JUnitDiagram>> that is used to stereotype test diagrams that are created by the JUnit Module.

Stereotypes declaration

Stereotypes are declared in module.xml file. Edit the template module xml file and edit the prepared fields.

 1 <Profiles>
 2    <Profile uid="" id="JUnitProfile">
 3        <Stereotype uid="" name="JUnit" label="JUnit" metaclass="Class" is-hidden="false">
 4            <Icon path="" />
 5            <Image path="" />
 6        </Stereotype>
 7        <Stereotype uid="" name="JUnitDependency" label="JUnitDependency" metaclass="Dependency" is-hidden="false">
 8            <Icon path="" />
 9            <Image path="" />
10        </Stereotype>
11        <Stereotype uid="" name="JUnitDiagram" label="JUnitDiagram" metaclass="ClassDiagram" is-hidden="false">
12            <Icon path="" />
13            <Image path="" />
14        </Stereotype>
15...
16    </Profile>
17 </Profiles>
  • uid value is a unique identifier. It is very important that the value shouldn’t be copied from another object (don’t copy the id from the example), nor modified after module delivery. If you are using a Maven project, this identifier is automatically generated during the module packaging.
  • name value is the name of the stereotype.
  • label value is the name of the stereotype that will appear in Modelio gui and diagrams. It follows the standard mechanism of resource management : if it begins with % then it is a resource label that will be retrieved in the manifest property file (module*.properties).
  • is-hidden value indicates whether or not the stereotype should be displayed in Modelio when manually setting/unsetting stereotypes.

Adding icons to a stereotype

Looking at the stereotype declarations in the previous file excerpt, we can see that stereotypes can be associated with two icons :

  • Icon is used to represent the stereotyped element in the explorer pane (provided the stereotype is the first on the element)
  • Image is used to replace the element standard representation when an image representation is preferred on diagram.

Explorer icons should have a size of size 16x16 px. Diagram image can be of any size but a base of 32x32 px is a good average. The recommended format is PNG which allows transparency.

Icon files should be stored in src/main/conf/res/icons ; src/main/conf directory is mandatory, res/icons is a convention. We can know complete the declaration of JUnit stereotype to add it the following icon : .

1...
2    <Icon path="res/icons/junitClass16.png" />
3    <Image path="" />
4...

Specifying annotation available with a stereotype

Stereotypes can also declare tag types, note types and extern document types:

 1...
 2      <ExternDocumentTypes>
 3         <ExternDocumentType uid=""  name="A"  label=""  is-hidden="false"/>
 4      </ExternDocumentTypes>
 5
 6      <NoteTypes>
 7         <NoteType uid=""  name="B"  label=""  is-hidden="false" />
 8      </NoteTypes>
 9
10      <TagTypes>
11         <TagType uid=""  name="C"  label=""  is-hidden="false" parameter-card="1"/>
12      </TagTypes>
13...
  • uid value is a unique identifier. It is very important that the value shouldn’t be copied from another object (don’t copy the id from the example), nor modified after module delivery. If you are using a Maven project, this identifier is automatically generated during the module packaging.
  • name value is the name of the type.
  • label value is the name of the type that will appear in Modelio gui and diagrams. It follows the standard mechanism of resource management : if it begins with % then it is a resource label that will be retrieved in the manifest property file (module*.properties).
  • is-hidden value indicates wheter or not the type should be displayed in Modelio when manually editing them (e.g. when adding a Note).
  • parameter-card value is the maximum number of TagParameter a TaggedValue having a specific TagType should have.

<< Previous Index Next >>

junitClass16.png (546 Bytes) admin admin, 13 July 2017 16:48