Handling instances of extended classes during runtime [message #1838296] |
Sat, 20 February 2021 16:28  |
Eclipse User |
|
|
|
Hello everyone!
Since this is my first post here, a little bit about my background beforehand - I'm an industrial automation engineer dabbling in DSL engineering with EMF/Sirius since 2016 (I'm in love with it, pure genius, a big thanks to all creators and contributors). My level of expertise is therefore predominantly low-level programming similar to embedded systems development. When it comes to DSL engineering and Sirius, I would consider myself an aspiring intermediate, however still on the beginner level. Until now I've went through all what I could find online and managed to create a couple of simple but useful DSLs. For the past 6 months I've been creating a more comprehensive modeling tool. Some time ago I hit a wall, and after several weeks of trying anything and everything, I think I'm losing my mind, if there is something still left there. Help!;)
The problem is complex (at least for me), I'll do my best to represent it as simple as possible:
What I want to do:
Theoretically, I would like to implement the pattern called "dynamic features". Practically, I would like to extend (reuse some properties of) the EAttribute structural feature in my metamodel (EClass Var with SuperType EAttribute). The goal is to, if another class from the metamodel (VarContainer) containing 0..* Vars is instantiated during runtime, i can add its children (Var instances) and determine their types dynamically. This functions perfectly when creating dynamic model instances directly from the metamodel ("offline").
The problem:
During runtime, instances of the VarContainer report the error
Cannot invoke
"org.eclipse.emf.edit.provider.IItemLabelProvider.getImage(Object)" because "itemLabelProvider" is null .
No children (Vars) can therefore be added during runtime. Furthermore, the existing VarContainer children are not rendered/parsed properly in the ModelExplorer, only textual representation is shown:
org.eclipse.emf.ecore.impl.EAttributeImpl@6f48bbde(eClass: org.eclipse.emf.ecore.impl.EclassImpl@122707013b (name:VAR) (instanceClassName: VarInstance)(abstract:false, interace:false))(name: ID)(ordered:true, unique:true, lowerBound:0, upperBound:1)
nor can they be accessed through custom diagrams, even though the Eclass Information shows the proper Ecore structure with all EAttribute properties. No Eclass Information is shown for the VarContainer instances.
What I've tried so far:
-Every variant of "electrical engineers first remedy" - turn off and on, uninstall, reinstall, different versions, variants, even computers :) - to no avail
-adapting Java versions and different path configurations
-all thinkable plugin combinations (I always come back to these though, there seems to be something rotten there)
-all thinkable combinations of Label Provider Generator configurations
-searching every nook and cranny on the community forums (here and EMF / Eclipse / Java in general).
-...
A weird coincidence that somehow seems to have something to do with this:
- In the offline Ecore metamodel, no properties are shown for attributes of any class (the Ecore Page in the properties view is completely empty). In the Table view they can be accessed and changed without problems.
I'd be very grateful for any kind of assistance or a clue. I'm aware that the question is chaotic to say the least, I'll be glad to provide any further needed information or explanations.
Thanks a bunch !
PS I'm using the LSV Eclipse & Sirius, but have also tried older versions
[Updated on: Mon, 22 February 2021 17:51] by Moderator
|
|
|
|
|
Re: Handling instances of extended classes during runtime [message #1838416 is a reply to message #1838413] |
Wed, 24 February 2021 09:48   |
Eclipse User |
|
|
|
Hi Laurent and Ed,
thank you very much for your replies!
@ Laurent
I think I will try to post to the general EMF Forum as well, however my initial thoughts were to ask here because the "error" happens during model rendering, quasi closer to the Sirius dominion (and also, Sirius is the new GMF, or am I understanding something wrong?:-)
@Ed
Yeah, I was thinking from your previous posts that you might say something like that. Now after some time of trying it, I think I also know why:D
But I still do not really understand it - why is it possible to define an EClass with an Ecore SuperType at all? And why does the reflective tree editor have no problem whatsoever with rendering them (with the full set of the SuperType properties) when creating dynamic model instances ("offline"), but this seems to not be possible (for me at least:) during runtime?
I know I'm on the fringe territory here, but is there any way to "trick" the runtime instances to be rendered in the same way the dynamic instances are offline?
Thanks again!
Cheers
Goran
PS I'm aware that what I'm actually trying to do here is cheat my way through "pushing" the class-object relationship a metalevel down, so that users can create type-classes (or in my case Attributes i.e. Vars), which can than be instantiated (by users). Seems to be so close yet so far:-)
[Updated on: Wed, 24 February 2021 09:59] by Moderator
|
|
|
|
Re: Handling instances of extended classes during runtime [message #1838426 is a reply to message #1838419] |
Wed, 24 February 2021 12:50  |
Eclipse User |
|
|
|
Hi
EMF does not go out of its way to prevent you being possibly stupid since what you are doing might be innovative, but if you do questionable things expect trouble, so somethings may fail and confusingly others may not. Reflectively you do not need to satisfy the stronger disciplines of Java generation so you may get away with more.
If you want your own metametamodel then design it/clone it, don't try to morph Ecore.
Regards
Ed Willink
|
|
|
Powered by
FUDForum. Page generated in 0.03248 seconds