How to listen to location (and other layout constraint) changes of a node? [message #498191] |
Sun, 15 November 2009 18:36 |
TL Messages: 22 Registered: July 2009 |
Junior Member |
|
|
Hello,
In my use case I have to different diagram that are depicting 2
different perspectives on our models. Because these two perspectives are
partially showing the same information (nodes and relationships) i.e.,
they are not orthogonal, I need to reflect the changes made to the
diagram elements on one diagram to the same diagram elements (actually
they are copies) on the other diagram. I decided to achieve this with
the notification mechanism provided by EMF.
So far I could not figure out how to catch the appropriate notification
event, which would correspond to arbitrary layout constraint changes
(change of location, size...). Until now I was trying to use the following
events:
NotationPackage.NODE__LAYOUT_CONSTRAINT,
NotationPackage.LAYOUT_CONSTRAINT NotationPackage.LOCATION, LOCATION__X,
NotationPackage.LOCATION__Y
But it did not work. When I compared it to the
notification.getFeatureID(Node.class) it never was the same value. Btw.
the notification.getFeatureID(Node.class) always returns the number -1,
when I change the location of the original node. Am I doing something
wrong?
Here is the code I am using:
observedNode.eAdapters().add(new AdapterImpl(){
public void notifyChanged(Notification notification){
int notificationNumber = notification.getFeatureID(Node.class);
switch (notificationNumber)
{
case NotationPackage.LAYOUT_CONSTRAINT:
// code to handle layout constraint changes (e.g., location) of the
original node
doSomething()
break;
}
}
});
Btw: I decided to use the notification mechanism without Adapter
Factories (I could not find any good examples, which would clear it up
to me). If anyone has good guide about the notification mechanism with
some examples (not the EMF documentation, which did not clear up things
to me).
Best wishes,
Tomaz
|
|
|
|
Powered by
FUDForum. Page generated in 0.02226 seconds