Skip to main content
Jump to: navigation, search

Java Code Generation Developer Guide

Overview

Papyrus provides an extra plugin named org.eclipse.papyrus.java.generator which allow to generate java source code from papyrus uml diagram. It is divided in 4 projects:

  • metamodel.jdt : provides a metamodel corresponding to jdt eclipse implementation. it Allows to parse uml diagram efficiently,
  • jdtsynchronizer : run the generation command (see RunGenerator.java),
  • transfo.jdt : allows to create a jdt model from papyrus uml model. Uses QVTO transformations,
  • ui : the user interface of this plugin.

Dependencies

The following schema show dependencies between java code generation plugins:

JavaGenerationDependenciesDiagram.png

Plugins Development

This is an overview of each project for this extraplugin. This part explain how the plugin is decomposed, and few key points for each of these projects.

metamodel.jdt

jdt metamodel

The metamodel.jdt project provides a metamodel, named jdtmm, corresponding to jdt eclipse implementation. Please see Eclipse JDT for more details. metamodel.jdt sources are directly generated using this metamodel. In particular, sources provides Factory and Visitor pattern to cross any model. Note that metamodel.jdt.edit, metamodel.jdt.editor and metamodel.jdt.tests are also generated.

generatorOptions metamodel

metamodel.jdt also provides a metamodel to change options. For now, it just integrate the source folder name, but it can easily been improved to contain other options data. Purpose is to give user options to umltojdt transformation.

umltojdt

The umltojdt project provides a qvto script to transform a papyrus uml diagram to a jdt model. it directly uses model instances of jdtmm et optionsmm.

jdtsynchronizer

The jdtsynchronizer project is the launcher of the main project of this plugin, as it run a transformation, by calling RunGenerator.runGeneration().

  • Find selected objects to generate into papyrus diagram,
  • Create a model with there informations,
  • Run the generation transformation,
  • Add result into papyrus diagram.

For this last action, jdtsynchronizer just cross transformed jdt model by using several visitor pattern:

JavaGenerationVisitorPattern.png

ui

The ui project provides Eclipse user interface for the entire plugin. It is divided in two parts:

  • GenerateJavaCodeHandler, which call the generation command when called.
  • plugin.xml, which contains buttons, pop menu … .

Each component call the GenerateJavaCodeHandler when pressed. Morehover, there components are only available when selected resource is generable, according to xml « when » condition.

Class Diagram

The following is a class diagram of this plugin. While it don't show every classes of the project, it offer a good overview of main classes.

JavaGenerationClassDiagram.png

Back to the top