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.
Capella/Tutorials/Extensibility/LoadModel
//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);
}