Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » row auto resizing
row auto resizing [message #1386694] Thu, 19 June 2014 13:53 Go to next message
Gal Rogozinski is currently offline Gal Rogozinski
Messages: 14
Registered: June 2014
Junior Member
Hello,

I've been trying to auto resize rows using the solution in the FAQ section of the doc:

natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
			{
				cellPainter = new LineBorderDecorator(new CustomTextPainter(
						 true, true, 5, false, true));
			}
}


This worked but...
Scenario:
When I applied a filter on column the first row got larger (as it should).
When I removed the filter the first row remained with the large unneccessary height.


I tried the other solutions:

natTable.addPaintListener(new PaintListener()
		{
			@Override
			public void paintControl(PaintEvent e){
				for (int i = 0; i < natTable.getRowCount(); i++)
				{
					InitializeAutoResizeRowsCommand rowCommand = new InitializeAutoResizeRowsCommand(natTable, i, natTable.getConfigRegistry(), new GCFactory(
							natTable));
					AutoResizeRowsCommand command = new AutoResizeRowsCommand(rowCommand);
					natTable.doCommand(command);
				}
				
			}


This did nothing!! Whether I changed the last flag of the cellPainter or not.
I noticed in debug that the appropriate command handler was called.

I tried invoking both InitializeAutoResizeRowsCommand and AutoResizeRowsCommand, yet nothing changed!

Any ideas??
Maybe I am missing a layer?

Thanks!
Re: row auto resizing [message #1386700 is a reply to message #1386694] Thu, 19 June 2014 14:42 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
The default painters do not support automatic shrinking, only automatically increasing width and height. This is because of possible runtime issues when both actions are executed while iterating over the table cells.

There is an example on a text painter that does both, increasing and shrinking on automatic size calculation. Maybe that fits your needs.

If you are missing a layer, well how should I know without knowing about your layer stack?

AFAIK the command handlers for the initial resize commands are registered in the GridLayer. Are you creating a grid?
Re: row auto resizing [message #1386707 is a reply to message #1386700] Thu, 19 June 2014 15:50 Go to previous messageGo to next message
Gal Rogozinski is currently offline Gal Rogozinski
Messages: 14
Registered: June 2014
Junior Member
Where is this example?

I am creating a custom layer instead of a grid. Here is my custom stack:
public CustomBodyLayerStack(IUniqueIndexLayer underlyingLayer) {
		columnHideShowLayer = new ColumnHideShowLayer(underlyingLayer);
		selectionLayer = new SelectionLayer(columnHideShowLayer);
		viewportLayer = new ViewportLayer(selectionLayer);
		setUnderlyingLayer(viewportLayer);
Re: row auto resizing [message #1386714 is a reply to message #1386707] Thu, 19 June 2014 18:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
Quote:
Where is this example?


Where all the examples can be found! In the NatTable examples app which can be started on the website via webstart or in the examples project that can be checked out via Git.

Classic Examples -> Configuration -> AutomaticRowHeightExample

The painter you are looking for is the AutomaticRowHeightTextPainter.

If you are creating your own layer instead of using the default layers like GridLayer, you need to register the necessary command handlers yourself to make things working. Check which command handlers are registered in the GridLayer.

Re: row auto resizing [message #1386875 is a reply to message #1386714] Sun, 22 June 2014 08:05 Go to previous messageGo to next message
Gal Rogozinski is currently offline Gal Rogozinski
Messages: 14
Registered: June 2014
Junior Member
Funny enough,
This is the only example that I can't run. All others seem to work fine.
Did you see it run by any chance?
Re: row auto resizing [message #1386876 is a reply to message #1386875] Sun, 22 June 2014 08:08 Go to previous messageGo to next message
Gal Rogozinski is currently offline Gal Rogozinski
Messages: 14
Registered: June 2014
Junior Member
Ahh wait, the errors I am seeing are hard coded. It works fine. Sorry
Re: row auto resizing [message #1386877 is a reply to message #1386876] Sun, 22 June 2014 08:18 Go to previous messageGo to next message
Gal Rogozinski is currently offline Gal Rogozinski
Messages: 14
Registered: June 2014
Junior Member
The example seems to work on layout resize only. It isn't applicable to my filtering scenario
Re: row auto resizing [message #1386880 is a reply to message #1386877] Sun, 22 June 2014 09:54 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
It works on layout resize because line wrapping behaviour is configured. The important thing is the automatic size configuration and the code that performs resize on shrinking.

Check the Javadoc and the implementation for further details.
Previous Topic:How to block further grouping after a grouping is done?
Next Topic:Group/Ungroup Externally
Goto Forum:
  


Current Time: Sat Sep 20 14:08:27 GMT 2014

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

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