Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Scrolling changing indexes
Scrolling changing indexes [message #1835602] Tue, 08 December 2020 10:45 Go to next message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 31
Registered: March 2020
Member
Hello,

I'm facing an issue when scrolling horizontally in a custom table.

In the first picture attached, the 'Type' column of the table holds a combobox, but after scrolling horizontally, the combobox is also 'moved' to the columns from the right (the second picture attached). So, while I'm scrolling, the combo keeps 'moving' left/right (the gif attached).

The relevant code snippets:

BodyLayerStack bodyLayerStack = new BodyLayerStack(this.attributes, columnPropertyAccessor);
bodyLayerStack.setConfigLabelAccumulator(newColumnLabelAccumulator());

IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());

SortHeaderLayer sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new GlazedListsSortModel<>( bodyLayerStack.getSortedList(), columnPropertyAccessor, configRegistry, columnHeaderDataLayer));

FilterRowHeaderComposite filterRowHeaderLayer = new FilterRowHeaderComposite<>(new DefaultGlazedListsFilterStrategy<>(bodyLayerStack.getFilterList(), columnPropertyAccessor, configRegistry),
sortHeaderLayer, columnHeaderDataLayer.getDataProvider(), configRegistry);

IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyLayerStack.getBodyDataProvider());
DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayerStack,
bodyLayerStack.getSelectionLayer());

IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, filterRowHeaderLayer);

GridLayer gridLayer = new GridLayer(bodyLayerStack, filterRowHeaderLayer, rowHeaderLayer, cornerLayer);

NatTable natTable = new NatTable(gridPanel, gridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new FilterRowConfiguration());
natTable.addConfiguration(new SingleClickSortConfiguration());
natTable.addConfiguration(new EditableCellsConfiguration(bodyLayerStack.bodyDataProvider));

DefaultNatTableStyleConfiguration style = new DefaultNatTableStyleConfiguration();
style.hAlign = HorizontalAlignmentEnum.LEFT;
natTable.addConfiguration(style);

natTable.configure();

GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);

natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(natTable));

class BodyLayerStack extends AbstractLayerTransform {

private final FilterList filterList;
private final SortedList sortedList;
private final IDataProvider bodyDataProvider;
private final SelectionLayer selectionLayer;

public BodyLayerStack(List values, IColumnPropertyAccessor columnPropertyAccessor) {
        EventList eventList = GlazedLists.eventList(values);
	TransformedList rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);

	this.sortedList = new SortedList<>(rowObjectsGlazedList, null);
	this.filterList = new FilterList<>(getSortedList());
			
	this.bodyDataProvider = new ListDataProvider<>(this.filterList, new CompleteDataProvider());
	DataLayer bodyDataLayer = new DataLayer(getBodyDataProvider());

	GlazedListsEventLayer glazedListsEventLayer = new GlazedListsEventLayer<>(bodyDataLayer, this.filterList);

	bodyDataLayer.registerCommandHandler(new GlazedListsRowObjectDeleteCommandHandler<>(this.filterList));
			
	this.selectionLayer = new SelectionLayer(glazedListsEventLayer);
	ViewportLayer viewportLayer = new ViewportLayer(getSelectionLayer());

	setUnderlyingLayer(viewportLayer);
}
}
			


What can be the cause of this behavior? Did I configured something incorrectly?

Thank you!

Kind Regards,

Alexandra
  • Attachment: Capture1.PNG
    (Size: 12.29KB, Downloaded 13 times)
  • Attachment: Capture2.PNG
    (Size: 11.59KB, Downloaded 13 times)
  • Attachment: Scrolling.gif
    (Size: 879.45KB, Downloaded 13 times)
Re: Scrolling changing indexes [message #1835607 is a reply to message #1835602] Tue, 08 December 2020 16:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
Typical issue that the label accumulator is registered on the body layer stack. Register it on the body DataLayer
Re: Scrolling changing indexes [message #1835609 is a reply to message #1835607] Tue, 08 December 2020 17:31 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
BTW, you asked a similar question before

https://www.eclipse.org/forums/index.php/t/1105141/
Re: Scrolling changing indexes [message #1835629 is a reply to message #1835609] Wed, 09 December 2020 04:58 Go to previous messageGo to next message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 31
Registered: March 2020
Member
I remember that I asked a similar question and I fixed that problem at that time. :)
The label accumulator is registered on the bodyDataLayer. Maybe is still not correct, though.

public BodyLayerStack(List values, IColumnPropertyAccessor columnPropertyAccessor) {
        EventList eventList = GlazedLists.eventList(values);
	TransformedList rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);

	this.sortedList = new SortedList<>(rowObjectsGlazedList, null);
	this.filterList = new FilterList<>(getSortedList());
			
	this.bodyDataProvider = new ListDataProvider<>(this.filterList, new CompleteDataProvider());
	DataLayer bodyDataLayer = new DataLayer(getBodyDataProvider());

	GlazedListsEventLayer glazedListsEventLayer = new GlazedListsEventLayer<>(bodyDataLayer, this.filterList);

	bodyDataLayer.registerCommandHandler(new GlazedListsRowObjectDeleteCommandHandler<>(this.filterList));

        AggregateConfigLabelAccumulator labelAccumulator = new AggregateConfigLabelAccumulator();
	labelAccumulator.add(new ColumnLabelAccumulator());
	labelAccumulator.add(new IConfigLabelAccumulator() {
	     @Override
	     public void accumulateConfigLabels( LabelStack configLabels, int columnPosition, int rowPosition) {
	         Object rowObject = ((ListDataProvider) bodyLayerStack.bodyDataProvider).getRowObject(rowPosition);
		 int indexOfCorrespondingAttribute = DataDictionaryGridProvider.this.attributes.indexOf(rowObject);
		 DataDictionaryGridModelPOJO correspondingAttribute = (DataDictionaryGridModelPOJO) DataDictionaryGridProvider.this.attributes.get(indexOfCorrespondingAttribute);  
configLabels.addLabel(dataDictionaryGridService.attributeIsDeprecated(correspondingAttribute, context) ? DEPRECATED_LABEL : UNDEPRECATED_LABEL);
	    }
       });
       bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);
			
       this.selectionLayer = new SelectionLayer(glazedListsEventLayer);
       ViewportLayer viewportLayer = new ViewportLayer(getSelectionLayer());

       setUnderlyingLayer(viewportLayer);
}
}
	


Re: Scrolling changing indexes [message #1835630 is a reply to message #1835629] Wed, 09 December 2020 05:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
In the first snippet you register the label accumulator on the stack. Maybe you forgot to remove that.
Re: Scrolling changing indexes [message #1835631 is a reply to message #1835630] Wed, 09 December 2020 05:45 Go to previous message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 31
Registered: March 2020
Member
Ohhhh, you're right. I feel so stupid. :)

Well, this was embarrassing. Thank you for your sharp eyes. :)

Kind Regards,

Alexandra
Previous Topic:Please test the latest NatTable 2.0 SNAPSHOT
Next Topic:NatTable 2.0 released
Goto Forum:
  


Current Time: Tue Jun 15 08:10:19 GMT 2021

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

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

Back to the top