[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.mdt.uml2] Re: genmodel for state machine diagram

Hi Tas, I got the example code going that you included and I intend to look at model transformational languages soon, thanks heaps for the tips! For the moment, I am still trying to de-serialise the uml model as per:

http://wiki.eclipse.org/MDT/UML2/FAQ#What.27s_required_to_load_a_UML_.28.uml.29_resource_from_a_standalone_application.3F

I am getting an empty set and I have double checked the .uml file has in it a statemachine and other elements. The code I have written is:

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);


File file = new File("InputC.uml");
if(!file.exists()) {
	System.out.println("Cannot find file.");
} else {
	System.out.println("Found " + file.getCanonicalPath());
}
		
//URI uri = URI.createFileURI(file.getCanonicalPath());
//Resource resource = resourceSet.createResource(uri);
//System.out.println(resource.getContents().get(0));

Map uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createFileURI(file.getCanonicalPath());
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
Resource resource = resourceSet.createResource(uri);
System.out.println(resource.getContents());


I know I am close but can't seem to get it loading. Any ideas? Thanks, Eban