Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Notification: how to not get our own modifications?
EMF Notification: how to not get our own modifications? [message #965947] Wed, 31 October 2012 16:31 Go to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Hi,

I have two pieces of code modifying the same EMF model.

When one modifies it, notifications are sent, to everyone, including the one that modifies it.

Is there any way to detect who did the modification that made the notification happen?

My only need is to be able, when I modify a model, to detect in my listener that I was the one actually modifying the model.

Thank you for any help :)
Re: EMF Notification: how to not get our own modifications? [message #966011 is a reply to message #965947] Wed, 31 October 2012 17:32 Go to previous messageGo to next message
Justin T is currently offline Justin TFriend
Messages: 1
Registered: October 2012
Junior Member
Hi,

You can access to the notifier by using the method "getNotifier()" of the Notification object.

For example:
class Observer extends AdapterImpl
{
	@Override
	public void notifyChanged(Notification notification)
	{
		if(notification.isTouch())
                   return;
                
                if(notification.getNotifier() == ...)
                ...
	}
}


Regards,
Justin
Re: EMF Notification: how to not get our own modifications? [message #966232 is a reply to message #965947] Wed, 31 October 2012 21:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26287
Registered: July 2009
Senior Member
Victor,

There's no way to know what/who caused the change. Of course if you did
the modification, you already know you'll get a notification for that...

On 31/10/2012 5:31 PM, Victor Mising name wrote:
> Hi,
>
> I have two pieces of code modifying the same EMF model.
>
> When one modifies it, notifications are sent, to everyone, including
> the one that modifies it.
>
> Is there any way to detect who did the modification that made the
> notification happen?
>
> My only need is to be able, when I modify a model, to detect in my
> listener that I was the one actually modifying the model.
>
> Thank you for any help :)
Re: EMF Notification: how to not get our own modifications? [message #966875 is a reply to message #966232] Thu, 01 November 2012 09:53 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi

An approach that I've used to break similar selectionChanged loops is to
have a private e.g. selectionChanging normally falsevariable. In the
handler, if the variable is false is it is set true to indicate
processing a selection change and restored in a finally clause. If
already set you know that you're in a nested loop and should probably
just return promptly.

Regards

Ed Willink


On 31/10/2012 21:29, Ed Merks wrote:
> Victor,
>
> There's no way to know what/who caused the change. Of course if you
> did the modification, you already know you'll get a notification for
> that...
>
> On 31/10/2012 5:31 PM, Victor Mising name wrote:
>> Hi,
>>
>> I have two pieces of code modifying the same EMF model.
>>
>> When one modifies it, notifications are sent, to everyone, including
>> the one that modifies it.
>>
>> Is there any way to detect who did the modification that made the
>> notification happen?
>>
>> My only need is to be able, when I modify a model, to detect in my
>> listener that I was the one actually modifying the model.
>>
>> Thank you for any help :)
>
Re: EMF Notification: how to not get our own modifications? [message #966891 is a reply to message #966875] Thu, 01 November 2012 10:11 Go to previous message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Hi,

Thanks you all for your insight.

Justin: As the other said, I'm looking for who did the change, not who was changed Smile
Ed&Ed (Razz): So, if I understand well, the only possibility is to handle that at the modifying place itself, but EMF can't help me.
Previous Topic:[CDO] Access to password on the server
Next Topic:Reading attribute value from EObject programmatically
Goto Forum:
  


Current Time: Mon Dec 22 05:36:51 GMT 2014

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

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