[Bug 273] Generating code for user-defined DataTypes (structs)

This resolves the problem by adding 'topTypedefinitions' to the model in
the intermediate representation (xtumlrt), translating such definitions
from UML to xtumlrt, and updating the Collector in CppCodeGenerator to
add generators for those user type definitions at the top-level and
package-level.

It remains to be decided whether those should also be generated if they
are referenced by a model element, but do not appear inside a package or
at the model level.

Also adds a key binding to trigger the generator: Ctrl + r g, when the
Composite structure diagram view is active.

Change-Id: I4ac523d0126a3b34348f43be96e072e45ebdab85
Signed-off-by: Ernesto Posse <eposse@gmail.com>
diff --git a/codegen/org.eclipse.papyrusrt.codegen.xtumlrt.trans/src/org/eclipse/papyrusrt/codegen/xtumlrt/trans/UML2xtumlrtModelTranslator.xtend b/codegen/org.eclipse.papyrusrt.codegen.xtumlrt.trans/src/org/eclipse/papyrusrt/codegen/xtumlrt/trans/UML2xtumlrtModelTranslator.xtend
index 702ea9d..0e24ea7 100644
--- a/codegen/org.eclipse.papyrusrt.codegen.xtumlrt.trans/src/org/eclipse/papyrusrt/codegen/xtumlrt/trans/UML2xtumlrtModelTranslator.xtend
+++ b/codegen/org.eclipse.papyrusrt.codegen.xtumlrt.trans/src/org/eclipse/papyrusrt/codegen/xtumlrt/trans/UML2xtumlrtModelTranslator.xtend
@@ -54,6 +54,7 @@
 import org.eclipse.papyrusrt.xtumlrt.common.StructMember
 import org.eclipse.papyrusrt.xtumlrt.common.StructType
 import org.eclipse.papyrusrt.xtumlrt.common.Type
+import org.eclipse.papyrusrt.xtumlrt.common.TypeDefinition
 import org.eclipse.papyrusrt.xtumlrt.common.VisibilityKind
 import org.eclipse.papyrusrt.xtumlrt.umlrt.PortRegistration
 import org.eclipse.papyrusrt.xtumlrt.umlrt.RTPassiveClass
@@ -331,6 +332,8 @@
                 topEntities.addIfNotPresent( translate(element) as Entity )
             else if (element.isProtocolContainer)
                 topProtocols.addIfNotPresent( translate(element) as Protocol )
+            else if (element instanceof org.eclipse.uml2.uml.DataType)
+                topTypedefinitions.addIfNotPresent( translateTypeDefinition(element) )
             else if (element instanceof org.eclipse.uml2.uml.Package)
                 rootPackages.addIfNotPresent( translate(element) as Package )
         }
@@ -351,6 +354,8 @@
                 entities.addIfNotPresent( translate(element) as Entity )
             else if (element.isProtocolContainer)
                 protocols.addIfNotPresent( translate(element) as Protocol )
+            else if (element instanceof org.eclipse.uml2.uml.DataType)
+                typedefinitions.addIfNotPresent( translateTypeDefinition(element) )
             else if (element instanceof org.eclipse.uml2.uml.Package)
                 packages.addIfNotPresent( translate(element) as Package )
         }
@@ -756,6 +761,14 @@
         // Do not translate unknown types
     }
 
+    protected def
+    create CommonFactory.eINSTANCE.createTypeDefinition
+    translateTypeDefinition( org.eclipse.uml2.uml.DataType dataType )
+    {
+        type = translate( dataType ) as Type
+    }
+
+
     /**
      * @param stateMachine  - A {@link org.eclipse.uml2.uml.StateMachine}
      * @return A {@link StateMachine}