|
Re: [EGL] CrossReferences [message #573741 is a reply to message #573719] |
Tue, 11 August 2009 17:18 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Ivosh,
Ivosh Musil wrote:
> Hi All
>
> I'm using EGL to generate (hypertext) HTML presentation of Ecore model.
Perhaps the EGLDoc example, which also generates HTML from Ecore models,
would be useful for you? Here's a link:
http://www.eclipse.org/gmt/epsilon/examples/index.php?exampl e=org.eclipse.epsilon.examples.egldoc
>
> I would like to have at any EObject section named "Where is used" which
> include links to all related EObjects (not only referenced and contained
> - it's easy - but these pointing to this EObject too).
>
> I have no success even I tried lot of ways how make it work:
>
> a) if I try use eCrossReferences() method on EObject then I will get
> some crossreferenced EObjects to my EObject. Unfortunately I have no
> chance to get associated feature because EObject.eCrossReferences()
> returns EContentEList.FeatureIterator but Epsilon identifies answer like
> untyped Sequence
The EObject interface defines EList<EObject> as the return type of
eCrossReferences. Are you using a different implementation of EObject?
Where does the EContentEList.FeatureIterator come from?
>
> Example:
>
> for (n in o.eCrossReferences()) {
> n.feature(); -- undefined method
> }
I ran an experiment with the following EOL code on the Ecore metamodel:
EClass.all.first.println();
for (crossRef in EClass.all.first.eCrossReferences()) {
(crossRef.name + ' ' + crossRef.eClass.name).println();
}
which prints:
EClass [name=EAttribute,
instanceClassName=org.eclipse.emf.ecore.EAttribute,
instanceClass=interface org.eclipse.emf.ecore.EAttribute,
defaultValue=null, instanceTypeName=org.eclipse.emf.ecore.EAttribute,
abstract=false, interface=false, ]
EStructuralFeature EClass
name EAttribute
ordered EAttribute
unique EAttribute
lowerBound EAttribute
upperBound EAttribute
.....
ETypedElement EClass
EStructuralFeature EClass
Property 'name' not found in object EGenericType []
(/Users/louis/Code/eclipse/workspaces/galileo/runtime-epsilo n/Scratchpad/CrossRefs.eol@3:14)
The first line of output tells us that EClass.all.first returns the
EAttribute class.
The second line of output tells us that the EStructuralFeature object
(of type EClass) cross references the EAttribute class.
The third line that the name object (of type EAttribute) cross
references the EAttribute class, and so on.
Finally, we get an error because name isn't defined on EGenericType.
This could be fixed with the following EOL code, which only prints an
object's name if the name property is defined for that object:
EClass.all.first.println();
for (crossRef in EClass.all.first.eCrossReferences()) {
if (crossRef.name.isDefined) {
(crossRef.name + ' ' + crossRef.eClass.name).println();
} else {
crossRef.println();
}
}
Apologies if this explanation is not very good. I always find ECore's
self-referencing nature a little hard to describe. Let me know if this
is unclear, and I'll devise a better example that doesn't use ECore.
>
> Maybe support of casting in Epsilon? Or possibility to include some Java
> code into EGL?
A bit more information on Epsilon... EOL, and hence EGL, is dynamically
typed - types aren't checked until runtime. Casting is not necessary,
because an object's type is always known at runtime.
Cheers,
Louis.
----
Louis Rose
Research Student
Department of Computer Science,
University of York,
Heslington, York, YO10 5DD, United Kingdom.
+44 1904 434762
Twitter: @louismrose
|
|
|
|
Powered by
FUDForum. Page generated in 0.40796 seconds