Reacting to changes in other resources in the same TransactionalEditingDomain [message #484838] |
Wed, 09 September 2009 13:32 |
Ozgun 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 |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02728 seconds