Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Scrolling changing style
Scrolling changing style [message #1832072] Tue, 08 September 2020 06:22 Go to next message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 37
Registered: March 2020
Member
Hello,

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

In the first picture attached, the first two lines of the table have the strikethrough style, but after scrolling once, the style is 'moved' to the next two lines (the second picture attached). So, while I'm scrolling, the style keeps 'moving' up/down.

The relevant code snippets:
BodyLayerStack bodyLayerStack = new BodyLayerStack(this.attributes, columnPropertyAccessor);
bodyLayerStack.setConfigLabelAccumulator(new ColumnLabelAccumulator());

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));

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);
	}
});
bodyLayerStack.setConfigLabelAccumulator(labelAccumulator);

final ThemeConfiguration deprecationTheme = new DefaultNatTableThemeConfiguration();
deprecationTheme.addThemeExtension(new DeprecatedStylingThemeExtension());
natTable.setTheme(deprecationTheme);


class DeprecatedStylingThemeExtension implements IThemeExtension {

	@Override
	public void registerStyles(IConfigRegistry configRegistry) {
		IStyle deprecatedStyle = new Style();
		deprecatedStyle.setAttributeValue(
			CellStyleAttributes.TEXT_DECORATION,
			TextDecorationEnum.STRIKETHROUGH);
		configRegistry.registerConfigAttribute(
			CellConfigAttributes.CELL_STYLE,
			deprecatedStyle,
			DisplayMode.NORMAL, DEPRECATED_LABEL);
	}

	@Override
	public void unregisterStyles(IConfigRegistry configRegistry) {
		configRegistry.unregisterConfigAttribute(
			CellConfigAttributes.CELL_STYLE,
			DisplayMode.NORMAL,
			DEPRECATED_LABEL);
		
	}
}


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

Thank you!

Kind Regards,

Alexandra




  • Attachment: Capture1.PNG
    (Size: 45.33KB, Downloaded 57 times)
  • Attachment: Capture2.PNG
    (Size: 43.94KB, Downloaded 50 times)
Re: Scrolling changing style [message #1832074 is a reply to message #1832072] Tue, 08 September 2020 06:48 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 47
Registered: March 2020
Member
The problem is that you are setting your custom label accumulator on the body layer stack. That one contains the ViewportLayer. So you face the index-position-transformation topic. You get the position based on the viewport and then get the object from the underlying data collection by index. Those two do not match.

Either you need to do the index-position-transformation in advance or set the custom label accumulator on the body DataLayer.
Re: Scrolling changing style [message #1832075 is a reply to message #1832074] Tue, 08 September 2020 07:07 Go to previous message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 37
Registered: March 2020
Member
Thank you for the fast response!

Setting the custom label accumulator on the body DataLayer is working like a charm, I'm really grateful.

Kind Regards,

Alexandra
Previous Topic:How to change the color of the only some part of the string in the cell
Next Topic:How to get the selected object from the tree table
Goto Forum:
  


Current Time: Thu Mar 28 10:43:23 GMT 2024

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

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

Back to the top