Skip to main content



      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 05:08 Go to next message
Eclipse UserFriend
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 05:44 Go to previous messageGo to next message
Eclipse UserFriend
You can use resourceSet.getEObject(uri, true).
Re: Getting EObject from an URI [message #1830571 is a reply to message #1830570] Wed, 29 July 2020 06:10 Go to previous messageGo to next message
Eclipse UserFriend
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 06:10] by Moderator

Re: Getting EObject from an URI [message #1830573 is a reply to message #1830571] Wed, 29 July 2020 06:24 Go to previous messageGo to next message
Eclipse UserFriend
Are you opening the generated editor? I assume so, in which case, look at what the createModel method does.
Re: Getting EObject from an URI [message #1830575 is a reply to message #1830573] Wed, 29 July 2020 06:48 Go to previous messageGo to next message
Eclipse UserFriend
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 08:51 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Getting EObject from an URI [message #1830588 is a reply to message #1830585] Wed, 29 July 2020 09:10 Go to previous message
Eclipse UserFriend
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: Sun May 18 00:52:12 EDT 2025

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

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

Back to the top