Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to track drown RowSelectionEvents
How to track drown RowSelectionEvents [message #1815500] Thu, 03 October 2019 15:23 Go to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
Hello

i noticed strange behaviour in my NatTable (this does not mean that i blame NatTable for it)

how can i track down the source of an SelectionEvent?
The event itself tells me that it got emitted by RowSelectionProvider;

why do i need this?
my basic configuration of nattable has an ISelectionChangedListener attached.
now i do set a new selection via mouse, which triggers this listener - all fine so far - i can proccess those selection events;

but when i set the selection via code (i tried the following two methods)

nattable.doCommand(new SelectRowsCommand(matching args);
OR
selectionProvider.setSelection(newSelection);

nattable sends out an selectionevent with the selection (it renders the selection correct for a moment) but then the Event is followed by an event for an empty selection (so the Selection gets removed again).

it could be that this is a sideeffect of my configuration, but i am just not able to track down where.
how can i get information about the source of the modification?
Stacktraces do not bring me to an helpful source (the stack only shows me nattable classes - no class from my packages)

the stack goes like this:
RowSelectionProvider
SelectionModel
ColumnHideShowLayer
ColumnReorderLayer

NOTE: i am using NatTable 1.5
Re: How to track drown RowSelectionEvents [message #1815505 is a reply to message #1815500] Thu, 03 October 2019 16:13 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
Are you trying an initial selection at build up or at runtime when everything is already set up?
Re: How to track drown RowSelectionEvents [message #1815506 is a reply to message #1815505] Thu, 03 October 2019 16:15 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
when everything is set up

i add one element to the list and want to select the new element - which works, but then an event gets fired and the selection disappears again.

[Updated on: Thu, 03 October 2019 17:01]

Report message to a moderator

Re: How to track drown RowSelectionEvents [message #1815507 is a reply to message #1815506] Thu, 03 October 2019 17:13 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
The question is what event is fired? Typically a refresh clears the selection. To find out what is causing the selection clear, you could add a breakpoint in the clear method of the SelectionModel
Re: How to track drown RowSelectionEvents [message #1815508 is a reply to message #1815507] Thu, 03 October 2019 17:20 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
just out of curiosity i updated to 1.6.0
           if (event.isVerticalStructureChanged()) {
                // if there are no row diffs, it seems to be a complete refresh
                if (event.getRowDiffs() == null) {
                    Collection<Rectangle> rectangles = event.getChangedPositionRectangles();
                    for (Rectangle rectangle : rectangles) {
                        Range changedRange = new Range(rectangle.y, rectangle.y + rectangle.height);
                        if (selectedRowModified(changedRange)) {
                            this.selectionLayer.clear();
                            break;
                        }
                    }
                } else {
                    // there are row diffs so we try to determine the diffs to
                    // process
                    for (StructuralDiff diff : event.getRowDiffs()) {
                        // DiffTypeEnum.CHANGE is used for resizing and
                        // shouldn't result in clearing the selection
                        if (diff.getDiffType() != DiffTypeEnum.CHANGE) {
                            if (selectedRowModified(diff.getBeforePositionRange())) {
                                this.selectionLayer.clear(); // this is causing the clear: SelectionModel 688
                                break;
                            }
                        }
                    }
                }


EDIT:
its an RowStructuralRefreshEvent
layer = ColumnGroupExpandCollapseLayer
underlyingLayer = CustomColumnHideShowLayer
do you need more information?

[Updated on: Thu, 03 October 2019 17:25]

Report message to a moderator

Re: How to track drown RowSelectionEvents [message #1815510 is a reply to message #1815508] Thu, 03 October 2019 17:31 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
Well yes, who is firing that event? What is triggering the event?
Re: How to track drown RowSelectionEvents [message #1815511 is a reply to message #1815510] Thu, 03 October 2019 17:33 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
Do you use the GlazedListsEventLayer? That one could fire the event with a delay on list changes. And adding an entry is such an event.
Re: How to track drown RowSelectionEvents [message #1815512 is a reply to message #1815511] Thu, 03 October 2019 18:38 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
Dirk Fauth wrote on Thu, 03 October 2019 13:31
Well yes, who is firing that event? What is triggering the event?

this is actually why i asked this question here :)

Dirk Fauth wrote on Thu, 03 October 2019 13:33
Do you use the GlazedListsEventLayer? That one could fire the event with a delay on list changes. And adding an entry is such an event.

Yes, i am using the GlazedListsEventLayer.

But this was no problem till like two months ago - it was already working properly.

I upgraded from NatTable 1.4.0 to 1.5.0 at this time, and i worked on selection too (full row selection instead of Cell selection on first RMB, but this is working as expected).
Re: How to track drown RowSelectionEvents [message #1815522 is a reply to message #1815512] Fri, 04 October 2019 05:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
Maybe I added the code you have posted in 1.5 to fix a bug with selections on structural changes. Would need to check the history to see what happened why some years ago.
Re: How to track drown RowSelectionEvents [message #1815552 is a reply to message #1815522] Fri, 04 October 2019 16:41 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
I am not sure if this of any interest, but I am also using GROUPING
Re: How to track drown RowSelectionEvents [message #1815556 is a reply to message #1815552] Fri, 04 October 2019 19:39 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
Grouping or groupBy?

Anyhow I suppose it is because of the GlazedListsEventLayer.
Typically I would suggest to disable it before the change, and after the change clear and enable it again. But clear was added with 1.6
Re: How to track drown RowSelectionEvents [message #1815878 is a reply to message #1815556] Mon, 14 October 2019 09:42 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
sorry, seems i missed the last response.
i am using GroupByDataLayer

how shall i disable /enable the GlazedListsEventLayer? (i know there are activate/deactivate methods) but i would need to disable it after i set my selection (which would be fine)
but when/how shall i enable it again? (reactivate after the clear)

NOTE: i am using the table (multiple instances) in an eclipse rcp;
i am executing an Handler on a list, which emits the selection to update the Table. so at the time of the change in selection i do not have access to the table itself.

[Updated on: Mon, 14 October 2019 09:49]

Report message to a moderator

Re: How to track drown RowSelectionEvents [message #1815879 is a reply to message #1815878] Mon, 14 October 2019 10:41 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
The problem is not the selection. The problem is the modification of the list.

Quote:
i add one element to the list and want to select the new element


Adding the element triggers the GlazedListsEventLayer (to be more precise the internal scheduled Runnable) to fire an update event in the range of 100ms. Before that update is fired you set the selection. Then the refresh is triggered which removes the selection again.

There are two options:
1. Deactivate the GlazedListsEventLayer before adding the element, then add the element, then clear the GlazedListsEventLayer to avoid firing the update on activate again (1.6 feature), activate the GlazedListsEventLayer again, then set the selection
2. Try the DetailGlazedListsEventLayer that fires a more detailed refresh event instead of a general one. This should also avoid the clearance of the selection.
Previous Topic:Validation dialog popup multiple times
Next Topic:Filter converted data
Goto Forum:
  


Current Time: Tue Jun 15 07:53:51 GMT 2021

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

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

Back to the top