Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Reacting to changes in other resources in the same TransactionalEditingDomain
Reacting to changes in other resources in the same TransactionalEditingDomain [message #484838] Wed, 09 September 2009 13:32 Go to next message
Ozgun  is currently offline Ozgun Friend
Messages: 30
Registered: August 2009
Member
Dear GMF community,

in my TransactionalEditingDomain there are two resources:

1) LazyLinkingResource (which is an XtextResource which again is an
EMFResource)
2) GMFResource

They are sharing the domain model so if my model is changed in the
resource of the textual editor, then the graphical diagram adapts the
changes.

Now exactly at that point, where the GMF editors refreshes according to
the changes in the model, I want to trigger our layouter.

The point is, that we do _not_ want to auto-layout any changes, but only
after changes that come from the textual editor.

I am guessing that this is a two-step process where I first listen to
the model change from the text editor and then fire something in the
graphical editor, but I cannot find the point to dock.

At this point, I have call my layouter from the handleElementChange()
method in ???DiagramProvider and it works but I am sure there is a
better suiting way than modifying generated code!


Any hint, help and advice is greatly appreciated!

Thank you

Özgün
Re: Reacting to changes in other resources in the same TransactionalEditingDomai [message #484919 is a reply to message #484838] Wed, 09 September 2009 16:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news.sascha.gessler.googlemail.com

Hi Özgün,

> I am guessing that this is a two-step process where I first listen to
> the model change from the text editor and then fire something in the
> graphical editor, but I cannot find the point to dock.

EMF has the possibility to inform observers / listeners about changes in
the model. You can listen to changes of an individual object and to
changes to all objects in a collection.

For example if PersonList is an model element of yours you can listen for
changes like this:

ModelFactory factory = ModelFactory.eINSTANCE;
PersonList persons = factory.createIPersonList();

Adapter adapter = new AdapterImpl() {

public void notifyChanged(Notification notification) {
System.out.println("Notfication received. Data model has changed!!!");
}
};

persons.eAdapters().add(adapter);

Therefore you simply acquire a reference to your model element and
register a listener as shown in the example above.

More informations can be found at
http://www.vogella.de/articles/EclipseEMF/article.html


Cheers,

sas
Re: Reacting to changes in other resources in the same TransactionalEditingDomai [message #485052 is a reply to message #484919] Thu, 10 September 2009 11:28 Go to previous message
Ozgun  is currently offline Ozgun Friend
Messages: 30
Registered: August 2009
Member
> ModelFactory factory = ModelFactory.eINSTANCE;
> PersonList persons = factory.createIPersonList();
>
> Adapter adapter = new AdapterImpl() {
>
> public void notifyChanged(Notification notification) {
> System.out.println("Notfication received. Data model has
> changed!!!");
> }
> };
>
> persons.eAdapters().add(adapter);
Thanks Sascha, but this would listen to every model change, would it
not? I want to kind of filter the model changes that come from the
textual editor. When the user adds a node using the palette then no auto
layout should be triggered of course.

As I said, currentyl I have changed the handleElementChanged method of
???DocumentProvider, but this looks hacky to me.
Previous Topic:Change a reference from the owner, after creating a new object in one command (EMF/GEF/GMF)?
Next Topic:Create Diagram from xml source
Goto Forum:
  


Current Time: Wed Apr 24 23:29:55 GMT 2024

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

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

Back to the top