Bug 493331 - Add support for selecting metamodels from the Target Platform when configuring RepresentationDescription
Summary: Add support for selecting metamodels from the Target Platform when configurin...
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 3.1.0   Edit
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks: 481849
  Show dependency tree
 
Reported: 2016-05-10 09:16 EDT by Pierre-Charles David CLA
Modified: 2018-04-03 10:19 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.