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.

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).