Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » load profile (how to load a profile with a program)
load profile [message #759303] Mon, 28 November 2011 05:32 Go to previous message
Hilaire  is currently offline Hilaire
Messages: 20
Registered: July 2009
Junior Member
Hello,


I'am developping a tool to transform UML stereotyped models to JAVA. For this I use an UML profile which contains stereotype that add attributes to classes (designed with papyrus) and wrapped in a specific plugin with an extension point (pathmap://MyProfiles/crio.profile.uml).

Now I want to load this profile within a program. I have found several topics on the subject and tried to follow these hints but it never worked. My plugin has as dependency the previous plugin and I try to load with the resourceSet.getPackageRegistry().put("pathmap://MyProfiles/crio.profile.uml",org.eclipse.uml2.uml.UMLPackage.eINSTANCE);


I also tried to register a factory
public void registerResourceFactories(ResourceSet resourceSet) {
super.registerResourceFactories(resourceSet);
// TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
// resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put
("uml",
new XMIResourceFactoryImpl()
{
public Resource createResource(URI uri)
{
XMIResource xmiResource = new XMIResourceImpl(uri);
return xmiResource;
}
});

}


and the last thing I tried was to load by

final String profile = "profiles/crio.profile.uml";
URL url = getClass().getClassLoader().getResource(profile);
if (url == null)
{
throw new RuntimeException("Error getting crio.profile.uml");
}
String urlString = url.toString();
if (!urlString.endsWith(profile))
{
throw new RuntimeException("Error getting crio.profile.uml. Got: " +
urlString);
}
urlString = urlString.substring(0, urlString.length() - profile.length());
URI uri = URI.createURI(urlString);org.eclipse.uml2.uml.Package package_ = null;

System.out.println("URI ="+uri+"\n");
try {

Resource resource = resourceSet.getResource(uri, true); //URI.createURI("PATHMAP://MyProfiles/crio.profile.uml")


package_ = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(

resource.getContents(), UMLPackage.Literals.PACKAGE);

} catch (WrappedException we) {

System.out.println(we.getMessage());

System.exit(1);

}
}



Is there somewhere a tutorial/document that explains how to do this ?

Thanks


Vincent
 
Read Message
Read Message
Previous Topic:plug-in and IDE error, my acceleo UI launcher is not invoking all modules
Next Topic:'.emtl' not found
Goto Forum:
  


Current Time: Sat May 18 07:33:45 EDT 2013

Powered by FUDForum. Page generated in 0.02207 seconds