Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Debug Variables view and EObject Logical Structure
Debug Variables view and EObject Logical Structure [message #644100] Thu, 09 December 2010 13:50 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I'm using dynamic EObjects a lot and when debugging it is very difficult
to see the the feature values. Eclipse provides so-called Logical
Structures for providing custom tree views of objects. I wonder if
anyone has tried to provide such for EObjects? I have tried myself, but
haven't been able to create a working snippet. The following gives the
error that the package org.eclipse.emf.js4emf cannot be found:

org.eclipse.emf.common.util.EList<org.eclipse.emf.eco re.EStructuralFeature>
features = this.eClass().getEAllStructuralFeatures();
java.util.Map.Entry[] entries = new java.util.Map.Entry[features.size()];
for (int i = 0; i < features.size(); i++) {
org.eclipse.emf.ecore.EStructuralFeature feature = features.get(i);
entries[i] = new
org.eclipse.emf.js4emf.ui.MapEntryImpl(feature.getName(),
this.eGet(feature));
}
return entries;

Hallvard
Re: Debug Variables view and EObject Logical Structure [message #644163 is a reply to message #644100] Thu, 09 December 2010 17:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Hallvard,

Comments below.


Hallvard Trætteberg wrote:
> Hi,
>
> I'm using dynamic EObjects a lot and when debugging it is very
> difficult to see the the feature values. Eclipse provides so-called
> Logical Structures for providing custom tree views of objects. I
> wonder if anyone has tried to provide such for EObjects?
Yes, I know that IBM did such a thing internally.
> I have tried myself, but haven't been able to create a working
> snippet. The following gives the error that the package
> org.eclipse.emf.js4emf cannot be found:
>
> org.eclipse.emf.common.util.EList<org.eclipse.emf.eco re.EStructuralFeature>
> features = this.eClass().getEAllStructuralFeatures();
> java.util.Map.Entry[] entries = new java.util.Map.Entry[features.size()];
> for (int i = 0; i < features.size(); i++) {
> org.eclipse.emf.ecore.EStructuralFeature feature = features.get(i);
> entries[i] = new
> org.eclipse.emf.js4emf.ui.MapEntryImpl(feature.getName(),
> this.eGet(feature));
What's giving that error. Are you missing a dependency in the
MANIFEST.MF for this? Do you really need a special implementation of
the map entry? I.e., why not just use a linked hash map?
> }
> return entries;
>
> Hallvard


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Debug Variables view and EObject Logical Structure [message #644287 is a reply to message #644163] Fri, 10 December 2010 12:07 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 09.12.10 18.30, Ed Merks wrote:
>>
> Yes, I know that IBM did such a thing internally.
>> I have tried myself, but haven't been able to create a working
>> snippet. The following gives the error that the package
>> org.eclipse.emf.js4emf cannot be found:
>>
> What's giving that error. Are you missing a dependency in the
> MANIFEST.MF for this? Do you really need a special implementation of the
> map entry? I.e., why not just use a linked hash map?

I also thought the problem was a missing dependency, but the package is
exported and in the same plugin as the extension point. The strange
thing is that the MapEntryImpl is in org.eclipse.emf.js4emf.ui, not
org.eclipse.emf.js4emf. I don't know exactly in what context the code
snippet is evaluated in, so it's difficult to interpret to message.

The snippet should return the logical contents of the EObject, so I
though it needed to return an array of entries, rather than a Map. But
you're right, it works with a map, as follows:

org.eclipse.emf.common.util.ELis<org.eclipse.emf.ecore.EStructuralFeature >
features = this.eClass().getEAllStructuralFeatures();
java.util.Map map = new java.util.HashMap();
for (int i = 0; i < features.size(); i++) {
org.eclipse.emf.ecore.EStructuralFeature feature = features.get(i);
map.put(feature.getName(), this.eGet(feature));
}
return map;

You get the look & feel of an array of key/value pairs, though, not a
list of fields like in the native case.

I guess registering this snippet for
org.eclipse.emf.ecore.impl.DynamicEObjectImpl is best, although it may
also be used for subclasses with dynamic features.

Hallvard
Re: Debug Variables view and EObject Logical Structure [message #644301 is a reply to message #644287] Fri, 10 December 2010 13:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Hallvard,

Comments below.

Hallvard Trætteberg wrote:
> On 09.12.10 18.30, Ed Merks wrote:
>>>
>> Yes, I know that IBM did such a thing internally.
>>> I have tried myself, but haven't been able to create a working
>>> snippet. The following gives the error that the package
>>> org.eclipse.emf.js4emf cannot be found:
>>>
>> What's giving that error. Are you missing a dependency in the
>> MANIFEST.MF for this? Do you really need a special implementation of the
>> map entry? I.e., why not just use a linked hash map?
>
> I also thought the problem was a missing dependency, but the package
> is exported and in the same plugin as the extension point. The strange
> thing is that the MapEntryImpl is in org.eclipse.emf.js4emf.ui, not
> org.eclipse.emf.js4emf. I don't know exactly in what context the code
> snippet is evaluated in, so it's difficult to interpret to message.
You can't run it under debug control to set breakpoints?
>
> The snippet should return the logical contents of the EObject, so I
> though it needed to return an array of entries, rather than a Map. But
> you're right, it works with a map, as follows:
>
> org.eclipse.emf.common.util.ELis<org.eclipse.emf.ecore.EStructuralFeature >
> features = this.eClass().getEAllStructuralFeatures();
> java.util.Map map = new java.util.HashMap();
> for (int i = 0; i < features.size(); i++) {
> org.eclipse.emf.ecore.EStructuralFeature feature = features.get(i);
> map.put(feature.getName(), this.eGet(feature));
> }
> return map;
A LinkedHashMap is likely to give you a more predictable/determinstic
feature order.
>
> You get the look & feel of an array of key/value pairs, though, not a
> list of fields like in the native case.
Yes, it's nice to hide lots of the implementation details. One might
test for things like being a proxy and show things like the eContainer
or eDirectResource; stuff that's lurking in the properties holder or the
array of slots in MinimalEObjectImpl...
>
> I guess registering this snippet for
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl is best, although it may
> also be used for subclasses with dynamic features.
Not sure how the registration works (you can't register it against an
interface like InternalEObject?) but it's expected that all
implementations of EObject ultimately extend BasicEObjectImpl.
>
> Hallvard


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Debug Variables view and EObject Logical Structure [message #644560 is a reply to message #644301] Mon, 13 December 2010 09:41 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 10.12.10 14.09, Ed Merks wrote:
>>I don't know exactly in what context the code
>> snippet is evaluated in, so it's difficult to interpret to message.
> You can't run it under debug control to set breakpoints?

I don't see a way of setting breakpoints in the snippet, since the
snippet is not technically part of the code that is debugged. From the
code, I get the impression that the snippet is executed "internally"
within the debug machinery on "the other side".

> A LinkedHashMap is likely to give you a more predictable/determinstic
> feature order.

OK.

>> I guess registering this snippet for
>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl is best, although it may
>> also be used for subclasses with dynamic features.
> Not sure how the registration works (you can't register it against an
> interface like InternalEObject?) but it's expected that all
> implementations of EObject ultimately extend BasicEObjectImpl.

The registration is for a class/interface (name). The key is to enable
it for implementations that are *not* generated, since these will
normally have a nice tree view with easily identifyable features.

Hallvard
Previous Topic:[GWT] How to transfer EMF models without Google App Engine
Next Topic:Securing the save process in EMF
Goto Forum:
  


Current Time: Thu Mar 28 20:55:49 GMT 2024

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

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

Back to the top