Home » Modeling » EMF » overload add operation in EMF generated editor
| | | | |
Re: overload add operation in EMF generated editor [message #486975 is a reply to message #486894] |
Mon, 21 September 2009 11:16 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Marcin,
Comments below.
Marcin Cylke wrote:
> Hi
>
> Well, I've managed to fix my problems with that. I misinterpreted You
> first reply, did some errors by myself. But eventually more debugging
> of the EMF behavior helped.
>
> However I have some other problem. I have a generated model. I have a
> collection of objectA in it. Now, I have to put an instance of PXModel
> into my EMF model, so that I can govern its objects from other places.
I'm not sure I follow what you're saying...
> I'd like to have collection from innerModel synchronized with types
> from Model. That is why I'd like to return that collection when types
> == null. Like this:
>
>
> public EList<ObjectA> getTypes() {
> if (types == null) {
> types = innerModel.getCollection();
> }
> return types;
> }
>
>
> But doing this way my model isn't updated - lacks behavior of
> EObjectContainmentEList.
Is this list supposed to be a read only view or can it be modified.
> Is there a way of "casting" EList to EObjectContainmentEList. Or maybe
> there is some other solution?
It sounds more like you should attach an adapter to the inner model and
as the feature changes, make corresponding changes here.
> I've tried to use eInverseAdd - but that doesn't work for me.
>
> Well, it may look ugly, but seems like the fastest solution to my
> problem.
>
> Here is the concept of the situation:
>
> class Model {
>
> private PXModel innerModel;
>
> protected EList<ObjectA> types;
>
> [...]
>
> public EList<ObjectA> getTypes() {
> if (types == null) {
> types = new
> EObjectContainmentEList<ObjectA>(ObjectA.class, this,
> ModelPackage.PX_MODEL__TYPES);
> }
> return types;
> }
> }
>
> and
> class PXModel {
>
> protected EList<ObjectA> collection;
>
> public EList<ObjectA> getCollection() {
> return collection;
> }
> }
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: overload add operation in EMF generated editor [message #487453 is a reply to message #487339] |
Wed, 23 September 2009 10:10 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Marcin,
Comments below.
Marcin Cylke wrote:
> Ed Merks wrote on Mon, 21 September 2009 07:16
>> Marcin,
>>
>> > But doing this way my model isn't updated - lacks behavior of >
>> EObjectContainmentEList. Is this list supposed to be a read only view
>> or can it be modified.
>> > Is there a way of "casting" EList to EObjectContainmentEList. Or
>> maybe > there is some other solution?
>> It sounds more like you should attach an adapter to the inner model
>> and as the feature changes, make corresponding changes here.
>> >
>
>
> This is supposed to be a modifiable list.
So the adapting/shadowing of changes needs to be in both directions?
>
> Well, incorporating changes to the embeded object through adapter - or
> anything else, as you've described, would surely suffice. But how can
> I notice when the change on the collection occures? Since there is
> only a getter for it I don't know how should I find out about its
> contents change.
All features notify of changes, not just single valued features. In the
case of multi-valued features, any change to the list produces
notifications, e.g., ADD, REMOVE, and SET.
>
> Marcin
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Thu Sep 26 10:18:37 GMT 2024
Powered by FUDForum. Page generated in 0.06674 seconds
|