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

Difference between revisions of "Capella/Tutorials/Extensibility/LoadModel"

(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...")
 
m (Replaced content with "This page has been moved to https://github.com/eclipse/capella/wiki/Tutorials")
 
Line 1: Line 1:
 
+
This page has been moved to https://github.com/eclipse/capella/wiki/Tutorials
//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);
+
}
+

Latest revision as of 05:02, 29 October 2021

This page has been moved to https://github.com/eclipse/capella/wiki/Tutorials

Back to the top