Thursday, October 14, 2010

Spy On Your Models - Part 1

Have you ever been stuck with an EMF model, trying to find what was going wrong? Which relation is broken or missing ? Where is that model element which should be there, related to that other one ? How many instances this EClass has in the model ?

Of course, you can use the EMF reflexive editor. It is suitable for small models, but when your model contains a lot of model elements it is hard to find your way (you must start from the roots elements, you don't see the name of the relations between the objects, the tree doesn't show the objects pointed by non-containment relations, etc).

So, if you really need this kind of information (and if you are not an expert in reading XMI files in plain text), the model browser provided by MoDisco is a solution for you.

To allow inspecting the details of large and complex EMF models, MoDisco (the Eclipse/modeling project dedicated to Software Modernization) provides an editor with lots of interesting features.

After MoDisco installation, you can right-click on any EMF resource and open the browser by selecting the menu "Open with > MoDisco Browser".



In this suite of posts, I will describe the main features of this tool.

The first feature is a panel, on the left-side of the browser, displaying the classes (metaclasses) of the corresponding ECore definition (the metamodel). The selection of a type displays all its instances in the right-side panel. Each type is suffixed by the number of its instances. By default, only the types with at least one instance are listed, but if you click on the "(0)" button, the empty metaclasses are also listed.


Sometimes, it can be helpful to see also the instances of the subtypes too. For example, in a UML model, if you consider the DataType metaclass you may need to access also to the Enumeration and PrimitiveType instances. It is possible by clicking on the button "Display Instances of Submetaclasses".

By clicking on the button "Show Derivation Tree", you can also display these types in a tree, organized according to the "eSuperTypes" relation.


Four other options are available: to sort the types alphabetically, to sort them by the number of their instances, to group them by package and to show their full qualified name.

Of course, standard features provided by EMF on EClass are still available. For example to get the references to a metaclass, the menu "Show References" opens the view "EClass References".


Another important feature provided by the browser is the management of large models. If a type as more than 1000 instances, they are displayed by groups of 1000 instances.


In a next post, I will describe the features related to the Instances panel which allows to view the properties of each instance and to navigate through its references to other instances.

2 comments:

  1. Hi Fred,

    Nice blog post.
    One question i have.

    For the last diagram you showed, for large models do you load all the resources?..How do you query the resources ?.

    Cheers,
    Saurav

    ReplyDelete
  2. Site Updated and Upgrade here: Please visit now why it last thanks Click Here

    ReplyDelete