1

I would like to add dynamic icons to column headers. To do this I've created a class that extends CellPainterWrapper and added a CellPainterDecorator with a TextPainter as the base painter and my dynamic icon painter as the decorator painter.

If I then swap the CELL_PAINTER in the config to use my class instead of the TextPainter the table doesn't display. If I click on where a row should be it then resizes and displays the table as expected with the column header text and icons. I've also tried using the SortableHeaderTextPainter and get the same issue occur.

configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new SortableHeaderTextPainter(),
    DisplayMode.NORMAL, GridRegion.COLUMN_HEADER);

Overall this means there is something different with how TextPainter and SortableHeaderTextPainter is implemented. In particular I can see parts in TextPainter that will call commands to resize the layer but I'm struggling to figure out how this should be done.

What needs to be added for it to set the initial column/row sizes?

Michael
  • 3,411
  • 4
  • 25
  • 56

2 Answers2

0

Either set the initial widths and heights via DataLayer or configure the TextPainter to calculate the dimensions. Either via setter or constructor parameter.

Dirk Fauth
  • 4,128
  • 2
  • 13
  • 23
  • I've tried setting `calculate` to `true` with the same result with `new SortableHeaderTextPainter(new TextPainter(false, true, true))` – Michael Jun 15 '20 at 16:40
  • Without more information on your composition and configuration I can't help. – Dirk Fauth Jun 15 '20 at 17:26
0

This is caused by one any of the painters having paintBg set to true and by my style not specifying the background color. No exceptions would be thrown but it would cause my table to not resize automatically.

To fix this I can either set paintBg to false for all of my painters or set the background color in the style.

Michael
  • 3,411
  • 4
  • 25
  • 56
  • 1
    So it means you have not configured the `DefaultNatTableStyleConfiguration` that contains the basic necessary style configurations. Correct? – Dirk Fauth Jun 16 '20 at 10:38
  • I'm not using the `DefaultNatTableStyleConfiguration` as I'm using custom styles depending on the layer. I was then overwriting any existing styles by creating a new one and adding it as the cell style. Would it be more recommended to use the default config and instead of creating new styles, get the existing style config attribute and change the values in that? – Michael Jun 16 '20 at 11:13
  • 1
    If you want to completely use custom styles in every layer I would suggest to create a custom theme configuration by extending the default and exchanging the values. This way you have the style configuration in one place and can even exchange it easily at runtime. – Dirk Fauth Jun 16 '20 at 12:12
  • That's a great idea. Thank you for the help! – Michael Jun 16 '20 at 12:53
  • 1
    This example should help learning about NatTable `ThemeConfiguration`s: https://github.com/eclipse/nebula.widgets.nattable/blob/master/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_400_Configuration/_423_ThemeStylingExample.java – Dirk Fauth Jun 16 '20 at 13:00