Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Obtaining an EAttribut's container's implementation
Obtaining an EAttribut's container's implementation [message #495382] Wed, 04 November 2009 16:46 Go to next message
Morten MacFly is currently offline Morten MacFlyFriend
Messages: 69
Registered: July 2009
Member
Hi all,
I feel I am struggeling with something very simple, here it goes:
I am iterating through a tree and collecting all EAttributes (and only
such) and the EObject they belong to (so it's parent, basically).

No I wondered why saving both, becasue there should be a way to get the
parent's implementation via the EAttribute. However, it seems I am
unable to get the right object.

If I do EAttribute.eContainer I'll get the container class, but not it's
implementation class which I need. So I am not looking for e.g.
"MyAttrib" but "MyAttribImpl"... ;-)

How to achive that?

With regards, Morten.
Re: Obtaining an EAttribut's container's implementation [message #495401 is a reply to message #495382] Wed, 04 November 2009 17:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Morten,

Comments below.

Morten MacFly wrote:
> Hi all,
> I feel I am struggeling with something very simple, here it goes:
> I am iterating through a tree and collecting all EAttributes (and only
> such) and the EObject they belong to (so it's parent, basically).
>
The parent is an EClass while the EObject is an instance of that EClass.
> No I wondered why saving both, becasue there should be a way to get the
> parent's implementation via the EAttribute. However, it seems I am
> unable to get the right object.
>
> If I do EAttribute.eContainer I'll get the container class, but not it's
> implementation class which I need. So I am not looking for e.g.
> "MyAttrib" but "MyAttribImpl"... ;-)
>
> How to achive that?
>
Maybe this method on InternalEObject would be helpful:

/**
* Returns a setting that can be used to access this object's feature.
* @param feature the feature of the desired setting.
* @return a setting that can be used to access this object's feature.
*/
EStructuralFeature.Setting eSetting(EStructuralFeature feature);

I.e., it's an object that represents the EObject/feature pair.
> With regards, Morten.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Obtaining an EAttribut's container's implementation [message #495499 is a reply to message #495401] Thu, 05 November 2009 06:46 Go to previous messageGo to next message
Morten MacFly is currently offline Morten MacFlyFriend
Messages: 69
Registered: July 2009
Member
Thanks for the answer!

Ed Merks wrote:
> The parent is an EClass while the EObject is an instance of that EClass.
That is correct, of course.

While reading the answer I realised that of course I don't whant to have
the attribute's implementation, but the parent's implementation.

Just for clarification: I am working on a customised diagnostics view.
If an element does not validate (dignostic error) I want to be able to
jump to the attribute in the tree. For this to work when I setup the
BasicDiagnostic I need to provide/use the parent's implementation and
the attribute (with the error). It works perfectly if I use the EObject
I gathered while iterating trough the tree, but I didn't manage to get
the right parent only having the EAttribute at that point. Probably
There is an easier way?

> Maybe this method on InternalEObject would be helpful:
> EStructuralFeature.Setting eSetting(EStructuralFeature feature);
> I.e., it's an object that represents the EObject/feature pair.
This seems plausible to me, but how do I use it?

I read about InternalEObject:
"An internal interface implemented by all EObjects.".

So that means I can cast my EObject to that interface, obtain the
"Setting" by querying for the EAttribute (feature) and just store the
"Setting", right? Like:

EAttribute ea = eaEOEntry.getKey();
EObject eo = eaEOEntry.getValue();
InternalEObject internalEObject = (InternalEObject)eo;
Setting eSetting = internalEObject.eSetting(ea);

Then I should use the methods:

eSetting.getEObject()
eSetting.getEStructuralFeature()

....to obtain the pair I am looking for.

I'll try that...
Re: Obtaining an EAttribut's container's implementation [message #495565 is a reply to message #495499] Thu, 05 November 2009 11:18 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030908020709060104020601
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Morten,

Comments below.

Morten MacFly wrote:
> Thanks for the answer!
>
> Ed Merks wrote:
>
>> The parent is an EClass while the EObject is an instance of that EClass.
>>
> That is correct, of course.
>
> While reading the answer I realised that of course I don't whant to have
> the attribute's implementation, but the parent's implementation.
>
> Just for clarification: I am working on a customised diagnostics view.
> If an element does not validate (dignostic error) I want to be able to
> jump to the attribute in the tree. For this to work when I setup the
> BasicDiagnostic I need to provide/use the parent's implementation and
> the attribute (with the error). It works perfectly if I use the EObject
> I gathered while iterating trough the tree, but I didn't manage to get
> the right parent only having the EAttribute at that point. Probably
> There is an easier way?
>
>
>> Maybe this method on InternalEObject would be helpful:
>> EStructuralFeature.Setting eSetting(EStructuralFeature feature);
>> I.e., it's an object that represents the EObject/feature pair.
>>
> This seems plausible to me, but how do I use it?
>
> I read about InternalEObject:
> "An internal interface implemented by all EObjects.".
>
> So that means I can cast my EObject to that interface, obtain the
> "Setting" by querying for the EAttribute (feature) and just store the
> "Setting", right? Like:
>
> EAttribute ea = eaEOEntry.getKey();
> EObject eo = eaEOEntry.getValue();
> InternalEObject internalEObject = (InternalEObject)eo;
> Setting eSetting = internalEObject.eSetting(ea);
>
> Then I should use the methods:
>
> eSetting.getEObject()
> eSetting.getEStructuralFeature()
>
> ...to obtain the pair I am looking for.
>
> I'll try that...
>
Yes, that's the idea. You'll see it's used in the CrossReferencers.

--------------030908020709060104020601
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Morten,<br>
<br>
Comments below.<br>
<br>
Morten MacFly wrote:
<blockquote cite="mid:hctsbq$fer$1@build.eclipse.org" type="cite">
<pre wrap="">Thanks for the answer!

Ed Merks wrote:
</pre>
<blockquote type="cite">
<pre wrap="">The parent is an EClass while the EObject is an instance of that EClass.
</pre>
</blockquote>
<pre wrap=""><!---->That is correct, of course.

While reading the answer I realised that of course I don't whant to have
the attribute's implementation, but the parent's implementation.

Just for clarification: I am working on a customised diagnostics view.
If an element does not validate (dignostic error) I want to be able to
jump to the attribute in the tree. For this to work when I setup the
BasicDiagnostic I need to provide/use the parent's implementation and
the attribute (with the error). It works perfectly if I use the EObject
I gathered while iterating trough the tree, but I didn't manage to get
the right parent only having the EAttribute at that point. Probably
There is an easier way?

</pre>
<blockquote type="cite">
<pre wrap="">Maybe this method on InternalEObject would be helpful:
EStructuralFeature.Setting eSetting(EStructuralFeature feature);
I.e., it's an object that represents the EObject/feature pair.
</pre>
</blockquote>
<pre wrap=""><!---->This seems plausible to me, but how do I use it?

I read about InternalEObject:
"An internal interface implemented by all EObjects.".

So that means I can cast my EObject to that interface, obtain the
"Setting" by querying for the EAttribute (feature) and just store the
"Setting", right? Like:

EAttribute ea = eaEOEntry.getKey();
EObject eo = eaEOEntry.getValue();
InternalEObject internalEObject = (InternalEObject)eo;
Setting eSetting = internalEObject.eSetting(ea);

Then I should use the methods:

eSetting.getEObject()
eSetting.getEStructuralFeature()

....to obtain the pair I am looking for.

I'll try that...
</pre>
</blockquote>
Yes, that's the idea.&nbsp; You'll see it's used in the CrossReferencers.<br>
</body>
</html>

--------------030908020709060104020601--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Extending a model
Next Topic:[CDO] CDO and RAP
Goto Forum:
  


Current Time: Fri Apr 26 01:31:58 GMT 2024

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

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

Back to the top