Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to listen to location (and other layout constraint) changes of a node?
How to listen to location (and other layout constraint) changes of a node? [message #498191] Sun, 15 November 2009 18:36 Go to next message
TL is currently offline TLFriend
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
Re: How to listen to location (and other layout constraint) changes ofa node? [message #500780 is a reply to message #498191] Sat, 28 November 2009 16:12 Go to previous message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello T,

> (actually they are copies) on the other diagram. I decided to achieve
> this with the notification mechanism provided by EMF.
You have to whare editing domain across both diagram editors to be able to
capture notification events coming from one diagram on an another one.

-----------------
Alex Shatalin
Previous Topic:What happend to "generate GEF only"?
Next Topic:Diagram Partitioning
Goto Forum:
  


Current Time: Tue Apr 23 12:19:54 GMT 2024

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

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

Back to the top