Thursday, October 28, 2010

How to create working Android applications using Eclipse modeling techniques

Several months ago, at Eclipse Con 2010, I presented a talk titled "Acceleo Code Generation : Let's start with an Android example". This is the demo.

At Eclipse Summit Europe, we will do the talk again. This time, I won't participate... But, Mikael Barbero and Stephane Begaudeau will show an advanced version of this tutorial : "Creating a Language for Android Apps with Eclipse Modeling". Both are software engineers at Obeo. They have worked on this 4 hours tutorial with Jan Koehnlein and Holger Schill from Itemis.

In this tutorial, attendees will create working Android applications using Eclipse modeling techniques. This talk will start with a short presentation of Android and its development tools. Then the attendees will learn how to define abstractions using EMF Ecore and how to create a language and an editor for these with Xtext. Finally, they will implement a generator that creates the Java and XML source code of the Android application with the help of Acceleo. The team will demonstrate how these ingredients are integrated into the Eclipse workbench just like Java and XML do.

Thank you guys for the good job you have done to prepare this tutorial. That kicks ass! The result seems to be very impressive...

This tutorial will also be interesting for beginners... Being an expert at code generation or Acceleo is not necessary to get started on your first code generator : using the Acceleo editor and the powerful features it exposes (completion, syntax highlighting, on-the-fly compilation, quick outline, ...), it is very easy to get started once you understand the most basic principles.

Flickr/androids eat apples!/laihiu 
Goulwen Le Fur will also be at Eclipse Summit Europe 2010 and he will talk about EEF, this very usefull component I have talked about several times this year.



Monday, July 12, 2010

Spain are world champions and Fanny wins the Eclipse forecasts

EspaƱa Gana la Copa!


Spain victory is the fruit of a lot of work. Andres Iniesta was the man of the match for the final game. He is to be congratulated for that. However, I would like to highlight another person today, the woman who wins the Eclipse EEF world cup forecasts. She isn't an Eclipse commiter but she lives with an active Eclipse modeling commiter. This is something that needs considering, isn't it? ;) Thanks for all those who share our life, like you... I'm surprised that you have more points than me ;) I also give you thanks for showing us that women know soccer as much as men, and above all that an Eclipse RCP application is also usable by a non-computer scientist ;)

Thanks to the EEF and the Acceleo teams that created this nice application in few days. EEF deserves to be adopted.



Congratulations to Laurent and Florian for finishing second and third! And finally, congratulations to Nathalie who won the Obeo version of the game. A revolution is in process!

Related Links :
  • The game : An RCP application created with EEF.
  • Acceleo add-in : An Acceleo code generator to export the results in an HTML page.
  • EMF Compare add-in : An action to compare your own forecasts with the best ones.
  • ATL add-in : An action to help soccer ignorants to improve their forecasts.

Viva Espana! Congratulations to Netherland and Germany for the podium!

Thursday, July 8, 2010

Eclipse WC 2010 Final round - 7 persons can win now

You can win 16 points this week-end for the final round of the world cup forecats. Here is the ranking table. I will come back with the final results on monday 12.


Have fun! Don't forget the Eclipse DemoCamp in Nantes today!

Wednesday, June 30, 2010

Women on top of the Eclipse World Cup Forecasts

I'm glad to see that a woman is on the top of the Eclipse World Cup forecasts table. Will Fanny win the competition? Who said that women don't know anything about soccer? Nathalie is 10th. Loredana is 21th. Each day, Lynn is better and better. She's now 25th in the table... There are 70 players in the game and the identified women are on the top of the results table. Well done!


It's not too late to come into the game! For the final phase, the score is multiplied by 2! So you keep a chance.

Related Links :
Don't hesitate to make your own add-in! It's so easy when you use Modeling technologies ;-)

Monday, June 28, 2010

Don't forget the Eclipse Modeling webinar

Don't forget the Modeling webinar today at 3:30pm UTC!

The Eclipse Modeling Project is one of the most active projects within the Eclipse community. Ed Merks will give a quick overview of the Modeling projects in Helios and Sebastian Zarnekow will show Xtext. Cedric Brun will mainly talk about Acceleo and he will demo what Obeo has done for this Helios release.


Friday, June 25, 2010

How to migrate from Acceleo 2 to Acceleo 3?

Acceleo 3.0 has just been released and we have a lot of questions about how to migrate from Acceleo 2.x to Acceleo 3.x? Acceleo 3 has some differences with Acceleo 2, especially for the new syntax elements based on the Model-to-text OMG standard.

The question is : How to create the 3.x '.mtl' file from the 2.x '.mt' file?


The tooling will initialize the migration process... Just right click on the Acceleo 2.x project.


We know that the migration can't be perfect, because the MTL standard is statically typed. Sometimes you need human understanding to provide the right context and get the right equivalence. You will probably have to change the way you organize your code generators. We are confident that Acceleo 2.x users will move easily to Acceleo 3.0.

Don't worry, the Acceleo Team will continue to maintain the 2.x syntax of Acceleo. However, the new major versions and the new features will take place on Eclipse.org.

There aren't a lot of differences between the old version of acceleo and the new one. It's not so long to migrate from a syntax to another, but you should do that only if you have at least one day free. Note that it can be a little bit more for big code generation modules. Acceleo 3.0 comes with an equivalence documentation.

I hope that it will be useful...

Wednesday, June 23, 2010

Acceleo 3.0 is out and Modeling webinar

I'm really proud to announce that Acceleo 3.0 is out. It comes with Eclipse 3.6. Acceleo 3.0 combines nice tooling, simple syntax and efficient code generation with all the pragmatism we had with the 2.x stream.

As you probably know, Eclipse Helios is out! Obeo was greatly involved in this release. Note that there will be an Eclipse Modeling Webinar today (June 24 at 7pm CEST). I'll talk about the new features we have added this year.

Wanted : 70 players for the EEF Eclipse World Cup forecasts! 3 players more and it's done. I'm really glad to be on the top 10, but the first guy is flying... Don't miss the final phase, the score will be multiplied by 2! It's easy to come into the game. Come at any time! See the rules.

Obeo was involved in several projects of the Helios simultaneous release :
  • Acceleo 3.0 is a pragmatic implementation of the OMG Model-to-text specification. It supports the developper with most of the features that can be expected from a top quality code generator IDE: simple syntax, efficient code generation, advanced tooling, features on par with the JDT... Acceleo also has a unique tooling around example-based design of code generators.
  • ATL 3.1 is definitively THE model-to-model transformation language in Eclipse.
  • EEF is another way to improve the EMF model creation and it aims to improve the EMF.Edit and EMF.Editor JET code generators.
  • Amalgamation is the project that leads the creation of the modeling bundle, it has an easy one click discover and install wizard.
  • EMF Compare 1.1 mainly brings performances enhancements : ID based matching and heuristic based matching have been enhanced by a 10 factor. EMF Compare has now better support for fragmented model during the comparison.
  • SCA Tools provides a set of tools for the Service Component Architecture (SCA) set of standards. The 2.1 release brings compatibility with the OASIS specifications. The SCA Designer has been updated to work with Tuscany 2.x...


Tuesday, June 15, 2010

My 2 cents HTML export for the WC 2010 application

I would like to go further with the Eclipse World Cup 2010 application, to help skeptical people to believe in modeling technologies. The EEF team created an RCP 'forecasts' game. Yersterday, someone said that exporting the results in HTML could improve this game. No sooner said than done.


The RCP application comes with a metamodel project : 'fr.obeo.dsl.worldcupforecast'.

Here is a short description of how to make a simple HTML generator with Acceleo, based on this 'forecasts' metamodel.

It is recommended to use a bottom-up approach when developing generators; Acceleo eases this process by allowing you to initialize the content of a generation module with an HTML example, and offering specific actions to transform these examples (static text) in dynamic OCL expressions.

Let's create the 'results.html' example file which contains an image and a single row line.


We create the code generation project with the new HTML code generation file.


The main template is initialized with the example content. It is based on the 'forecasts' metamodel.


We would like to create a row line for each player, starting from the best to the least score. Thus, we create a 'for' statement to iterate over the players.


Finally, we run the coge generator on the forecasts model. It's done!


Note that you can directly access the online model in your launcher.


Here are the files : the results page, the Acceleo project, the MTL file.



Friday, June 11, 2010

WC 2010 powered by EEF and Acceleo - Results and Rating

The first day is complete and results are online. Get the results with the menu "World Cup Results and Rating".


I'm glad to be in the first part of the Rating view ;-)

This post is also a reminder. Goulwen validates the 'forecast of the day' at 6am UTC. It's easy to come into the game. Come at any time! See the rules.


Last Call : Now boarding for the Eclipse World Cup 2010!

A bit of sweetness during the final Helios release build...

Want to play to the Eclipse World Cup 2010? Want to believe in modeling technologies?

Download it!

Goulwen posted the rules yersterday.

Exceptionally today (june 11th), you can play until the beginning of the first match!


Tuesday, June 8, 2010

Two billion years of software evolution

The Acceleo planet, the Modeling solar system, the Eclipse galaxy, and the software development universe...

The only conclusion that could be derived from a universe where everything moves away from everything else is that the universe constantly expands.

Today, more than 400 000 objects roam the solar system. The stars, planets and galaxies are in constant motion. The gravitational force acting on these celestial bodies, attracting them to each other, leads to collisions. 65 millions years ago, the impact of an asteroid on Earth has caused mass extinction of living species such as dinosaurs. In two billion years, scientists predict that our galaxy will be struck by Andromeda to form a single galaxy. Related to the origins and evolution of the universe, cosmic shocks created in the past affects the present and shape the future. The Dinosaur Extinction has probably cleared the way for us. Thus, we can also consider a collision as the beginning of something else...

Image courtesy of NASA/JPL-Caltech License

I posted this because it sounds like Eclipse plug-ins development and software evolution... Sometimes, you want to blow everything up, to go further... But, it's not easy to do...

The JDT has been re-written several times in ten years, isn't it? I think that the Eclipse XText version is really more cool than the old one. E4 will probably be a revolutionary development platform... What an exciting challenge to rewrite everything without losing the best of what you have already done? We've tried to do our best for the Acceleo MTL mutation. Now, thanks to the team, the new Acceleo version seems to be on the road... Thanks for all the positive feedbacks we have received about the collision between the Acceleo planet and the MTL celestial object. Where does MTL come from? the OMG galaxy!

I can't imagine how Eclipse could be in two billion years... It would be an ordered bloody mess, like the universe ;-)

Monday, June 7, 2010

How an Android file could become a code generation template in few clicks?

Let's take a simple Android metamodel with different kinds of Widgets, like Text, Spinner, Button...

Acceleo provides a way to customize quickly your Android code generator, and manage the different code generation alternatives. With the For/If menu item, you can apply a specific treatment to each kind of Widgets.

In the Java file which contains Android widgets declarations, select them and then right-click and run: Source > As For/If (Alt+Shift+F).


Each kind of Widget is isolated as a new code generation alternative.


Then fill the appropriate kind of Widget in each condition (This is the link between the metamodel concept and the textual alternative to produce for this concept).


Leave just one TextField declaration and delete the other ones. Complete it by changing the static name of Widgets with a dynamic Acceleo expression by using the Quick replacement tool.


Repeat for the other files. The Alt+Shift+F feature is more useful the second time you use it because it tries to fill automatically the alternative condition.


Acceleo 3.0 comes with an Android Tutorial. This is meant to give beginners a tutorial to get them started with defining their own code generators... and advanced users a way to discover some of Acceleo 3.0 features.

I have shown this feature at the Eclipse modeling runaway 2010 and some of you asked me to have more details...

I hope it will be useful for you.


Wednesday, June 2, 2010

1-minute fully-functional example for ATL and Acceleo


This message will help you to install and use ATL and Acceleo in 2 minutes or if you need to make a quick demo for your client or for your boss... Don't waste your time! Use the Modeling discovery UI of the Amalgamation project.

Amalgamation Note :

The Eclipse Modeling Package is a base and sound platform one can rely on for development tasks leveraging the modeling technologies. The Package is focusing on EMF and its complementary frameworks and tools : we call that the "base platform". That said the modeling community is way more diverse than that and provides complete IDE's for dedicated langages. Those are provided through the discovery UI.

Here is the easiest way to install and try the modeling technologies like ATL and Acceleo, by downloading the Amalgamation bundle :

The final release (June 23) will be available at http://www.eclipse.org/downloads

  • Use the modeling discovery button to install ATL and Acceleo

  • Examples are available for these technologies in the right-click menus New > Examples > Acceleo Plug-ins and New > Examples > ATL


  • Now, your workspace contains the new examples...


I will come back with some little information about the interoperability between these 2 technologies...

Coming soon...

Monday, May 31, 2010

The Acceleo editor provides refactoring actions and quick fixes

You can use the usual shortcut ALT+SHIFT+R to rename either modules, templates, queries, variables... in a coherent manner. This action can also be accessed from the menu Refactor > Rename. The interface will allow you to preview the changes before validating them.

Friday, May 28, 2010

Code Generation Patterns

The Acceleo IDE provides an extension point to help you to define your own code generation pattern proposals.

Here is an example available in Acceleo 3.0 (use the same way to define your own proposal) :


The extension point is org.eclipse.acceleo.ide.ui.proposal
The Java class implements "org.eclipse.acceleo.ide.ui.views.proposals.patterns.IAcceleoPatternProposal"

Generation patterns have been introduced in acceleo because we noticed that something that happens really often when developing code generators is the need to implement some behavior on an interface and all or part of its subtypes.

For example, let's imagine you are implementing a java generator from UML. What you want is to have a template called javaName which will generate the name of any classifier, with some default behavior and some specific behavior on classes and interfaces.

This is where the Generation Patterns view comes into play:
  • Locate the cursor in the template, at the position where you want to insert your javaName templates
  • In the Generation patterns view, select "[template] for all selected types" in the top part
  • Select the types for which you want to create javaName templates for
Note the bottom part of the Generation Patterns views presents a hierarchical view of the metamodel you are using. Each node represents a type of the metamodel and contains all of its subtypes. So, one type can appear several times in this view, one time for each of its super-classes or super-interfaces. When you select a node (by checking the combo-box before it), all its descendants are also selected by default, but you can uncheck those you don't need.


Once you have selected the types you need, go back to the editor and activate the completion by hitting Ctrl+Space. The first choice should be "[template] for all selected types", select it.


New templates are then inserted into you Acceleo module. They are called "name" by default but you can immediately rename them by just entering the name you want. All templates will be renamed simultaneously.


Here, Acceleo has done his job, now it's time for you to do yours: implement these newly created templates!

Thursday, May 27, 2010

The Overrides View - Customize an existing code generator

Thank you for following me on my "New Acceleo features" week ;-)

The Overrides view shows every Acceleo element that is accessible in your workbench (no matter your current project's dependencies). You can select one or several elements (use the checkboxes) and override them.


Note: If the meaning of "override" is not clear, you may want to refer to the official MTL Specification.

Templates displayed in this view can be anywhere in your workspace or in your plug-ins.

So, this view can be used for:
  • Selecting templates you want to override (which is its main purpose)
  • Navigating to templates in your plug-ins to see their implementation without having to explicitly import their plug-in(s) in your workspace.
To override one or several existing templates, just select them in this view by checking their checkboxes. Then, edit the module in which you will override the templates, place the cursor where you want to insert the overriding templates, and hit Ctrl + Space.


Select the first choice ("Selected Overrides") and hit Return. The overriding templates are then created. Note that by default, their implementation is initialized with their original implementation.


Note: A marker indicates whether a given project is accessible from yours. If this is the case, a green mark indicates everything is fine. Otherwise, a red marker indicates that you need to import the project in yours to be able to override a template it contains. For example, in the screenshot below, org.eclipse.acceleo.module.other.sample needs be imported in your current project before you can successfully override one of its templates.


Nevertheless, you can declare the overriding, it will just not compile while you have not imported the relevant project (which is done in the MANIFEST.MF file of your Acceleo project).


Wednesday, May 26, 2010

Rapid Text Replacement in an M2T approach

Here is a very useful trick in Acceleo. Rapid text replacement allows you to quickly replace all occurrence of a chosen piece of text by some template invocation. Case differences are inferred generating toUpper() or toUpperFirst() depending on what's needed.

Here is an example:


In a classical bottom-up approach, you have written your code first, and you now implement the Acceleo template from this code. What you want to do here is to replace all occurrences of "att1" by a dynamic behavior, i.e. by a template call.

The easiest way to do this is to select one of the "att1" in the editor, and invoke the content assistant by hitting Ctrl + Space.


The completion assistant proposes to replace all occurrences of the selected text by a template call. A preview of the result is displayed in a tooltip close to the completion window.

When you accept this option, all occurrences are replaced and you can immediately enter the template invocation needed, which is simultaneously replaced in all relevant locations.


All occurrences of att1 have been replaced by [javaName()/] (because javaName() is what was entered manually), but Att1 has been replaced by [javaName().toUpperFirst()/].

The next thing you'd want to do in the above example is to replace all occurrences of int by something like [javaType()/], and implement the javaType template to write the java type of the class attributes.


Just proceed the same way and you're done. No risk to forget any occurrence of your type anymore!