Can't indent tree column of TreeLayer [message #911963] |
Wed, 12 September 2012 16:56 |
Eclipse User |
|
|
|
I prefer my left-aligned cells to have a bit of margin to match the default SWT table look-and-feel. It doesn't appear that I can do this with TreeLayer without copying the whole implementation.
|
|
|
Re: Can't indent tree column of TreeLayer [message #912251 is a reply to message #911963] |
Thu, 13 September 2012 07:45 |
Dirk Fauth Messages: 2903 Registered: July 2012 |
Senior Member |
|
|
You are right that this is something that isn't addressed correctly at the moment.
But there is a workaround where you don't have to override the whole implementation. Extend TreeLayer and override getCellPainter() like this:
@Override
public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) {
ICellPainter cellPainter = super.getCellPainter(columnPosition, rowPosition, cell, configRegistry);
if (columnPosition == TREE_COLUMN_NUMBER) {
cellPainter = new BackgroundPainter(new PaddingDecorator(
new CellPainterDecorator(cellPainter, CellEdgeEnum.LEFT, indentedTreeImagePainter),
0, 0, 0, 5));
}
return cellPainter;
}
To explain on that:
On rendering the NatTable asks its layers for the cell painter to use. Ususally this is the painter configured via NatTable configuration or specialized configuration by labels. In the special case of TreeLayer, the underlying painter is wrapped to be decorated with the tree image for expand/collapse. If you want to add padding, you have to wrap the created painter with a PaddingDecorator like shown above.
This is surely some part we have to look at when looking at the configuration of TreeLayer in general.
Hopefully my workaround solves your issue for the moment.
Greez,
Dirk
|
|
|
Re: Can't indent tree column of TreeLayer [message #912437 is a reply to message #912251] |
Thu, 13 September 2012 15:32 |
Eclipse User |
|
|
|
Thanks, Dirk. One problem with your suggestion is that indentedTreeImagePainter is private.
In the meantime, I've moved off of the mainline to version 2.3.2 from sourceforge.
Is it good enough to override getCellPainter() with a simple PaddingDecorator() wrap? Seems to be working.
@Override
public ICellPainter getCellPainter(int columnPosition, int rowPosition,
LayerCell cell, IConfigRegistry configRegistry) {
ICellPainter cellPainter = super.getCellPainter(columnPosition,
rowPosition, cell, configRegistry);
if (columnPosition == TREE_COLUMN_NUMBER) {
cellPainter = new PaddingDecorator(cellPainter, 0, 0, 0, 5);
}
return cellPainter;
}
Tom
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04133 seconds