On using PossibleValuesService for dynamically changed list of values [message #1497449] |
Wed, 03 December 2014 20:49  |
Slava Kabanovich Messages: 8 Registered: December 2014 |
Junior Member |
|
|
I have a long list of xml elements
<object id="object107" extends="object17"/>
where each element declares an unique id and optionally extends another object from the same file, referencing it by id.
Field editor for property 'extends' should display list of available ids. The list should dynamically change when xml is modified.
I implemented extension of PossibleValuesService for property 'extends'. When computing values, the implementation adds listeners to referenced model objects, so that when 'id' is modified or element 'object' added or removed, listener calls for refresh of values.
It works fine for small files, but causes concerns for large ones.
An instance of PossibleValuesService is created for each object/@extends. At invoking popup by a filed editor button, the first call to computing values occurs. That is nice. However, then, at a change event, each of service objects that computed values should be called through its listener to refresh them, - otherwise, possible values at corresponding field editor remain obsolete. I could do computation just once, but even if each service object is going to have the same list of possible values, I have to fill new Set<String> in compute(Set<String>) method because method PossibleValuesService.compute() is final.
Suppose I work with a file that has 1000 objects in the editor for a long time, and have edited 'extends' at 100 objects. By now, 100 service instances added listeners to 1000 model objects and keep 100 tree sets of 1000 strings each. Each next adding new object will cause creating 100 new sets and filling them with 1000 objects each. They will replace old sets, no memory leak, but it is still a heavy load on memory and performance.
Maybe I do it all wrong and there is a better solution. Please advise it.
|
|
|
|
Re: On using PossibleValuesService for dynamically changed list of values [message #1499151 is a reply to message #1497471] |
Fri, 05 December 2014 00:07   |
Slava Kabanovich Messages: 8 Registered: December 2014 |
Junior Member |
|
|
My example is simplified, in general, values can depend on object, e.g. in my example it may be not allowed for an element to reference itself.
It may be just important to avoid cashing all possible values. Moreover, it may be desirable to represent all possible values as a tree with an opportunity to build children dynamically, as a tree node is expanded - the tree may have unlimited set of values.
I guess it can be achieved in Sapphire by customising property editor instead of using values service. May I bind to the property editor declaration in *.sdef PopUpListFieldPropertyEditorPresentation.Factory (to have text input and button) and a custom action, bound to 'Sapphire.Browse' in that property editor declaration's context, that would run a wizard with a desired values provider and presentation?
[Updated on: Fri, 05 December 2014 00:11] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02604 seconds