Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Load Domain Model (File) into Diagram
Load Domain Model (File) into Diagram [message #756895] Tue, 15 November 2011 08:19 Go to next message
Matt H. is currently offline Matt H.
Messages: 6
Registered: August 2011
Junior Member
Hi!

I want to load business objects (EMF format) into a new Graphiti diagram.

The thread "Create Diagram Model Programatically" has been of great help so far.

But my question is:
How do I get the business objects out of the domain model file?


My first naive attempt was:
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.getResource(domainModelFileURI, true);
try {
	resource.load(Collections.EMPTY_MAP);
} catch (IOException e) {
	e.printStackTrace();
}

All I get is resource = 'null'.


Thanks,
Matt
Re: Load Domain Model (File) into Diagram [message #756917 is a reply to message #756895] Tue, 15 November 2011 09:30 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim Kaiser
Messages: 118
Registered: July 2009
Senior Member
Hi Matt,

maybe the uri is wrong? If the resource is not null you can
retrieve its contents via getContents().
You may have a look at the TutorialUtil for inspiration.
Also, you may want to ponder on reusing the resource set of the diagram editor...
For pure EMF questions, please use the EMF forum.

Best, Tim
Re: Load Domain Model (File) into Diagram [message #756937 is a reply to message #756917] Tue, 15 November 2011 10:34 Go to previous messageGo to next message
Matt H. is currently offline Matt H.
Messages: 6
Registered: August 2011
Junior Member
Hi Tim,

thanks for the quick reply!
Good to know my code is basically correct.
I will check the URI again.
( update: URI is correct. resource.getcontents() is not null, but empty. I will use the EMF Forum for details )


Sorry, I don't understand what you mean by "reusing the resource set of the diagram editor". Could you explain this?


best regards,
Matt

[Updated on: Wed, 16 November 2011 05:23]

Report message to a moderator

Re: Load Domain Model (File) into Diagram [message #757079 is a reply to message #756937] Wed, 16 November 2011 07:06 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim Kaiser
Messages: 118
Registered: July 2009
Senior Member
Hi Matt,

the diagram editor has a resource set where the resource
for the graphiti model is managed.
You might use this resource set instead of creating a new one.
You might have a look at the method saveToModelFile
in the TutorialUtil.

Best, Tim
Re: Load Domain Model (File) into Diagram [message #757407 is a reply to message #757079] Fri, 18 November 2011 05:16 Go to previous messageGo to next message
Matt H. is currently offline Matt H.
Messages: 6
Registered: August 2011
Junior Member
Hi Tim,
thanks for your help.

I finally solved the problem.
If anybody has the same problem, here is my solution:
	
// LOAD OTX MODEL FROM FILE
ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createFileURI(new File("filepath.xml").getAbsolutePath() );
Resource poResource = resourceSet.getResource(fileURI, true);
		
// Add business objects to list
Set<EObject> eObjects = new HashSet<EObject>();
eObjects.addAll(poResource.getContents());


Re: Load Domain Model (File) into Diagram [message #757441 is a reply to message #757407] Fri, 18 November 2011 08:16 Go to previous message
Christian B is currently offline Christian B
Messages: 68
Registered: August 2011
Member
Hi Matt, could you allow private messages in youre profile, i would like to send you one Wink
Previous Topic:How to rotate a text
Next Topic:Store EMF model and Graphiti diagram seperately
Goto Forum:
  


Current Time: Fri Aug 22 06:08:27 EDT 2014

Powered by FUDForum. Page generated in 0.11041 seconds