Generating the separate ecore files for the sub-Epackes present in the existing model

259 Views Asked by At

Problem: I have an ecore file which has the sub-E Packages. Using this model I am trying to create the GUI part using Sirius. But the problem with Sirius is that it does not support ecore files containing sub-E Packages. So we have to extract those sub-E Packages to separate ecore files. But each sub-E Packages has relation with the other sub-E Packages. So how can we extract those sub-E Packages to separate ecore files such that the relations still exists between separate ecore files after extracting them.

Thanks

2

There are 2 best solutions below

0
On

In eclipse ecore editor you can use "Load Resource" in pop-up menu to load any ecore file and use objects from it.

0
On

By extracting them the ecore Editor will lose the information unfortunately, which means some extra work... I had the same issue with sirius and sub e-packages leading to sirius crashing the diagram constantly. Here is how i solved extracting a sub-epackage:

  1. First Create a new .ecore file for your desired sub-package.
  2. Open both .ecore files (your main and the new one) with the Sample ecore model editor (treeview).
  3. Copy the Package properties to your new epackage node(ns, praefix, uri) you need to do this manually.
  4. Then drag and drop your whole contents(excluding the purple package node) from your subpackage into the new Epackage
  5. Save and make sure no errors in your new file occur.
  6. load your new .ecore file into your main file by clicking "Load resource" Now your main file knows 2 kinds of the EClasses you have in your sub-package, their names are identical but their uri is different.

you could now simply replace all occurrences of sub-epackage-eclasses with the newer ones or smarter and safer

  1. Replace an etype one time (where actually use the etype in your root package)
  2. open your main .ecore file as text, you will see that the etype values all have a path like eType="ecore:EClass ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EObject" Then You need to know how your etype paths (from your sub-epackage and your new one) differ so you can simply replace them all and your good.
  3. finally delete the sub-epackage

Hope this helps