Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Listen to part of Model
Listen to part of Model [message #810722] Thu, 01 March 2012 13:28 Go to next message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
Hi,
I have an emf editor in my rcp client and a treeviewer that represents a part of this tree (some middle layers).

At present the tree does not recognize changes I do to the model through the emf model editor.
Is there a very nice possibility to listen to a part of this tree. It would be ugly if I had to create an observableValue for every Object/Reference/Attribute the treeviewer depends on. It would be also ugly if the treeviewer listens to all changes everywhere in the model.

Any ideas ?

Regards from germany
Re: Listen to part of Model [message #810739 is a reply to message #810722] Thu, 01 March 2012 13:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Markus,

Comments below.

On 01/03/2012 2:28 PM, Markus Jo wrote:
> Hi,
> I have an emf editor in my rcp client and a treeviewer that represents
> a part of this tree (some middle layers).
>
> At present the tree does not recognize changes I do to the model
> through the emf model editor.
Are you using AdapterFactoryContentProvider for it?
> Is there a very nice possibility to listen to a part of this tree. It
> would be ugly if I had to create an observableValue for every
> Object/Reference/Attribute the treeviewer depends on.
How are you rendering the tree? The generator editor shows how to use
EMF item providers to populate a tree and it already responds to
nofifications. There's also data binding support for this, though I'm
not so familiar with that.
> It would be also ugly if the treeviewer listens to all changes
> everywhere in the model.
You can listen to any object by adding an adapter to its eAdapters().
>
> Any ideas ?
>
> Regards from germany


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Listen to part of Model [message #822143 is a reply to message #810739] Fri, 16 March 2012 08:13 Go to previous messageGo to next message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
Hmm.....I tried a little bit....AdapterFactoryContentProvider probably will not work for me, because I dont want the model structure exactly in me Tree. I want to leave out some layers.

So I tried to make my viewer an adapter and add is as listener.......but I recognized that I have to add it to every element in the tree because changes of children do not inform its parent.
train.getRouteVariants().eAdapters().add(this);
....
....
train.getRouteVariants().getRoute().get(0).getMainRoute().getStops().getStop().get(0).eAdapters().add(this);


Is there a way to say "This is the adapter for this root list. Inform him about all changes of children and childrens children".
Re: Listen to part of Model [message #822158 is a reply to message #822143] Fri, 16 March 2012 08:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Markus,

An EContentAdapter is very useful. It attaches itself to the entire
containment tree. You can even attach it to a ResourceSet and listen to
everything that's happening.

On 16/03/2012 9:13 AM, Markus Jo wrote:
> Hmm.....I tried a little bit....AdapterFactoryContentProvider probably
> will not work for me, because I dont want the model structure exactly
> in me Tree. I want to leave out some layers.
>
> So I tried to make my viewer an adapter and add is as
> listener.......but I recognized that I have to add it to every element
> in the tree because changes of children do not inform its parent.
>
> train.getRouteVariants().eAdapters().add(this);
> ...
> ...
> train.getRouteVariants().getRoute().get(0).getMainRoute().getStops().getStop().get(0).eAdapters().add(this);
>
>
>
> Is there a way to say "This is the adapter for this root list. Inform
> him about all changes of children and childrens children".


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Listen to part of Model [message #822182 is a reply to message #822158] Fri, 16 March 2012 09:08 Go to previous message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
Thanks Ed,
I used it this way (where I create the treeviewer) and it works.

Train train = (Train) input.getModel();
		EContentAdapter eContentAdapter = new EContentAdapter(){

			@Override
			public void notifyChanged(Notification notification) {
				super.notifyChanged(notification);
				viewer.refresh();
			}
		};
		eContentAdapter.setTarget(train);
Previous Topic:[CDO] Metamodels in CDO & exceptions
Next Topic:EMF for code generation in EMF application
Goto Forum:
  


Current Time: Thu Apr 25 00:24:40 GMT 2024

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

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

Back to the top