Bug 493331

Summary: Add support for selecting metamodels from the Target Platform when configuring RepresentationDescription
Product: [Modeling] Sirius Reporter: Pierre-Charles David <pierre-charles.david>
Component: CoreAssignee: Project inbox <sirius.core-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P5 CC: cedric.brun, julien.dupont
Version: 3.1.0Keywords: triaged
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/72685
Whiteboard:
Bug Depends on:    
Bug Blocks: 481849    

Description Pierre-Charles David CLA 2016-05-10 09:16:20 EDT
In the VSM editor, in the "Metamodels" section of RepresentationDescriptions, we have buttons to select the metamodel "from the registry", "from the workspace", and "from the filesystem". We should add "from the Target Platform" button, based on the "Browse Target Platform Packages" button proposed by recent versions of EMF (see https://bugs.eclipse.org/bugs/attachment.cgi?id=257858 for a screenshot).

The Sirius code for this custom section is at RepresentationDescriptionMetamodelPropertySectionSpec.

The EMF code for the actual behavior we want can be found in org.eclipse.emf.ecore.presentation.EcoreActionBarContributor.ExtendedLoadResourceDialog.
Comment 1 Pierre-Charles David CLA 2016-05-18 03:37:33 EDT
There's a first very rough attempt at https://git.eclipse.org/r/#/c/72685/, but it looks like it might be more complex than initially thought, so moving to 4.1.
Comment 2 Pierre-Charles David CLA 2016-09-08 10:27:18 EDT
From what I understand, EMF itself uses a lot of "dirty tricks" (see org.eclipse.emf.ecore.plugin.EcorePlugin.PDEHelper, full of reflective calls, which is invoked from  org.eclipse.emf.ecore.presentation.EcoreActionBarContributor.ExtendedLoadResourceActi
 on.TargetPlatformPackageDialog.updateElements()) to obtain the nsURIs for the EPackages declared in the plug-ins found in the target platform (it actually reflectively parses the EMF extension points from the plugin.xml of said plug-ins' JARs...).

Even with this, it can only obtain the textual nsURIs of the packages, not actual EPackages instances. However, because of how our metamodel is designed, RepresentationDescription.getMetamodel() is actually a reference to actual EPackages. Why this was done this way and whether or not it was a good idea is another matter, but in practice I see no easy way to obtain what we need (loading the .ecore from the target platform archives like the PDEHelper does for the plugin.xml files? ugh...).

Cédric, I'm adding you in CC in case I misunderstood something or if you have an idea. In the meantime, moving to 5.0 to re-evaluate, but if we really want this, it might require some deeper infrastructure work to make it possible.