Skip to content

Junit_dev_diagram

Antonin Abhervé edited this page Sep 3, 2020 · 1 revision

Creating a customized diagram

In this section we will focus on the creation of a customized diagram with a basic palette for our JUnit module.

A diagram creation can be entirely declared in module.xml.

Diagram declaration

A diagram is declared within the gui section of the module.xml file, along with its tools (i.e. commands in the palette).

 1    <Gui>
 2        ...
 3        <Tools>
 4            <Tool id="CreateJUnit" label="%CreateJUnitLabel" tooltip="%CreateJUnitTooltip" image="">
 5                <Scope-target metaclass="ModelTree"/>
 6                <Handler class="Box">
 7                    <HParameter name="metaclass" value="Class"/>
 8                    <HParameter name="stereotype" value="JUnit"/>
 9                </Handler>
10            </Tool>
11            <Tool id="CreateJUnitDependency" label="%CreateJUnitDependencyLabel" tooltip="%CreateJUnitDependencyTooltip">
12                <Scope-source metaclass="ModelTree"/>
13                <Scope-target metaclass="ModelTree"/>
14                <Handler class="Link">
15                    <HParameter name="metaclass" value="Dependency"/>
16                    <HParameter name="stereotype" value="JUnitDependency"/>
17                </Handler>
18            </Tool>
19        </Tools>
20        ...
21        <Diagrams>
22            <DiagramType base-diagram="ClassDiagram" stereotype="JUnitDiagram">
23                <Palette keepBasePalette="false">
24                    <ToolRef refid="CreateJUnit" group="JUnit"/>
25                    <ToolRef refid="CreateJUnitDependency" group="JUnit"/>
26                    <ToolRef refid="CREATE_PACKAGE" group="Standard"/>
27                    <ToolRef refid="CREATE_CLASS" group="Standard"/>
28                </Palette>
29                <Handler class="StandardCustomizer"/>
30            </DiagramType>
31        </Diagrams>
32        ...
33    </Gui>

tool

  • id: this field defines the logical name of the tool. It will not be shown to the end-user and is only used internally as an identifier;

  • label & tooltip: the name of the tool as shown in Modelio gui and its associated tooltip. When these fields begin with % then it is a resource label that will be retrieved in the manifest property file (module*.properties);

  • image: a 24x24px image that will be displayed on the gui. The image should be stored in resources/…;

tool scope

  • metaclass & stereotype: filter the availability of the tool. It will only be displayed if the selected element types are a direct or indirect heir of metaclass value and have the requested stereotype. metaclass name can be found in [Modelio metamodel user guide][2]. In our case, the metaclass is “Class” because we want to create test cases for classes and it should have been stereotyped JavaClass because there is no point in adding a Junit testcase class to a non Java class.

handler

  • class: value is the name of the Java class that will be called when the tool is invoked. Box, Link and AttachedBox are generic values implemented in Modelio, but it is also possible to specify any class implementing IBoxCommand, ILinkCommand or IAttachedBoxCommand.

diagram type

  • base-diagram: value is the type of diagram to create for our customized diagram. Must extend AbstractDiagram.

  • stereotype: value is stereotype defining our customized diagram is to be used when opening the diagram.

palette

  • keepBasePalette: indicates whether or not to display the standard UML palette. Here, we chose to hide it and display our own tools only.

palette entries

  • refid: indicates which tool should appear in the diagram’s palette. It might be a standard Modelio tool or a custom one (defined in the same module.xml file) In our case we decide to display the CreateJUnit, CreateJUnitDependency custom tools and the CREATE_PACKAGE and CREATE_CLASS standard tools.

  • group: indicates which category the tool should appear in.

At this step of the process, we have a customized diagram for our JUnit module, based on the UML Class diagram.

Later, the only thing to add will be the command to create this diagram, as presented in the creating module commands section.


Clone this wiki locally