Can't get TableCellPainter's dynamically calculated sub cell heights to work [message #1770856] |
Fri, 18 August 2017 01:35 |
Louis Detweiler Messages: 100 Registered: August 2017 |
Senior Member |
|
|
Hey I'm implementing a NatTable where I need to have multiple separate entries in one row cell in some of the columns. I need all of the text in the cell to show, so naturally I would like to use the dynamically calculated sub cell heights feature of the TableCellPainter. However, with the input parameter set to -1, it doesn't do it.
I've included all of the code I feel is relevant for the topic here, and the attached image is the result of what I have. Note the sub cell heights do not show the entire contents. However, I did check that the wrap text was working by manually increasing the sub cell heights and the text does wrap, so I don't see why the dynamically calculated sub cell height doesn't work. All of the cells with excessive "a"s in them have text that isn't fully shown.
final NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.addConfiguration(new RequirementsTableStyleConfiguration());
natTable.addConfiguration(new PainterConfiguration());
natTable.addConfiguration(new MyRowHeaderResizeBindings());
natTable.configure();
return natTable;
}
private static void registerColumnLabels(ColumnOverrideLabelAccumulator columnLabelAccumulator) {
columnLabelAccumulator.registerColumnOverrides(0, COLUMN_WITH_SINGLE_ENTRY_LABEL);
columnLabelAccumulator.registerColumnOverrides(1, COLUMN_WITH_MULTIPLE_ENTRIES_LABEL);
columnLabelAccumulator.registerColumnOverrides(2, COLUMN_WITH_MULTIPLE_ENTRIES_LABEL);
columnLabelAccumulator.registerColumnOverrides(3, COLUMN_WITH_MULTIPLE_ENTRIES_LABEL);
columnLabelAccumulator.registerColumnOverrides(4, COLUMN_WITH_MULTIPLE_ENTRIES_LABEL);
columnLabelAccumulator.registerColumnOverrides(5, COLUMN_WITH_MULTIPLE_ENTRIES_LABEL);
columnLabelAccumulator.registerColumnOverrides(6, COLUMN_WITH_SINGLE_ENTRY_LABEL);
}
public static class PainterConfiguration extends AbstractRegistryConfiguration {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
registerPainters(configRegistry);
}
private void registerPainters(IConfigRegistry configRegistry) {
registerColumnWithMultipleEntriesTablePainter(configRegistry);
registerColumnWithSingleEntryTablePainter(configRegistry);
}
private void registerColumnWithMultipleEntriesTablePainter(IConfigRegistry configRegistry) {
//register the TableCellPainter for the source collection in the data model
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER, new TableCellPainter(new TextPainter(true,true),
GUIHelper.COLOR_GRAY, GUIHelper.COLOR_WHITE, -1, true),
DisplayMode.NORMAL, COLUMN_WITH_MULTIPLE_ENTRIES_LABEL);
}
private void registerColumnWithSingleEntryTablePainter(IConfigRegistry configRegistry) {
//register the TableCellPainter for the source collection in the data model
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER, new TextPainter(true, true),
DisplayMode.NORMAL, COLUMN_WITH_SINGLE_ENTRY_LABEL);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03225 seconds