Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » row resizing according to text inside
row resizing according to text inside [message #1015948] Mon, 04 March 2013 11:47 Go to next message
Aggelos Aggelis is currently offline Aggelos AggelisFriend
Messages: 4
Registered: February 2013
Junior Member
Hi,
I am trying to create a table where according to the example I want my row to resize
according to text inside the cells, so as to be able to see the wholecontent of all cells. So I use
 TextPainter(true, true, 0, true). 

The problem is that although when
my window's width gets smaller the rows get higher(exactly as I want), when the window's width gets bigger, rows height isn't getting smaller!
Is there anyone else facing same problem?
I'm wondering If this is a bug or I am doing sthing wrong..

Thanks
Re: row resizing according to text inside [message #1015950 is a reply to message #1015948] Mon, 04 March 2013 11:53 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1406
Registered: July 2012
Senior Member
Hi,

the behaviour you are describing is intended. It is similar to other well known spreadsheet applications. The cell heights will only grow and not shrink automatically, because otherwise you would have jumping resizing on scrolling. So this is the desired default behaviour for grids/tables with large datasets.

If you are aware of that fact and still need the automatic growing and shrinking of row heights, you should consider using the AutomaticRowHeightTextPainter as shown in the AutomaticRowHeightExample.

Greez,
Dirk
Re: row resizing according to text inside [message #1016070 is a reply to message #1015950] Mon, 04 March 2013 19:50 Go to previous messageGo to next message
Aggelos Aggelis is currently offline Aggelos AggelisFriend
Messages: 4
Registered: February 2013
Junior Member
I see that AutomaticRowHeightTextPainter is not in version 0.9.0 and I 'm going to test it from the base version . What I've done until now , was override paintcell method of textpainter, but it persists to throw me exception :

java.lang.ClassNotFoundException: org.eclipse.nebula.widgets.nattable.command.ILayerCommand
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(Unknown Source)

I managed to isolate the problem and found out that it is caused by adding in my paintcell method this:

layer.doCommand(
new RowResizeCommand(
layer, 
cell.getRowPosition(), 
contentHeight + this.spacing * 2 + contentToCellDiff));


Any ideas??
Re: row resizing according to text inside [message #1016123 is a reply to message #1016070] Tue, 05 March 2013 07:30 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1406
Registered: July 2012
Senior Member
Well class loading issues relate to issues with the dependencies. So without knowing your project structure it is hard to determine what the problem is.
Re: row resizing according to text inside [message #1017353 is a reply to message #1015950] Mon, 11 March 2013 16:37 Go to previous messageGo to next message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 20
Registered: July 2009
Location: Stuttgart, Germany
Junior Member
Hi Dirk,

where can I find the AutomaticRowHeightTextPainter class and the Example? I've pretty much the same problem, that my rows need to shrink when more space becomes available.

Thanks,

Ralf Gro├čklaus
Re: row resizing according to text inside [message #1017374 is a reply to message #1017353] Mon, 11 March 2013 17:44 Go to previous messageGo to next message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 20
Registered: July 2009
Location: Stuttgart, Germany
Junior Member
Hi,

I found the AutomaticRowHeightTextPainter and the Example in the GIT repository. But the problem with this implementation is, that it works only, if the table has exactly one column. The problem is, that the painter is called 'per cell' and while painting it has no idea about the text (and thus about the height) of other cells of the same row. So, if you add another row to the example, the Table is resizing back and forth: Painter of cell (X,Y) might increase the cell- (an thus row-) height, since the text does not fit in the column, whereas the painter of column (X+1, Y) decreases the row height, since it finds, it has to much space. This triggers a repaint, where the painter of (X,Y) again increases the cell-heigh...


Any idea how to solve this?

Regards, Ralf
Re: row resizing according to text inside [message #1017607 is a reply to message #1017374] Tue, 12 March 2013 07:34 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1406
Registered: July 2012
Senior Member
Hi,

as I posted before
Quote:
The cell heights will only grow and not shrink automatically, because otherwise you would have jumping resizing on scrolling.


This also applies if you have more than one column as you can see now.

The only way to solve this is to let the TextPainter know about all other cells in the row, remember the height of the previous needed height and only perform a resize if it is necessary.
I started writing such a painter a while ago, but as this breaks a lot of design principles of the NatTable architecture, I discarded it and decided to not add such a feature to the NatTable. But of course you are free to create such a painter with dependencies to other cells and use it in your project.

Hope that helps,
Dirk
Re: row resizing according to text inside [message #1017654 is a reply to message #1017607] Tue, 12 March 2013 09:16 Go to previous messageGo to next message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 20
Registered: July 2009
Location: Stuttgart, Germany
Junior Member
Hi,

I'm aware that such a painter you describe might not follow all NatTable tenets. But our table has a 'row orientation' and one of the requirements is that rows should shrink if more space becomes available.

Do you still have a version of your painter? It would help me a lot, if i could use it as a 'blue print' for my own cell painter, since I'm pretty new to the whole NatTable business.

Thanks a lot,
Ralf

Re: row resizing according to text inside [message #1017661 is a reply to message #1017654] Tue, 12 March 2013 09:32 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1406
Registered: July 2012
Senior Member
Sorry, I discarded it and don't have it anymore. I think I added a map <RowIndex, MinHeight> and at the point where the height is calculated like in the AutomaticRowHeightTextPainter the map is checked additionally. But that might cause some other issues for lowering. Not sure anymore.
Previous Topic:configRegistry.registerConfigAttribute dont work on CompositeLayer
Next Topic:Regions in Natable?
Goto Forum:
  


Current Time: Mon Nov 24 20:25:36 GMT 2014

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

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