|On using PossibleValuesService for dynamically changed list of values [message #1497449]
||Wed, 03 December 2014 20:49
| Slava Kabanovich
Registered: December 2014
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.
Powered by FUDForum
. Page generated in 0.05286 seconds