Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Capture the attribute change event
Capture the attribute change event [message #552809] Fri, 13 August 2010 15:47 Go to next message
Yu Sun is currently offline Yu SunFriend
Messages: 58
Registered: July 2009
Member
Hi everyone,

I am trying to have such a feature in my GMF editor:

When I make a change in an attribute of a certain element in the property view, I would like to do some customized operations. For example, when I change the attribute - Size to 4, I want to automatically add 4 children in this element.

So I am wondering how to capture the attribute change event, and where to put the customized operations.

Thanks a lot.

Yu
Re: Capture the attribute change event [message #640036 is a reply to message #552809] Thu, 18 November 2010 18:37 Go to previous message
Carlos  is currently offline Carlos Friend
Messages: 16
Registered: July 2009
Junior Member
Hi there,

In my GMF editor, I add/remove affixed children when I modify a property of the object.

To do this, I override method "handleNotificationEvent" in the XXXEditPart.java file.

For example, if you have an object called MyObject with an attribute called MyAttribute, the code would be something like this:

   /**
    * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#handlePropertyChangeEvent(java.beans.PropertyChangeEvent)
    */
   protected void handleNotificationEvent(Notification notification)
   {
      Object feature = notification.getFeature();
      if (notification.getFeature() instanceof EAttributeImpl
            && notification.getFeatureID(MyObject.class) == MyEditorPackage.MYOBJECT_MYATTRIBUTE)
      {
         // Place your code here
      }
      else
      {
         super.handleNotificationEvent(notification);
      }
   }


Hope it helps

Carlos

[Updated on: Thu, 18 November 2010 18:39]

Report message to a moderator

Previous Topic:common figures for different editparts
Next Topic:GMF Tooling Committers: Michael Golubev starts 100% as of 1.12.2010
Goto Forum:
  


Current Time: Thu Apr 25 14:15:17 GMT 2024

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

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

Back to the top