Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Can't get TableCellPainter's dynamically calculated sub cell heights to work
Can't get TableCellPainter's dynamically calculated sub cell heights to work [message #1770857] Fri, 18 August 2017 01:35 Go to next message
Louis Detweiler is currently offline Louis DetweilerFriend
Messages: 57
Registered: August 2017
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);
    }
    
    
  }


index.php/fa/30412/0/
Re: Can't get TableCellPainter's dynamically calculated sub cell heights to work [message #1770883 is a reply to message #1770857] Fri, 18 August 2017 11:35 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2624
Registered: July 2012
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=516783
Re: Can't get TableCellPainter's dynamically calculated sub cell heights to work [message #1771292 is a reply to message #1770883] Wed, 23 August 2017 17:55 Go to previous message
Louis Detweiler is currently offline Louis DetweilerFriend
Messages: 57
Registered: August 2017
Member
Hey thanks so much Dirk, the work around you posted for the bug works!
Previous Topic:NatTable Books
Next Topic:Is it possible to implement something similar to merged cells in Excel?
Goto Forum:
  


Current Time: Sat Nov 17 17:51:36 GMT 2018

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

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

Back to the top