Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Summary layer with group by layer
Summary layer with group by layer [message #1262432] Mon, 03 March 2014 16:27 Go to next message
Michal Sudra is currently offline Michal SudraFriend
Messages: 5
Registered: March 2014
Junior Member
Hi,

I have a requirement to enable summary row with group by functionality. I was trying to modify the Group by example by adding the summary layer, unfortunately I get the following errors

java.lang.NullPointerException
	at ca.odell.glazedlists.impl.adt.barcode2.FourColorTree.get(FourColorTree.java:169)
	at ca.odell.glazedlists.TreeList.getTreeNode(TreeList.java:302)
	at ca.odell.glazedlists.TreeList.get(TreeList.java:287)
	at org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData.getDataAtIndex(GlazedListTreeData.java:52)
	at org.eclipse.nebula.widgets.nattable.tree.AbstractTreeRowModel.depth(AbstractTreeRowModel.java:40)
	at org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter.getDepth(IndentedTreeImagePainter.java:128)
	at org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter.getPreferredWidth(IndentedTreeImagePainter.java:109)
	at org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator.getBaseCellPainterBounds(CellPainterDecorator.java:238)
	at org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator.paintCell(CellPainterDecorator.java:219)
	at org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper.paintCell(CellPainterWrapper.java:61)
	at org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter.paintCell(BackgroundPainter.java:52)
	at org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter.paintCell(CellLayerPainter.java:185)
	at org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter.paintCell(SelectionLayerPainter.java:212)
	at org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter.paintLayer(CellLayerPainter.java:81)
	at org.eclipse.nebula.widgets.nattable.painter.layer.GridLineCellLayerPainter.paintLayer(GridLineCellLayerPainter.java:106)
	at org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter.paintLayer(SelectionLayerPainter.java:105)
	at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$CompositeLayerPainter.paintLayer(CompositeLayer.java:889)
	at org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer$FreezableLayerPainter.paintLayer(CompositeFreezeLayer.java:177)
	at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$CompositeLayerPainter.paintLayer(CompositeLayer.java:889)
	at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$CompositeLayerPainter.paintLayer(CompositeLayer.java:889)
	at org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter.paintLayer(NatLayerPainter.java:36)
	at org.eclipse.nebula.widgets.nattable.NatTable.paintNatTable(NatTable.java:406)
	at org.eclipse.nebula.widgets.nattable.NatTable.paintControl(NatTable.java:401)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:217)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1324)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4001)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4589)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2405)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Composite.WM_SYSCOMMAND(Composite.java:1599)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4022)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4589)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2405)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4036)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4602)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2410)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3471)
	at org.eclipse.nebula.widgets.nattable.examples.runner.TabbedNatExampleRunner.run(TabbedNatExampleRunner.java:91)
	at org.eclipse.nebula.widgets.nattable.examples.runner.TabbedNatExampleRunner.run(TabbedNatExampleRunner.java:54)
	at org.eclipse.nebula.widgets.nattable.examples.NatTableExamples.main(NatTableExamples.java:55)
Error while painting table: null


And the modified group by example code

GroupByDataLayer<RowDataFixture> bodyDataLayer = new GroupByDataLayer<RowDataFixture>(groupByModel, eventList,reflectiveColumnPropertyAccessor, configRegistry);
		
// Summary layer
SummaryRowLayer summaryRowLayer =
	new SummaryRowLayer( bodyDataLayer, configRegistry, false );
		 
configRegistry.registerConfigAttribute( SummaryRowConfigAttributes.SUMMARY_PROVIDER, 
	new SummationSummaryProvider( bodyDataLayer.getDataProvider() ), DisplayMode.NORMAL,
		SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL );

// Body layer
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(summaryRowLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);

TreeLayer treeLayer = new TreeLayer(selectionLayer, bodyDataLayer.getTreeRowModel());


And my question, is it a known problem that this two functionalities cannot be combined or maybe I am doing it in a wrong way?
Re: Summary layer with group by layer [message #1262552 is a reply to message #1262432] Mon, 03 March 2014 19:12 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2704
Registered: July 2012
Senior Member
You are trying to register a summary provider for each column. But for the tree column this doesn't work because of the structure. Also the groupby objects can not be used to calculate the summary because for the other columns the value is null. So if you need to combine those features you need to create custom summary providers.
Re: Summary layer with group by layer [message #1263414 is a reply to message #1262432] Tue, 04 March 2014 13:02 Go to previous messageGo to next message
Michal Sudra is currently offline Michal SudraFriend
Messages: 5
Registered: March 2014
Junior Member
Hi Dirk,

Thanks for your quick answer. Creation of custom summary provider is not enough, even when I made some empty summary provider its code is not invoked. The exception I posted before is thrown earlier. I will try to examine the situation, but I will also want to ask you for some clues.
Re: Summary layer with group by layer [message #1263432 is a reply to message #1263414] Tue, 04 March 2014 13:23 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2704
Registered: July 2012
Senior Member
Possibly you need to set the SummaryRowLayer on top of the TreeLayer, as it adds a row that does not belong to the data model itself.
Re: Summary layer with group by layer [message #1265832 is a reply to message #1262432] Thu, 06 March 2014 16:16 Go to previous messageGo to next message
Michal Sudra is currently offline Michal SudraFriend
Messages: 5
Registered: March 2014
Junior Member
Setting SummaryRowLayer on top of the TreeLayer was a good hint. Unfortunately some other errors appeared:
Exception in thread "main" java.lang.StackOverflowError
	at java.lang.Integer.hashCode(Integer.java:750)
	at java.util.HashMap.hash(HashMap.java:351)
	at java.util.HashMap.getEntry(HashMap.java:443)
	at java.util.HashMap.get(HashMap.java:405)
	at org.eclipse.nebula.widgets.nattable.hideshow.AbstractRowHideShowLayer.getStartYOfRowPosition(AbstractRowHideShowLayer.java:176)
	at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getStartYOfRowPosition(AbstractLayerTransform.java:274)
	at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findRowPosition(LayerUtil.java:54)
	at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findRowPosition(LayerUtil.java:62)
	at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findRowPosition(LayerUtil.java:62)
	at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findRowPosition(LayerUtil.java:62)
	at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findRowPosition(LayerUtil.java:62)
	at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findRowPosition(LayerUtil.java:62)
	at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findRowPosition(LayerUtil.java:62)
...


It was caused by the summary row position calculations, but I was able to eliminate that by overriding few methods of the AbstractLayerTransform in the SummaryRowLayer. Below the changed methods:
@Override
public int getStartYOfRowPosition(int rowPosition) {
	if( isSummaryRowPosition(rowPosition))
	{
		return super.getHeight();
	}
	if (rowPosition < 0 || rowPosition >= getRowCount()) {
		return -1;
	}
	return super.getStartYOfRowPosition(rowPosition);
}
	
@Override
public String getDisplayModeByPosition(int columnPosition, int rowPosition) {
	if( isSummaryRowPosition(rowPosition) )
	{
		return DisplayMode.NORMAL;
	}
	return super.getDisplayModeByPosition(columnPosition, rowPosition);
}


After this changes the summary row and the group by features are working together as expected. Maybe it will be helpful for you to improve the summary row functionality. For now I am using my custom summary row layer with the described changes in my code but if you plan to improve that in the near future please let me know. Once again thanks for your help.
Re: Summary layer with group by layer [message #1268432 is a reply to message #1265832] Mon, 10 March 2014 13:46 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2704
Registered: July 2012
Senior Member
Whenever someone tries to override default behaviour of abstract implementations by removing functionality (in your case it is not possible to select a cell in the summary row anymore), it is time to take a closer look.

So first thing, I pushed you into the wrong direction. Of course it is wrong to add the SummaryRowLayer on top of the TreeLayer. Your first approach is the correct composition. My fault!

The real reason for the issue is hidden in ITreeData (GlazedListsTreeData) because the tree state for the summary row is requested. I fixed this by adding verifications before trying to access the TreeList via index. This way it works as intended.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=429975
Previous Topic:Registering an ImagePainter for a certain cell
Next Topic:Adding filter to entire table like viewer filters in TreeViewer
Goto Forum:
  


Current Time: Sat Aug 24 13:56:20 GMT 2019

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

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

Back to the top