Tutorial

Create a Hello World module

tutorials

In this tutorial we will create a very simple module for Modelio. This basic module will allow to:

  • create a Model Element with a custom Stereotype
  • create a custom diagram
  • execute a contextual command

Please note that this tutorial has been done with Modelio 3.1 and Eclipse Juno (4.2). The procedure should be compatible with Modelio 3.x versions. Some differences/specificities can appear depending on the Modelio version. We will indicate them if necessary.

Prerequisites

Modules are written in Java so you must know this language. Some knowledge about the Maven software project management tool is recommended but not essential.

In order to help you developing a module easily, It is preferable to use the Eclipse IDE (or any Java IDE supporting Maven).

For Modelio 3.1/3.2

The JDK7 is required to package Modelio 3.1/3.2 modules.

For Modelio 3.3

For packaging Modelio 3.3 modules, the JDK8 is required. It is recommended to use Eclipse 4.4 (Luna) as it should have the right configuration to work with the JDK8. We tested successfully the module 3.3 packaging with this tool.

Set up the Development Environment

We will work with the Eclipse tool for code editing, packaging and debugging. You can use other Java IDE like Netbeans as long as they can use Maven. Nevertheless they probably require adaptations of the provided template and described procedures which are beyond the scope of this tutorial.

This tutorial has been made with Eclipse Juno (4.2).

Installation of Maven plugin

Actually the plugin providing Maven integration in Eclipse is called m2eclipse.
Start Eclipse and go to Help/Install New Software...

In the "Work with" field, enter this link: http://download.eclipse.org/technology/m2e/releases and check the options as shown on the following screenshot.

install-maven

Click Next to view Installation Details then click Next again to the license terms and click Finish.

Create new Maven project in Eclipse

Create a Maven Project based on the modelio-module-archetype Archetype

  • Launch Eclipse
  • Select File/New/Project...,
  • Select Maven Project
  • Register the modelio public repository as a new Remote Repository.
    On the Select an Archetype step window, click on the Configure... button the click on the Add Remote Catalog... button and enter the following Catalog File: http://repository.modelio.org/archetype-catalog.xml (You can enter Modelio repository as Description).
    maven-archetype-project
  • Select modelio-module-archetype Archetype then click on Next. Please note that the Artifact version gives an indication about the Modelio target version (3.1.0.01 for Modelio 3.1, 3.3.0.01 for Modelio 3.3, ...).
    new-maven-project
  • Specify the Archetype parameters
    maven-archetype-parameters
    On the Artifact Id field, please enter a name with lowercase letters and without extra symbols (no spaces, no comma, no star, ...). For the moduleName, please enter a value without extra symbols (you can use uppercase and lowercase letters) as it will be used for naming some classes.

Create the Modelio module

We are now almost ready to create our Hello World module!

We will give a new label to our module. Go to the module.properties file (See the followiing screenshot).

change-module-label

Change the ModuleLabel value in the module.properties file. By default, the module provides English and French language support so if you consider to also provides French support you should change the ModuleLabel value in the module_fr.properties file.

If you would like support other languages, you should add module_{Language shortcode}.properties file in the src/main/conf directory and messages_{Language shortcode }.properties in the src/main/resources/org/modelio/helloworld/i18n directory. The {Language shortcode} should be replaced by a two-letter code (following the ISO 639-1 norm [See list of codes]) .

Now we are ready to package the HelloWorld module. Packaging the module is the operation that produces a deployable jmdac file.

Select the pom.xml file at the root of the project. On the contextual menu (right-click), select Run As/Maven install. The resulting HelloWorld_xx.yy.zzz.jmdac file is in the target directory.

maven-package-module

Deploy the module in Modelio

You can now deploy it in Modelio. Start Modelio, launch Configuration/Modules catalog... and add your module to the catalog.

Open an existing project or create a new one. Install your module on the project (See how to manage modules: http://forge.modelio.org/projects/modelio3-usermanual-english-300/wiki/Modeler-_modeler_managing_projects_configuring_project_modules).

module-shown-modelio

Use the module commands

Right-click on any model element in the UML explorer. You will see that the HelloWorld module commands have been added to the popup menu.

module-contextual-menu

  • The Contextual Command Example opens a messagebox with the name of the current element.
  • The Element Creation Example creates a Class stereotyped <<Stereotype 1>>.
  • The Diagram Creation Example creates a diagram stereotyped <<Stereotype 2>> which allows to create a Class stereotyped <<Stereotype 1>>.

Useful links

 

^ Back to Top