Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Capella/Tutorials/Extensibility/LoadModel

< Capella‎ | Tutorials
Revision as of 10:45, 19 January 2018 by Philippe.dul@thalesgroup.com (Talk) (Created page with " //Case 1: as it is done in Capella: //Add dependencies to org.polarsys.capella.common.ef plugin ExecutionManager manager = ExecutionManagerRegistry.getInstance().addNewManag...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

//Case 1: as it is done in Capella:

//Add dependencies to org.polarsys.capella.common.ef plugin ExecutionManager manager = ExecutionManagerRegistry.getInstance().addNewManager(); Resource res1 = manager.getEditingDomain().getResourceSet().getResource(uri, true);


//Other ways : but the derived methods defined in the capella model will not work properly.

//Case 2: Create a new ResourceSet ResourceSet set2 = new ResourceSetImpl(); Resource res2 = set2.getResource(uri, true);


//Case 3: Set the global registry and it shall work. ResourceSet set3 = ...; set3.setPackageRegistry(EPackage.Registry.INSTANCE); Resource res3 = set3.getResource(uri, true);


//Case 4: Register packages from the global registry and it shall work. ResourceSet set4 = ...; for (String pkgId: EPackage.Registry.INSTANCE.keySet()) { set4.getPackageRegistry().put(pkgId, EPackage.Registry.INSTANCE.get(pkgId)); } Resource res4 = set4.getResource(uri, true);


EObject o = res1.getContents().get(0); for (EObject oo : o.eContents()) { System.out.println(oo); }

Back to the top