Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Getting EObject from an URI(Trying to convert EObject to URI and back to EObject in editors)
Getting EObject from an URI [message #1830568] Wed, 29 July 2020 09:08 Go to next message
Palraj Jayaraj is currently offline Palraj JayarajFriend
Messages: 15
Registered: June 2015
Junior Member
Hello Everyone,
I'm beginner in EMF frameworks and tools. I have an Editor which takes URIEditorInput, for displaying an EMF model data.
So, I convert an EObject to URI using the API EcoreUtil.getURI(EObject) and create an URIEditorInput and pass it for opening the editor.

Now, I'm need in need of accessing the EObject inside the Editor instance.

so, How can I convert the URI to an EObject? I analyzed a bit and found that there is a resource API to fetch the EObject (Resource.getEObject(String uriFragment)). But, I'm unable to find an API to fetch Resource from the URI.

can someone please advice a way to convert URI to it's corresponding EObject?

Thanks,
Pal
Re: Getting EObject from an URI [message #1830570 is a reply to message #1830568] Wed, 29 July 2020 09:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
You can use resourceSet.getEObject(uri, true).

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting EObject from an URI [message #1830571 is a reply to message #1830570] Wed, 29 July 2020 10:10 Go to previous messageGo to next message
Palraj Jayaraj is currently offline Palraj JayarajFriend
Messages: 15
Registered: June 2015
Junior Member
Thanks Ed for the reply.

But, sorry for me , being naive, How to get the ResourceSet from an URI?

[Updated on: Wed, 29 July 2020 10:10]

Report message to a moderator

Re: Getting EObject from an URI [message #1830573 is a reply to message #1830571] Wed, 29 July 2020 10:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Are you opening the generated editor? I assume so, in which case, look at what the createModel method does.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting EObject from an URI [message #1830575 is a reply to message #1830573] Wed, 29 July 2020 10:48 Go to previous messageGo to next message
Palraj Jayaraj is currently offline Palraj JayarajFriend
Messages: 15
Registered: June 2015
Junior Member
Sorry Ed for not being specific,

I'm not opening a generated editor , but, a custom built editor.
Re: Getting EObject from an URI [message #1830585 is a reply to message #1830575] Wed, 29 July 2020 12:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Well, an editor ought to have support for undo/redo and such things, so you'd probably be best off to start with the generated editor and then customize it. In any case, you can generate the editor and look at how it's implemented for guidance.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting EObject from an URI [message #1830588 is a reply to message #1830585] Wed, 29 July 2020 13:10 Go to previous message
Palraj Jayaraj is currently offline Palraj JayarajFriend
Messages: 15
Registered: June 2015
Junior Member
Thanks Ed. I'll check that out.
Previous Topic:[Compare] Using ExtensionPoint for PostProcessor
Next Topic:Save Resource Without Alphabetic Sorting
Goto Forum:
  


Current Time: Thu Apr 18 07:42:23 GMT 2024

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

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

Back to the top