| [comment] |
| Copyright (c) 2008, 2012 Obeo |
| All rights reserved. This program and the accompanying materials |
| are made available under the terms of the Eclipse Public License 1.0 |
| |
| Any license can be applied to the files generated with this template |
| and Acceleo. |
| |
| author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a> |
| [/comment] |
| [module init('http://www.eclipse.org/emf/2002/Ecore')/] |
| [import names/] |
| [import types/] |
| |
| [template public toModuleInit(packaje : EPackage)] |
| [file (packaje.moduleInit().trim(), false)] |
| Module [packaje.name/] |
| |
| Sample usage : |
| [if (packaje.eClassifiers->size() > 0)] |
| >>> from [packaje.name.toLower()/] import [packaje.eClassifiers->first().name/] |
| [packaje.eClassifiers->first().oclAsType(EClass).sampleClassUsage()/] |
| [/if] |
| |
| """ |
| |
| [for (sub : EPackage | packaje.eSubpackages) before('#import subpackages')] |
| import [sub.moduleName().substituteAll('/', '.')/] |
| [/for] |
| |
| from [packaje.moduleName()/] import * |
| |
| from __factory__ import [packaje.factoryClassName()/] |
| """ |
| Initialize the default instances factory |
| """ |
| factory = [packaje.factoryClassName()/]() |
| # here you may redefine the module singletons or do some special tricks |
| |
| from __common__ import [packaje.resourceFactory()/] |
| resourceFactory = [packaje.resourceFactory()/]() |
| [/file] |
| [/template] |
| |
| [template public sampleClassUsage(c : EClass)] |
| >>> [c.name.toLower()/] = [c.name/]() |
| [for (att : EAttribute | c.eAttributes)] |
| >>> [c.name.toLower()/].[att.name/] = [att.eAttributeType.typeInitialization().trim()/] |
| [/for] |
| [for (ref : EReference | c.eReferences) separator ('\n')] |
| [ref.sampleReferenceUsage()/] |
| [/for] |
| [/template] |
| |
| [template public sampleReferenceUsage(reference : EReference)] |
| >>> [reference.eContainingClass.name.toLower()/].[reference.name/].append([reference.eType.name/]()) |
| >>> [reference.eType.name.toLower()/] = [reference.eContainingClass.name.toLower()/].[reference.name/]['[0]'/] |
| [/template] |