Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Monitoring adds/removes to a ModelElementList
Monitoring adds/removes to a ModelElementList [message #1017470] Mon, 11 March 2013 22:15 Go to next message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
I have the feeling this has a simple answer, but I'm wondering what the recommended approach is for monitoring when elements are added to/removed from a ListProperty.

My scenario is a Sapphire editor linked to a View built using Worldwind, and used to edit a list of geolocated objects. Each object has a linked graphic within the Worldwind view. Currently these graphics are created/populated when the Sapphire editor is opened, and disposed when it closes, but naturally I would like to add them on-the-fly as the user adds a new ModelElement to the list (and, conversely, remove them when an element is removed from the list).

I'm unsure within the hierarchy of Sapphire events and listeners which would be most appropriate for this. In particular, I need to make sure any new ModelElement is fully initialized before I try to retrieve it (I have InitialValueServices on several of the properties).

Any suggestions would be greatly appreciated.
Re: Monitoring adds/removes to a ModelElementList [message #1017480 is a reply to message #1017470] Mon, 11 March 2013 22:49 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
For a list property, PropertyContentEvent will fire when list entries are added, deleted or rearranged. This event will fire before nested properties are initialized. Initialization of those property will trigger PropertyContentEvent on those properties.

- Konstantin

[Updated on: Mon, 11 March 2013 22:55]

Report message to a moderator

Re: Monitoring adds/removes to a ModelElementList [message #1017787 is a reply to message #1017480] Tue, 12 March 2013 14:40 Go to previous messageGo to next message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
Thanks. That raises another question: if I register a Listener for PropertyContentEvents on the list property, and retrieve the nested properties, is there a way to "force" the initialization of those properties?
Re: Monitoring adds/removes to a ModelElementList [message #1017799 is a reply to message #1017787] Tue, 12 March 2013 15:01 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
You could try calling element.initialize(), but keep in mind that the initialization will happen again after your listener exits and control returns to the list. A better way to do this is to write your listener to not be dependent on catching the model immediately after initialization. If you listen on PropertyContentEvents on the nested value properties, you will see when they are initialized and be able to update whatever state your listener is building.

- Konstantin
Re: Monitoring adds/removes to a ModelElementList [message #1017840 is a reply to message #1017799] Tue, 12 March 2013 16:14 Go to previous message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
Thanks!
Previous Topic:Proper use of/examples for InitialValueService?
Next Topic:potential workaround for startup speed issue
Goto Forum:
  


Current Time: Tue Mar 19 05:02:43 GMT 2024

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

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

Back to the top