Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Type of UML attribute/property (Acceleo 4.3.0, Eclipse SR2)?
[Acceleo] Type of UML attribute/property (Acceleo 4.3.0, Eclipse SR2)? [message #1265583] Thu, 06 March 2014 04:25 Go to next message
Joost Kraaijeveld is currently offline Joost Kraaijeveld
Messages: 173
Registered: July 2009
Senior Member
Hi,

I have a Papyrus model in which a class has an attribute with of the
type String from the UML Primitive Types. Based on the getting started
tutorial I expected the following to work and to result in "String
attributeName":

[for (p: Property | aClass.attribute) separator('\n')]
[p.type.name/] [p.name/];
[/for]

But "[p.type.name/]" does not result in any output. Am I missing
something? What should I do?

TIA


Joost
Re: [Acceleo] Type of UML attribute/property (Acceleo 4.3.0, Eclipse SR2)? [message #1402835 is a reply to message #1265583] Thu, 17 July 2014 13:37 Go to previous messageGo to next message
Béla Boda is currently offline Béla Boda
Messages: 1
Registered: July 2014
Junior Member
Yes you do.

Saidly it is a bit ugly, but you need to do as it is described here:
https://wiki.eclipse.org/MDT/UML2/FAQ#What.27s_required_to_load_a_UML_.28.uml.29_resource_from_a_standalone_application.3F

Don't forget the
@generated NOT


It works for me, customize your eclipse location and the versions:
    /**
     * This can be used to update the resource set's package registry with all needed EPackages.
     * 
     * @param resourceSet
     *            The resource set which registry has to be updated.
     * @generated NOT
     */
    @Override
    public void registerPackages(ResourceSet resourceSet) {
        super.registerPackages(resourceSet);
        if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
            resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
        }
        
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
        Map uriMap = resourceSet.getURIConverter().getURIMap();
        URI uri = URI.createURI("jar:file:/c:/eclipse/eclipse-modeling-luna-R-win32-x86_64/plugins/org.eclipse.uml2.uml.resources_5.0.0.v20140602-0749.jar!/"); // for example
        uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
        uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
        uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
...
}
Re: [Acceleo] Type of UML attribute/property (Acceleo 4.3.0, Eclipse SR2)? [message #1402841 is a reply to message #1402835] Thu, 17 July 2014 14:44 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

As of Luna UMLReourcesUtil.init(ResourceSet) does all the setup scanning
the classpath top discover the JAR spelling. Acceleo could call it for
you but it doesn't.

(In Kepler the pathmap assignments were still needed.)

Regards

Ed Willink


On 17/07/2014 19:12, Béla Boda wrote:
> Yes you do.
>
> Saidly it is a bit ugly, but you need to do as it is described here:
> https://wiki.eclipse.org/MDT/UML2/FAQ#What.27s_required_to_load_a_UML_.28.uml.29_resource_from_a_standalone_application.3F
>
>
> Don't forget the @generated NOT
>
> It works for me, customize your eclipse location and the versions:
>
> /**
> * This can be used to update the resource set's package registry
> with all needed EPackages.
> * * @param resourceSet
> * The resource set which registry has to be updated.
> * @generated NOT
> */
> @Override
> public void registerPackages(ResourceSet resourceSet) {
> super.registerPackages(resourceSet);
> if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
> resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(),
> org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
> }
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Map uriMap = resourceSet.getURIConverter().getURIMap();
> URI uri =
> URI.createURI("jar:file:/c:/eclipse/eclipse-modeling-luna-R-win32-x86_64/plugins/org.eclipse.uml2.uml.resources_5.0.0.v20140602-0749.jar!/");
> // for example
> uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
> uri.appendSegment("libraries").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
> uri.appendSegment("metamodels").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
> uri.appendSegment("profiles").appendSegment(""));
> ..
> }
>
Previous Topic:[Acceleo] Accessing DataType values of a stereotype
Next Topic:Package registration fails silently
Goto Forum:
  


Current Time: Fri Aug 01 18:41:43 EDT 2014

Powered by FUDForum. Page generated in 0.02171 seconds