Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Row and column header disappear
Row and column header disappear [message #1818440] Mon, 16 December 2019 10:40 Go to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 235
Registered: July 2009
Senior Member
Hi all,
I've the following two classes to build a layer stack for my NatTable (code stripped):

class BodyLayerStack {
        TransformedList<T, T> rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);
        this.sortedList = new SortedList<T>(rowObjectsGlazedList, null);

        this.bodyDataProvider = new ListDataProvider<T>(sortedList, columnPropertyAccessor);
        this.bodyDataLayer = new DataLayer(bodyDataProvider);
        glazedListsEventLayer = new DetailGlazedListsEventLayer<T>(bodyDataLayer, sortedList);
        glazedListsEventLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
        rowReorderLayer = new RowReorderLayer(glazedListsEventLayer);
        rowReorderLayer.setConfigLabelAccumulator(new AlternatingRowConfigLabelAccumulator());
        this.selectionLayer = new SelectionLayer(rowReorderLayer);
        RowSelectionModel<T> selectionModel = new RowSelectionModel<T>(selectionLayer, bodyDataProvider, rowIdAccessor, false);
        selectionLayer.setSelectionModel(selectionModel);
        selectionLayer.addConfiguration(new RowOnlySelectionConfiguration<T>());
        viewportLayer = new ViewportLayer(selectionLayer);
        setUnderlyingLayer(selectionLayer);
}

class GridListLayer {
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(columnLabels);
		dataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
		columnHeaderLayer = new ColumnHeaderLayer(dataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());

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

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

        gridLayer = new GridLayer(bodyLayerStack, columnHeaderLayer, rowHeaderLayer, cornerLayer);
        
        setViewportLayer(new ViewportLayer(bodyLayerStack.getSelectionLayer()));
        getViewportLayer().setRegionName(GridRegion.BODY);
}


Now, if I create the NatTable with
final NatTable natTable = new NatTable(tableComposite,gridListLayer.getViewportLayer(), false);

, the row and column headers are not shown. If I instead use
final NatTable natTable = new NatTable(tableComposite,gridListLayer.getGridLayer(), false);

, the row and column headers are shown, but if I scroll the table horizontally a bunch of exceptions is thrown because of wrong column mappings (at least it seems so). How can I correct this?

Thanks in advance,
Ralf.
Re: Row and column header disappear [message #1818443 is a reply to message #1818440] Mon, 16 December 2019 11:37 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
There are several things wrong with your code:

1. BodyLayerStack
You need to set the ViewportLayer as underlying layer, not the SelectionLayer! Using the SelectionLayer as underlying layer skips the virtual nature with scrolling by still assuming you have scrolling enabled.

2. Using the ViewportLayer as underlying layer of the NatTable.
If you want to show the headers you have to use the GridLayer. Otherwise, why should the NatTable render the headers? They are only available in the grid.

3. At the end of your GridListLayer you are setting the region name to the newly created ViewportLayer. So you have 2 ViewportLayer in your composition, both with the regionName set to GridRegion.BODY. So the last two lines are actually wrong.
Re: Row and column header disappear [message #1818455 is a reply to message #1818443] Mon, 16 December 2019 15:45 Go to previous messageGo to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 235
Registered: July 2009
Senior Member
Hi Dirk,
thanks for your fast answer. I've updated my code. But if I now scroll horizontally the exceptions occur again. It seems that the column number isn't detected correctly. I'll try to create a simple example project for this issue.

Regards,
Ralf.
Re: Row and column header disappear [message #1818460 is a reply to message #1818455] Mon, 16 December 2019 17:13 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Then your columnPropertyAccessor probably has an issue.
Re: Row and column header disappear [message #1818462 is a reply to message #1818460] Mon, 16 December 2019 19:29 Go to previous messageGo to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 235
Registered: July 2009
Senior Member
Hi,
it seems that the CellDisplayConversionUtils gets the wrong cell. This call:
        IDisplayConverter displayConverter = configRegistry.getConfigAttribute(
                CellConfigAttributes.DISPLAY_CONVERTER, cell.getDisplayMode(),
                cell.getConfigLabels().getLabels());

returns the wrong DisplayConverter. Does it have to do with some layer configuration?
Re: Row and column header disappear [message #1818464 is a reply to message #1818462] Mon, 16 December 2019 20:31 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Probably yes. Can't tell with the information you provided. You need to check the label stack and see what converters are registered.
Re: Row and column header disappear [message #1818480 is a reply to message #1818464] Tue, 17 December 2019 08:09 Go to previous messageGo to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 235
Registered: July 2009
Senior Member
Hm. There is a mistake in cell detection. In CellLayerPainter I get cell for column 2 if I want cell for column 1. In debug view I see that in paintLayer(ILayer, GC, int ,int ,Rectangle ,IConfigRegistry) the call to natLayer.getCellByPosition(columnPosition, rowPosition) returns cell for column 1 although the column position is 2. It seems that the layers are diverging after scrolling. Perhaps I have to rebuild the complete stack again and check it...
Re: Row and column header disappear [message #1818515 is a reply to message #1818480] Wed, 18 December 2019 09:08 Go to previous message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 235
Registered: July 2009
Senior Member
Ok, found it out. The mistake was that I've created the ColumnOverrideLabelAccumulator from my bodylayerstack and not from the datalayer :-/ Now it works perfectly :-) Thanks for your help.
Previous Topic:Sorting a TreeTable at first level
Next Topic:Displaying Dialog for multi edit of checkbox.
Goto Forum:
  


Current Time: Thu Apr 25 05:13:04 GMT 2024

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

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

Back to the top