Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to detect property changes
How to detect property changes [message #747888] Mon, 24 October 2011 10:42 Go to next message
Neslepaks  is currently offline Neslepaks Friend
Messages: 37
Registered: April 2011
Member
Hi,

I would need to know programmatically if a property of an UML element is changed. I'm not sure if this is more EMF/GMF related than Papyrus, but maybe Papyrus provides some help, as the changes are done via Papyrus perspective.

I guess I need something like property change listener. From where should I start in this case? Is there any tutorial?
Re: How to detect property changes [message #747926 is a reply to message #747888] Mon, 24 October 2011 11:11 Go to previous messageGo to next message
Neslepaks  is currently offline Neslepaks Friend
Messages: 37
Registered: April 2011
Member
I found out that this kind of functionality seems nice (http://wiki.eclipse.org/EMF/FAQ#How_can_I_easily_listen_to_changes_for_a_specific_object.3F) tough it has a problem. I have created an action that generates elements to diagram using a non-standard way. Adding the listener for those is easy.

So, how could I implement the same functionality for those elements that are generated from the default palette?

[Updated on: Mon, 24 October 2011 11:58]

Report message to a moderator

Re: How to detect property changes [message #752357 is a reply to message #747888] Wed, 26 October 2011 11:13 Go to previous messageGo to next message
Neslepaks  is currently offline Neslepaks Friend
Messages: 37
Registered: April 2011
Member
When using this code,
eObject.eAdapters().add
  (new AdapterImpl()
   {
     @Override
     public void notifyChanged(Notification msg)
     {
       // Look at notification to see what's changed.
     } 
   });


it is easy to get the oldValue and newValue from msg if the changed property has been for example package name. Thus msg.getFeature() is instance of EAttribute.

But if the user changes property which is a tagged value of stereotype then the msg.getFeature() is instance of EReference. How can I get the old value and new Value from EReference?
Re: How to detect property changes [message #752848 is a reply to message #752357] Wed, 26 October 2011 14:41 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Hey Neslepaks,

I may not get your question right, but what about the ModelListener
extension point provided by Papyrus? You can easily provide an extension for
this extension point and you will get notified whenever a feature changed in
your model... I think this should work for you...

Regards,
Timothy

"Neslepaks" schrieb im Newsbeitrag news:j88paf$jbg$1@news.eclipse.org...

When using this code,

eObject.eAdapters().add
(new AdapterImpl()
{
@Override
public void notifyChanged(Notification msg)
{
// Look at notification to see what's changed.
}
});


it is easy to get the oldValue and newValue from msg if the changed property
has been for example package name. Thus msg.getFeature() is instance of
EAttribute.

But if the user changes property which is a tagged value of stereotype then
the msg.getFeature() is instance of EReference. How can I get the old value
and new Value from EReference?
Re: How to detect property changes [message #755463 is a reply to message #752848] Tue, 08 November 2011 15:24 Go to previous message
Neslepaks  is currently offline Neslepaks Friend
Messages: 37
Registered: April 2011
Member
Thanks! That was what I was looking for.
Previous Topic:Creating a SysML model
Next Topic:How to model a network switch as a predefined type?
Goto Forum:
  


Current Time: Thu Mar 28 21:58:09 GMT 2024

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

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

Back to the top