Papyrus Tutorial:

How to contribute to the code generation menu

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Editor

Saadia DHOUIB - CEA LIST

Status

Production

Version number

0.1

Date of preparation

07/11/11

Authors

 

 

Authors name (first/last name)

Company

E-mail

Initial

 

 

 

 

Saadia Dhouib

CEA LIST

Saadia.dhouib@cea.fr

SD

 

 

Revision chart and history log

Version

Date

Reasons

0.1

19/10/11

Initial contribution.

 

 

 

 

 

 

 

 

 

 

 

 

Table of contents


  Authors................................................................................................................................................ 2

  Revision chart and history log................................................................................................................ 3

  Table of contents.................................................................................................................................. 4

1  Introduction......................................................................................................................................... 5

2  Set the Java execution environment..................................................................................................... 6

3  Add the menu contribution extension point......................................................................................... 10

4  Add the command extension point..................................................................................................... 14

5  Add the handler extension point......................................................................................................... 15


 

 

1          Introduction

This tutorial explains how to contribute to the RobotML code generation menu in the papyrus model explorer view, as shown in the following figure:

 


2          Set the Java execution environment

It is very important that your Eclipse projects use the J2SE-1.5, this is the java version used by papyrus. To do this, follow the steps in the table:

Step 1

click on project properties

Step 2

Edit the JRE system library and set it to J2SE-1.5


Step 3

Set the minimum execution environment in the plug-in manifest editor


 

3          Add the menu contribution extension point

Go to the user interface project, org.eclipse.proteus.generators.acceleo.yourplatform.ui:

Then open the plug-in manifest editor.

In the Extensions corner, you are going to add a new extension that will contribute to the RobotML code generation menu.

To do this, follow the steps described in the table:

Step1

Go to the extension corner

Step 2

Add org.eclipse.ui.menus extension


Step 3

Add a new menu contribution

 

 

 


Step 4

Add a command to the menucontribution

<extension

         point="org.eclipse.ui.menus">

      <menuContribution

            allPopups="true"

            LocationURI=

"popup:org.eclipse.papyrus.robotML.modelexplorer.popupmenu.generate">

         <command

               commandId="org.eclipse.robotML.generateRTMapsCommand"

               icon="icons/default.gif"

               id="org.eclipse.robotML.generateRTMaps"

               label="Generate to RTMaps"

               style="push"

               tooltip="Generate code to RTMaps middleware">

            <visibleWhen>

               <reference

                     DefinitionId=

"org.eclipse.papyrus.proteus.diagram.common.IsPapyrusActiveWithProteus">

               </reference>

            </visibleWhen>

         </command>

      </menuContribution>

   </extension>

 

The extension details (plugin.xml corner)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


4          Add the command extension point

Then add an extension point to define the code generation command called by the previously defined menu. A command is is a declarative description of a component and is independent from the implementation details. Commands are defined via the extension point "org.eclipse.ui.commands". A command can be categorized, assigned to the user interface and a key binding can be defined for the command. The behavior of a command can be defined via a handler.

Step

Add a command extension point

 

 

 

 

 

 

 

 

 

 

 

 

5          Add the handler extension point

Add an extension point to define the handler of the command. The handler is used to define the command behavior.

Step

Add the handler extension point

 

 

 

 

 

 

You can find an example of a generation command handler class in org.eclipse.proteus.generators.acceleo.rtmaps.ui.handler.AcceleoGenerateRTMapsCommandHandler” package. [Proteus wp2 svn repository: https://dassault3.ddo.net/svn/proteus-wp2/trunk/S2.2.8-RTMaps-connectors/rtmaps-generator/org.eclipse.proteus.generators.acceleo.rtmaps.ui]