Wrong order after inserting a row into a NatTable [message #1811098] |
Mon, 26 August 2019 16:43  |
Eclipse User |
|
|
|
Hi all,
if I insert a row into a previously reordered NatTable, the origin order is restored (at least in the view). If I save the View and re-open it the re-ordered rows appear in the correct ordering. This leads to some confusion...
I have the following Layer stack:
- DataLayer (with an underlying GlazedList) => "bodyDataLayer"
- GlazedListsEventLayer
- RowReorderLayer
- SelectionLayer
- ViewportLayer
The row header data layer is a DefaultRowHeaderDataLayer.
I'm adding a new row with the following method:
public void addNewItem(myDTO newItem) {
getMyListData().add(newItem);
getBodyDataLayer().fireLayerEvent(new RowInsertEvent(getBodyDataLayer(), newPos));
}
Now I do the following steps:
- open an existing list
- change row ordering
- add a new list item => result: previous ordering is displayed
- save the document
- open the document again => the new row order is applied and the added row is at the end of the list
How can I get the intended behavior (ordering remains stable after inserting an element)?
Thanks in advance,
Ralf.
|
|
|
|
|
Re: Wrong order after inserting a row into a NatTable [message #1811116 is a reply to message #1811109] |
Tue, 27 August 2019 02:57   |
Eclipse User |
|
|
|
I used the _5083_ColumnAndRowReorderExample but also tested now with _5082_RowReorderExample where it works as expected. Do you see the same issue in those examples? For testing I simply added a header configuration to add a menu to the corner region.
final NatTable natTable = new NatTable(panel, gridLayer, false);
// as the autoconfiguration of the NatTable is turned off, we have to
// add the DefaultNatTableStyleConfiguration manually
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
// add the corner menu configuration for adding the view management
// action
natTable.addConfiguration(new AbstractHeaderMenuConfiguration(natTable) {
@Override
protected PopupMenuBuilder createCornerMenu(NatTable natTable) {
return super.createCornerMenu(natTable)
.withStateManagerMenuItemProvider()
.withMenuItemProvider(new IMenuItemProvider() {
@Override
public void addMenuItem(NatTable natTable, Menu popupMenu) {
// TODO Auto-generated method stub
MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
menuItem.setText("add");
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int newPos = persons.size();
persons.add(new Person(newPos, "Ralph", "Wiggum", Gender.MALE, false, new Date()));
bodyDataLayer.fireLayerEvent(new RowInsertEvent(bodyDataLayer, newPos));
}
});
}
});
}
});
natTable.configure();
But those examples do not use GlazedLists. And it looks like the GlazedListsEventLayer is actually responsible for the behavior. That layer is a listener on the GlazedLists instance and fires a structural change event without details in case of changes.
You could try to use the DetailGlazedListsEventLayer which is creating events with detail information for list changes. Using that it worked for me in a modified example.
If you see an issue with that layer, please let me know soon. I am about to finish 1.6. But while preparing the release documents I could fix smaller things.
|
|
|
Re: Wrong order after inserting a row into a NatTable [message #1811123 is a reply to message #1811116] |
Tue, 27 August 2019 04:07  |
Eclipse User |
|
|
|
Hi Dirk,
I found the mistake. The problem was that I've fired a RowInsertEvent after inserting the new element. Since the GlazedListLayer already fired that event the layers gets confused a little ;-) I've removed the additional event, now it works (with DetailGlazedListsEventLayer). Thanks for your help.
Regards,
Ralf.
|
|
|
Powered by
FUDForum. Page generated in 0.03603 seconds