Friday, May 7, 2010

How to load emf resource from a plugin jar

Lets assume that an emf resource file has been contributed to an extension-point.
Now while reading the extension points; one can find out the name of the plugin.

IConfigurationElement[] elements = extensions[i].getConfigurationElements();
IContributor contributor = elements[j].getContributor();
String bundleId = contributor.getName();

URI uri = URI.createPlatformPluginURI("/" + bundleId + "/"+ filePath, true);
Resource resource = ResourceSetFactory.getResourceSet().createResource(uri);
resource .load(null);
EList contents = resource .getContents();

No comments: