[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.tools.emf] Re: EContentAdapter for all new Model instances
|
- From: Ed Merks <Ed.Merks@xxxxxxxxx>
- Date: Fri, 11 Sep 2009 09:41:13 -0400
- Newsgroups: eclipse.tools.emf
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.23 (Windows/20090812)
Hauke,
Comments below.
Hauke Fuhrmann wrote:
Ed Merks schrieb:
Now I want to observe *any* new model instance of my metamodel. Is
there a way to automatically add such adapter to the model at
creation or loading? Where is the best point to hook that in?
You can add an EContentAdapter to a ResourceSet and then it will be
added to all objects contained by that resource set.
But I want to add it also automatically to all new resources created
for a specific metamodel.
Resources aren't necessarily created specific to a model and as I
suggested you could do it in your resource factory.
I'm tempted to ask what you're trying to accomplish though. For
example, the XSD model is "self adapting" because it uses
notifications internally to keep the DOM in sync with the model, but
it doesn't do that by attaching adapters...
It sounds something like exactly that.
I have a metamodel with a String attribute in some object and a lot of
complicated child objects. The String is a convenience represenation
of those child objects and I have a String parser and serializer that
is able to convert the String into the child object set and vice versa.
So what I wanna do is whenever somebody changes such a String, it
should trigger my parser and vice versa if any of the child object
have changed, the serializer should update the String.
So you might be better to override eNotificationRequired to be true, and
specialize eNotify to not only forward the notifications to the adapters
list (calling super) but also do some processing internal to the model.
Additionally the serialization is dependent on some referenced objects
somewhere else so I have also to monitor them.
So how can such "self adapting" be done. Sounds like something I could
also use.
@Override
public boolean eNotificationRequired()
{
return true;
}
@Override
public void eNotify(Notification msg)
{
// Internal model processing...
super.eNotify(msg);
}
Cheers,
Hauke