Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Compilation error with Eclipse 3.5 and EMF 2.5
Compilation error with Eclipse 3.5 and EMF 2.5 [message #481559] Fri, 21 August 2009 14:35 Go to next message
Eclipse UserFriend
Originally posted by: mluchian.interpro.qc.ca

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hello, <br>
<br>
I recently updated to Eclipse 3.5 and EMF 2.5 and I have the following
problem when getting EMF attributes in a panel. This problem was not
present in EMF 2.4. <br>
<br>
My code is the following:<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (Iterator&lt;IItemPropertyDescriptor&gt; i =
detailPropertyDescriptors.iterator(); i.hasNext();)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; final IItemPropertyDescriptor desc =
(IItemPropertyDescriptor) i.next();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; EObjectImpl dataHolderObject = (EObjectImpl)
desc.getFeature(input);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Object dataValue = ((EObjectImpl)
adapterFactoryItemDelegator.getEditableValue(input)).eGet((E StructuralFeature)
dataHolderObject);<br>
<br>
<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if (<u>((EAttributeImpl) dataHolderObject)</u>.getName().equals("name" ))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }&nbsp; <br>
<br>
I get a compilation error in the underlined code saying "Cannot cast
from EObjectImpl to EAttributeImpl", so my conlusion is that the EMF
API has changed. How could I fix my problem, as I need to get all
attributes in the implemented EMF object and test whether the attribute
is a "name", etc, etc. <br>
<br>
Thanks, <br>
<br>
Mircea<br>
</body>
</html>
Re: Compilation error with Eclipse 3.5 and EMF 2.5 [message #481570 is a reply to message #481559] Fri, 21 August 2009 15:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080002010207060106030302
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Mircea,

Comments below.


M. Luchian wrote:
> Hello,
>
> I recently updated to Eclipse 3.5 and EMF 2.5 and I have the following
> problem when getting EMF attributes in a panel. This problem was not
> present in EMF 2.4.
>
> My code is the following:
>
> for (Iterator<IItemPropertyDescriptor> i =
> detailPropertyDescriptors.iterator(); i.hasNext();)
> {
> final IItemPropertyDescriptor desc =
> (IItemPropertyDescriptor) i.next();
> EObjectImpl dataHolderObject = (EObjectImpl)
> desc.getFeature(input);
Why case cast to an Impl class? You should cast to EObject or
InternalEObject not to one of the specific Impl classes.
> Object dataValue = ((EObjectImpl)
> adapterFactoryItemDelegator.getEditableValue(input)).eGet((E StructuralFeature)
> dataHolderObject);
>
>
> if (_((EAttributeImpl)
> dataHolderObject)_.getName().equals("name"))
Again, why cast to an Impl? Why not to EAttribute? I see this so
often, and I ask people why they do this yet no one has ever explained
why...
>
> {
>
> }
> }
>
> I get a compilation error in the underlined code saying "Cannot cast
> from EObjectImpl to EAttributeImpl", so my conlusion is that the EMF
> API has changed.
No, in the implementation changed and you've been relying on
implementation details. Don't do that. Delete the bogus "Impl" parts
of your code above?
> How could I fix my problem, as I need to get all attributes in the
> implemented EMF object and test whether the attribute is a "name",
> etc, etc.
>
> Thanks,
>
> Mircea

--------------080002010207060106030302
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">
Mircea,<br>
<br>
Comments below.<br>
<br>
<br>
M. Luchian wrote:
<blockquote cite="mid:h6mbb4$ha3$1@build.eclipse.org" type="cite">Hello,
<br>
<br>
I recently updated to Eclipse 3.5 and EMF 2.5 and I have the following
problem when getting EMF attributes in a panel. This problem was not
present in EMF 2.4. <br>
<br>
My code is the following:<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (Iterator&lt;IItemPropertyDescriptor&gt; i =
detailPropertyDescriptors.iterator(); i.hasNext();)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; final IItemPropertyDescriptor desc =
(IItemPropertyDescriptor) i.next();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; EObjectImpl dataHolderObject = (EObjectImpl)
desc.getFeature(input);<br>
</blockquote>
Why case cast to an Impl class?&nbsp; You should cast to EObject or
InternalEObject not to one of the specific Impl classes.<br>
<blockquote cite="mid:h6mbb4$ha3$1@build.eclipse.org" type="cite">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Object dataValue = ((EObjectImpl)
adapterFactoryItemDelegator.getEditableValue(input)).eGet((E StructuralFeature)
dataHolderObject);<br>
<br>
<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if (<u>((EAttributeImpl) dataHolderObject)</u>.getName().equals("name" ))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;
<br>
</blockquote>
Again, why cast to an Impl?&nbsp; Why not to EAttribute?&nbsp; I see this so
often, and I ask people why they do this yet no one has ever explained
why...<br>
<blockquote cite="mid:h6mbb4$ha3$1@build.eclipse.org" type="cite">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }&nbsp; <br>
<br>
I get a compilation error in the underlined code saying "Cannot cast
from EObjectImpl to EAttributeImpl", so my conlusion is that the EMF
API has changed. </blockquote>
No, in the implementation changed and you've been relying on
implementation details.&nbsp; Don't do that.&nbsp; Delete the bogus "Impl" parts
of your code above?<br>
<blockquote cite="mid:h6mbb4$ha3$1@build.eclipse.org" type="cite">How
could I fix my problem, as I need to get all
attributes in the implemented EMF object and test whether the attribute
is a "name", etc, etc. <br>
<br>
Thanks, <br>
<br>
Mircea<br>
</blockquote>
</body>
</html>

--------------080002010207060106030302--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Compilation error with Eclipse 3.5 and EMF 2.5 [message #481600 is a reply to message #481570] Fri, 21 August 2009 17:23 Go to previous message
Eclipse UserFriend
Originally posted by: mluchian.interpro.qc.ca

<!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">
Thanks Ed, <br>
It was my mistake. I made the changes and everything compiles now. <br>
Mircea<br>
<br>
Ed Merks wrote:
<blockquote cite="mid:h6mejg$sdm$1@build.eclipse.org" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Mircea,<br>
<br>
Comments below.<br>
<br>
<br>
M. Luchian wrote:
<blockquote cite="mid:h6mbb4$ha3$1@build.eclipse.org" type="cite">Hello,
<br>
<br>
I recently updated to Eclipse 3.5 and EMF 2.5 and I have the following
problem when getting EMF attributes in a panel. This problem was not
present in EMF 2.4. <br>
<br>
My code is the following:<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (Iterator&lt;IItemPropertyDescriptor&gt; i =
detailPropertyDescriptors.iterator(); i.hasNext();)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; final IItemPropertyDescriptor desc =
(IItemPropertyDescriptor) i.next();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; EObjectImpl dataHolderObject = (EObjectImpl)
desc.getFeature(input);<br>
</blockquote>
Why case cast to an Impl class?&nbsp; You should cast to EObject or
InternalEObject not to one of the specific Impl classes.<br>
<blockquote cite="mid:h6mbb4$ha3$1@build.eclipse.org" type="cite">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Object dataValue = ((EObjectImpl)
adapterFactoryItemDelegator.getEditableValue(input)).eGet((E StructuralFeature)
dataHolderObject);<br>
<br>
<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; if (<u>((EAttributeImpl) dataHolderObject)</u>.getName().equals("name" ))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;
<br>
</blockquote>
Again, why cast to an Impl?&nbsp; Why not to EAttribute?&nbsp; I see this so
often, and I ask people why they do this yet no one has ever explained
why...<br>
<blockquote cite="mid:h6mbb4$ha3$1@build.eclipse.org" type="cite">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }&nbsp; <br>
<br>
I get a compilation error in the underlined code saying "Cannot cast
from EObjectImpl to EAttributeImpl", so my conlusion is that the EMF
API has changed. </blockquote>
No, in the implementation changed and you've been relying on
implementation details.&nbsp; Don't do that.&nbsp; Delete the bogus "Impl" parts
of your code above?<br>
<blockquote cite="mid:h6mbb4$ha3$1@build.eclipse.org" type="cite">How
could I fix my problem, as I need to get all
attributes in the implemented EMF object and test whether the attribute
is a "name", etc, etc. <br>
<br>
Thanks, <br>
<br>
Mircea<br>
</blockquote>
</blockquote>
<br>
</body>
</html>
Previous Topic:Dynamically adding a new feature to existing model object
Next Topic:Databind enable state to multiple attributes
Goto Forum:
  


Current Time: Fri Apr 19 22:41:29 GMT 2024

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

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

Back to the top