Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » SelectCellCommand issue with TextPainter calculateByTextHeight
SelectCellCommand issue with TextPainter calculateByTextHeight [message #1065342] Tue, 25 June 2013 11:26 Go to next message
Marius Pop is currently offline Marius Pop
Messages: 3
Registered: June 2013
Junior Member
Hello ,

first of all I would like to thank all of the people working on NatTable for
providing such a good tool.

Now to my issue Smile,

I'm trying to navigate to a cell (not displayed in the current Viewport) by using SelectCellCommand.
Everything works fine when I use a Text painter with "calculateByTextHeight" parameter set to false.

When I set the "calculateByTextHeight" parameter to true and the cell I want to navigate to contains two lines of text the SelectCellCommand does not scroll to the cell anymore, it scrolls close to it but it is not displayed in the Viewport.

If I scroll manually to the cell and then try to navigate to it then it will work correctly.

I suspect it has something to do with the fact the cell heights are calculated only on demand on the visible part of the table but is there a possibility to force this calculation before the actual SelectCellCommand ?

Regards,
Marius
Re: SelectCellCommand issue with TextPainter calculateByTextHeight [message #1065371 is a reply to message #1065342] Tue, 25 June 2013 13:24 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1338
Registered: July 2012
Senior Member
Hi,

No there is no way to force the calculation prior. That would validate the concept of virtual tables which means "we only calculate what we see".

And that seems to be the issue. The automatic height calculation does a resize of the cell when it moves into the viewport and gets rendered. Until then the row height will have the default height (which is not an issue as long as it isn't visible). In that special case the cell seems to move into the viewport, gets a resize and therefore moves out of the viewport again. At least that would be my interpretion without having debugged already.

Could you please provide a small sample so we can start investigate on this?

Greez,
Dirk
Re: SelectCellCommand issue with TextPainter calculateByTextHeight [message #1065499 is a reply to message #1065342] Wed, 26 June 2013 07:30 Go to previous messageGo to next message
Marius Pop is currently offline Marius Pop
Messages: 3
Registered: June 2013
Junior Member
Hi Dirk ,

thank you for your quick reply.

As for the sample I modified the "Getting Started" (_001_Getting_Started) from nattable examples in the following way :

I added more persons to the list , so it will need scrolling :
	private IDataProvider setupBodyDataProvider() {
		List<Person> people = new ArrayList<Person>();
		Person mickey = new Person(100, "Mickey Mouse", new Date(1000000));
		for (int i = 0; i < 50; i++) {
			people.add(mickey);
		}

		Person bond = new Person(100, "James Bond", new Date(1000000));

		for (int i = 0; i < 50; i++) {
			people.add(bond);
		}

		propertyToLabels = new HashMap();
		propertyToLabels.put("id", "ID");
		propertyToLabels.put("name", "First Name");
		propertyToLabels.put("birthDate", "DOB");

		propertyNames = new String[] { "id", "name", "birthDate" };
		return new ListDataProvider(people,
				new ReflectiveColumnPropertyAccessor(propertyNames));

	}


and the NatTable creation I modified to have automatic calculation of text height:

		NatTable natTable = new NatTable(parent, false);
		natTable.setLayer(gridLayer);
		natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
			{
				cellPainter = new TextPainter(false, true, 5, false, true);
			}
		});
		natTable.configure();


Now when this sample is run try to search with the search dialog for "James" and it will not navigate to to James unless you search 3 or 4 times.

Hope this is enough to reproduce the behavior , if not I can post the entire sample code.

Regards,
Marius
Re: SelectCellCommand issue with TextPainter calculateByTextHeight [message #1065504 is a reply to message #1065499] Wed, 26 June 2013 07:56 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1338
Registered: July 2012
Senior Member
Thanks for providing the sample. I was able to reproduce and my thoughts on it were correct.

By using the specified TextPainter for calculating the height, the row height of every row in the grid gets resized. It would also occur if there would be only some rows that get resized.

As I said before, we only calculate what we see and do not calculate the row heights and columns widths initially. This is because we follow the concept of a virtual table and want to support large data sets.

So what happens is, to move the row into the viewport we need to calculate the coordinates. This is done by adding the row heights of the other rows. Now that these rows are rendered, by setting calculateHeight, all rows get resized, and therefore the selected cell moves out of the viewport again. After a few times the correct row heights for all visible rows are set correctly, therefore it works then.

We have some kind of race condition here, because ideally we would need to resize first and then move the row into the viewport. Which would violate the virtual concept. Another option would be to try to have something like "let the selected row STAY regardless what happens next".

As you hopefully can see, this is not a trivial issue to solve. Could you please open a ticket for this, adding a link to this forum post and maybe attach your whole example? This way also other committers would be able to have a look into this issue. We definitely need to discuss a possible solution.

Thanks,
Dirk
Re: SelectCellCommand issue with TextPainter calculateByTextHeight [message #1065522 is a reply to message #1065504] Wed, 26 June 2013 10:06 Go to previous messageGo to next message
Marius Pop is currently offline Marius Pop
Messages: 3
Registered: June 2013
Junior Member
I've opened a ticket for this issue :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=411670

Regards,
Marius
Re: SelectCellCommand issue with TextPainter calculateByTextHeight [message #1112339 is a reply to message #1065522] Thu, 19 September 2013 13:07 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1338
Registered: July 2012
Senior Member
Should be fixed now. Have a look at the ticket to see what corrections where made.
Previous Topic:Sorting in Tree List Breaks the Tree Structure
Next Topic:Export mechanism modifications
Goto Forum:
  


Current Time: Wed Oct 22 01:43:04 GMT 2014

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

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