Skip to main content


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 13:19 Go to next message
Matt H. is currently offline Matt H.Friend
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 14:30 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
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 15:34 Go to previous messageGo to next message
Matt H. is currently offline Matt H.Friend
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 10: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 12:06 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
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 10:16 Go to previous messageGo to next message
Matt H. is currently offline Matt H.Friend
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 13:16 Go to previous message
Christian B is currently offline Christian BFriend
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: Tue Apr 16 14:47:58 GMT 2024

Powered by FUDForum. Page generated in 0.13781 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top