Knowing when GridCells become pooled/unused?

17 views
Skip to first unread message

Austin T

unread,
Oct 26, 2020, 6:54:32 PM10/26/20
to ControlsFX
I've got a problem with the GridView GridCells that I can't find any solution to, and I'm wondering if anyone has any ideas or suggestions. I have a cleanup operation that needs to be run for each GridCell when the item changes, which is normally handled by overriding the updateItem method. The problem is that when items are removed from the GridView and the GridCells holding those items aren't immediately reused for other items, the my cleanup operation is not called because updateItem() is not called.

As an example: A grid has items [A, B, C], so it creates cells [cA, cB, cC]. I then remove all items from the grid [], and cells [cA, cB, cC] do not call updateItem(), as they are not being reused to display any items.

I haven't been able to find any properties I can watch for changes that fire when cells are "removed", or for that matter any way to check if a given cell is being displayed in the grid at all.

Thanks,

Austin

Samir Hadzic

unread,
Oct 27, 2020, 4:40:43 AM10/27/20
to ControlsFX
Hi,

I've stumbled across the same issue for the SpreadsheetView when I introduced the "HTML cells" and I really needed to retrieve the WebView I was adding in the cells.

What I've done is to put  a listener on the cell's parent : https://github.com/controlsfx/controlsfx/blob/df0412b764ad4721c8a78ea57ce06519f0af2fa6/controlsfx/src/main/java/impl/org/controlsfx/spreadsheet/CellView.java#L783

Therefore, when the parent is removed, the cell could be unused. I say "could" because  sometimes the cell is put aside (parent becomes null) then reused immediately.

Hopes it can help you,

Austin Thompson

unread,
Oct 27, 2020, 12:12:53 PM10/27/20
to control...@googlegroups.com
Thanks so much for responding!

I had experimented with listening to the parent property before, but I guess I must have made some sort of mistake and it wasn't having the desired effect. I quickly tried it again just now, though, and it works exactly how I need.

Thank you,

- Austin

Virus-free. www.avast.com

--
You received this message because you are subscribed to a topic in the Google Groups "ControlsFX" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/controlsfx-dev/nkJVSxC2QI8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to controlsfx-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/controlsfx-dev/6a6cf105-f90d-4d74-b862-1c654ea4425cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages