Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » NatTable is not redrawn when ShowRowPositionsEvent is triggered
NatTable is not redrawn when ShowRowPositionsEvent is triggered [message #1838190] Thu, 18 February 2021 11:47 Go to next message
Yann Mortier is currently offline Yann MortierFriend
Messages: 17
Registered: July 2009
Location: Paris FR
Junior Member
Hi,

Firstly, many thanks to all contributors of NatTable. This component is the only one which allows to create features rich tables for SWT!

I have migrated from NatTable 1.6.0 to NatTable 2.0.0 and I encounter a strange behavior on Expand All. When I use the collapse all action then everything work as expected but when I use the expand all action or when I expand a row by clicking on the 'expand icon' then the table is not refreshed.

I took a look at the code to show if there are differences between 1.6.0/2.0.0 Expand/Collapse and I have found that the method org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent.convertToLocal(ILayer) has been removed by this issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=560669

So here is my analysis:



  1. TreeLayer.expandAll delegates the operation to ITreeRowModel.expandAll which must return the indexes of all children that are showed once the expand operation is finished.
  2. I use a GlazedListTreeRowModel and its expandAll operation tells: Returns an empty list because the list transformation for expand/collapse is handled by GlazedLists TreeList. So the list rowIndexes in TreeLayer.expandAll is empty.
  3. A ShowRowPositionsEvent is created from this empty list
  4. Before the event bubbles up to upper layer, the method ShowRowPositionsEvent.convertToLocal is called. If false is returned then the event is not pass to the parent layer.
  5. Because ShowRowPositionsEvent.convertToLocal(ILayer) has been removed and RowVisualChangeEvent.convertToLocal(ILayer) returns false if rowPositionRanges is empty then the event is not propagated to parent layers.
  6. The table is not redrawn because the visual change event is never added to the EventConflaterChain because it does not bubble up to the NatTable.


Is it a bug or should I use something else than GlazedListTreeRowModel?

Best regards,
Yann

Links to source code:
[1] https://git.eclipse.org/r/plugins/gitiles/nattable/org.eclipse.nebula.widgets.nattable/+/refs/tags/2.0.0/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java#418
[2] https://git.eclipse.org/r/plugins/gitiles/nattable/org.eclipse.nebula.widgets.nattable/+/refs/tags/2.0.0/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeRowModel.java#164
[3] https://git.eclipse.org/r/plugins/gitiles/nattable/org.eclipse.nebula.widgets.nattable/+/refs/tags/2.0.0/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java#422
[4] https://git.eclipse.org/r/plugins/gitiles/nattable/org.eclipse.nebula.widgets.nattable/+/refs/tags/2.0.0/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayer.java#266
[5] https://git.eclipse.org/r/plugins/gitiles/nattable/org.eclipse.nebula.widgets.nattable/+/refs/tags/2.0.0/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowVisualChangeEvent.java#177
[6] never called: https://git.eclipse.org/r/plugins/gitiles/nattable/org.eclipse.nebula.widgets.nattable/+/refs/tags/2.0.0/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/NatTable.java#753

[Updated on: Thu, 18 February 2021 11:47]

Report message to a moderator

Re: NatTable is not redrawn when ShowRowPositionsEvent is triggered [message #1838196 is a reply to message #1838190] Thu, 18 February 2021 13:46 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
Hi,

thanks for the detailed analysis. Unfortunately you found a regression that was not noticed for the last 12 months. :(

I will have a look and also create a test case to avoid that this issue comes up in the future again.

Greez,
Dirk
Re: NatTable is not redrawn when ShowRowPositionsEvent is triggered [message #1838197 is a reply to message #1838196] Thu, 18 February 2021 14:10 Go to previous messageGo to next message
Yann Mortier is currently offline Yann MortierFriend
Messages: 17
Registered: July 2009
Location: Paris FR
Junior Member
Hi Dirk,

Thank you for the reply. It's OK, we should execute our tests on snapshots to avoid this.

As a temporary workaround I will specialize TreeList and RowVisualChangeEvent to restore the old behavior. I can't do it, TreeList is final.

Thank you for your contribution to NatTable!

Best Regards,
Yann

[Updated on: Thu, 18 February 2021 14:15]

Report message to a moderator

Re: NatTable is not redrawn when ShowRowPositionsEvent is triggered [message #1838198 is a reply to message #1838196] Thu, 18 February 2021 14:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
No wait, after digging a bit deeper it seems the issue is not the ShowRowPositionsEvent. Actually the GlazedListsEventLayer should propagate a general RowStructuralRefreshEvent in case a tree node is expanded.

Unfortunately even the examples attach the GlazedListsEventLayer on the SortedList instead of the TreeList. Which is why the expand event is not handled.

In the GroupByExample the code needs to be updated to look like this:
            GroupByDataLayer<T> bodyDataLayer =
                    new GroupByDataLayer<>(getGroupByModel(), this.sortedList, columnPropertyAccessor);

            // layer for event handling of GlazedLists and PropertyChanges
            GlazedListsEventLayer<Object> glazedListsEventLayer =
                    new GlazedListsEventLayer<>(bodyDataLayer, bodyDataLayer.getTreeList());


This way the GlazedListsEventLayer will react on changes in the TreeList and the NatTable gets updated correctly. IMHO this is even the better solution than firing the ShowRowPositionsEvent even with an empty row set.

Instead of reverting the change, I will update the examples to reflect the correct instantiation of the GlazedListsEventLayer.
Re: NatTable is not redrawn when ShowRowPositionsEvent is triggered [message #1838200 is a reply to message #1838198] Thu, 18 February 2021 14:23 Go to previous message
Yann Mortier is currently offline Yann MortierFriend
Messages: 17
Registered: July 2009
Location: Paris FR
Junior Member
Hi,

It was exactly the problem.

Superb! It works like a charm, now!

Thank you!!

Yann
Previous Topic:Multi Cell Editor
Next Topic:Summary row layer with mutliple rows
Goto Forum:
  


Current Time: Fri Jul 23 20:15:10 GMT 2021

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

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

Back to the top