Skip to main content



      Home
Home » Modeling » Papyrus » How to detect property changes
How to detect property changes [message #747888] Mon, 24 October 2011 06:42 Go to next message
Eclipse UserFriend
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 07:11 Go to previous messageGo to next message
Eclipse UserFriend
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 07:58] by Moderator

Re: How to detect property changes [message #752357 is a reply to message #747888] Wed, 26 October 2011 07:13 Go to previous messageGo to next message
Eclipse UserFriend
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 10:41 Go to previous messageGo to next message
Eclipse UserFriend
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 10:24 Go to previous message
Eclipse UserFriend
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 Jul 03 05:17:37 EDT 2025

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

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

Back to the top