|
|
|
|
|
Re: How to get an EObject from an EObjectNode [message #1010603 is a reply to message #1010579] |
Sun, 17 February 2013 15:40  |
Eclipse User |
|
|
|
Hi
No. Christian told you about IUnitOfWork, which is fundamental to
correct use of Xtext. (Xtext doesn't use URIs just to make your life
difficult; it's to protect you from unsafe access to the EObjects. The
IUnitOfWork provides the safe access.)
At best your approach requires a model reload; it may not be a loadable URI.
At worst you get a stale copy.
Regards
Ed Willink
On 17/02/2013 19:01, Andrea Sindico wrote:
> This is the answer I was looking for
>
> if (selection instanceof IStructuredSelection) {
> Object first =
> ((IStructuredSelection)selection).getFirstElement();
> EObjectNode enode = (EObjectNode)first;
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource inResource =
> resourceSet.getResource(enode.getEObjectURI(),true);
> MyEcoreElement element =
> (MyEcoreElement)inResource.getEObject(enode.getEObjectURI().fragment());
> //.... }
>
> Regards
|
|
|
Powered by
FUDForum. Page generated in 0.04512 seconds