Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Friday, December 17, 2010

Traceability between an EMF Java model and the corresponding source code

MoDisco 0.9M4 has been released this week with Eclipse Indigo M4.

One of the new interesting features is the traceability between an EMF model created from the reverse-engineering of a Java application and the corresponding source code.

It allows to directly navigate from elements of the Java model in the MoDisco Model Browser to the corresponding code fragment in a Java editor.


This feature is provided by a new Java discoverer which can be executed with the MoDisco menu "Discover Java and Inventory model from Java source code" available on a Java project.

This discoverer automatically creates three EMF models:
  • a Java model describing the content of the source code: it is the model created by the basic Java discoverer.
  • a KDM Inventory model describing the structure of the Java project (all the files and folders).
  • a traceability model containing relations between the Java model elements and source code fragments
If you need to know more about these models, you can read the documentation of the discoverer.

When you launch the discoverer on a java project, the traceability model is automatically opened in the MoDisco model browser. 

To activate the synchronization with the Java source code editor, you need to activate the "Synchronize with source code option". 


Now, when you click on a model element in the model browser, the corresponding source code is automatically highlighted in the Java source code editor (otherwise, the double-click on an element opens the property view).

Tuesday, February 2, 2010

MoDisco 0.8M5 available for download


Version 0.8M5 of MoDisco, has been released yesterday : http://www.eclipse.org/gmt/modisco/downloads/

It already embeds the components which will be available in the final 0.8 version running with Helios.

Today I would like to focus on two new components (Query Manager and Facet Manager) and how they are used by the new version of the Model Browser to allow defining custom (and dynamic) viewpoints on your EMF models.

These mechanisms have been developped to support understanding of complex models automatically created from legacy source code. But you can also use it on "classic" EMF models created manually with graphical tool such as Papyrus.

Query Manager (new)

This is a new component providing a facade to evaluate queries against an EMF model independently from the query mechanism. Implementations are provided to call queries written in Java, EMFQuery, OCL and XPath.

A QuerySet containing OCL and Java queries


Facet Manager (new)

This new component provides a mechanism to dynamically extend EMF model elements by adding "virtual" attributes and relations computed by queries.


ModelBrowser

The look & feel has been reviewed to be more compliant with Eclipse UI checklist.

With the new version it is possible to dynamically customize how the EMF model elements are displayed. Any customizable feature (label, color, icon, police, ...) can be set statically, or dynamically using a Query executed on each element to display.

Wizard to customize the Browser for a given metamodel

You can also execute a Query against a model element directly from the browser

Selection of a model element from the Browser

Selection of Query to execute on the selected element

Result of the Query displayed in a table

If you want the Query to be always executed on each element of the same type, you can define a Facet to see the Query as a virtual type, attribute or relation in the browser.
The Query "subClassifiers" visible as a "virtual" relation on Class


Friday, January 29, 2010

How to create an EMF model from a Java application ?


Is it possible to reuse EMF-based tools with Java source code ? Yes if you have your Java source code translated into an EMF model.

This is the aim of the Java component provided by MoDisco. This component is composed of a ECore definition of a java application and a discoverer which creates EMF models from an EClipse project containing Java source code.

The ECore definition declares all the concepts of the Java language : Package, ClassDeclaration, MethodDeclaration, Parameters, VariableDeclaration, IfStatement, Assignment, CastExpression, LineComment, ...

To create an EMF model using this metamodel, select your project and right-click on the menu "MoDisco>Discover Java model from Java project...". A wizard appears to select the analysis options :
  • You can extend the analysis to dependencies (the JAR used by the project).
  • You can use an incremental mode if you need to optimize the memory usage
  • You can limit the analysis to declaration members if you don't need a model of the instructions contained within the methods
  • You can use a filter to exclude Java classes during the analysis

The result is an EMF model which can be opened with the EMF reflexive editor or with the MoDisco generic browser. This browser allows accessing directly to instances of a specific class (for example all the MethodDeclarations) and navigating through all the references (composed or not).

This model can be used with other EMF-based tools to check architectural or coding norms, to generate other models (UML or Domain-Specific) or to regenerate an other application (if you modify the Java model, MoDisco provides templates to regenerate Java source code).

Saturday, October 31, 2009

Eclipse Summit Europe 2009

This year was my first attending ESE, and it was worth it !

The talks on modeling were very interesting (Xtext, EMFQuery, Papyrus, ...) and it was nice to meet the guys directly involved in the projects we are interested in.

The Cloudsmith team, for example, to discuss how we could use MoDisco on the B3 project to analyse plugins and create models of builds. Or André Dietisheim about our tests with CDO to manage models of large Java applications created with MoDisco. Nice also to talk with Kenn, Ed, Ralph and many others.

I had the chance to talk during both the Modeling Symposium (Tuesday) and a session dedicated to MoDisco (Thursday).

With my colleague Gabriel Barbier of Mia-Software, who presented the demo Thursday, we shown how to create fine-grained models from Java source code (based on a Java.ecore metamodel), and how to navigate through this model with the model browser we have developped. We put the focus on the customization and the extensibility of this browser by using queries.

You can dynamically change the icon, color, font ... of the instances of your models (by defining a UICustomization, stored in a EMF model), or add "virtual" types (not originally defined in your Ecore metamodel) with "virtual" properties and references (by defining a RoleSet, also stored in a EMF model). The query mechanism that we provide is generic : it allows integrating queries written in Java, EMFQuery, OCL, XPath or ATL.


We presented the 0.8 version which is still under development (planned for the end of 2009). But thanks to Nicolas Bros who have put the releng in place, it is possible to download an integration build.

The demos are online :
- Demo during the Modeling Symposium
- Demo during the MoDisco short talk