Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Left border is not drawn
Left border is not drawn [message #1174716] Thu, 07 November 2013 09:17 Go to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
I have tried the online available demos and I can see that all tables don't draw the left border. At least on my Windows 7 x86, jre 1.7.0_40. Is it a bug or how can I set the table to draw left border the same way as its right border?

Left
http://imageshack.us/a/img10/315/hnx9.png
Right
http://imageshack.us/a/img443/50/r17z.png
By the way why is disabled attaching files in this forum?
Re: Left border is not drawn [message #1174782 is a reply to message #1174716] Thu, 07 November 2013 10:04 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2716
Registered: July 2012
Senior Member
To be precise, there is also no right border if you look at the first picture.

I haven't looked at that stuff ever I thought it should be this way. Maybe you are able to add a border to the Canvas to achieve what you want, as NatTable extends Canvas.

new NatTable(parent, NatTable.DEFAULT_STYLE_OPTIONS | SWT.BORDER);
Re: Left border is not drawn [message #1174815 is a reply to message #1174782] Thu, 07 November 2013 10:28 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Dirk Fauth wrote on Thu, 07 November 2013 11:04
To be precise, there is also no right border if you look at the first picture.

Well, both pictures I posted are from the same table. There is no right border in the first picture because its cropped. The right border is visible in the second image.
I can use SWT.BORDER, but then the right border is doubled and between left border and row lines is small gap.
Re: Left border is not drawn [message #1174874 is a reply to message #1174815] Thu, 07 November 2013 11:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2716
Registered: July 2012
Senior Member
Quote:
Well, both pictures I posted are from the same table


Jup, I'm aware of that.

As said before, I never looked into that and I always accepted it as is. You could either try to use a CustomLineBorderDecorator for the row header layer and configure it to render a left border or try to modify the GridLineCellLayerPainter and tell me where the issue might be. Smile
Re: Left border is not drawn [message #1177360 is a reply to message #1174874] Fri, 08 November 2013 23:31 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi Dirk,

here is my customization to the GridLineCellLayerPainter for drawing the leftmost border
@Override
public Rectangle adjustCellBounds(int columnPosition, int rowPosition, Rectangle bounds) {
	Rectangle rectangle = new Rectangle(
			bounds.x, 
			bounds.y, 
			Math.max(bounds.width - 1, 0), 
			Math.max(bounds.height - 1, 0)
	);
	if (columnPosition == 0) {
		rectangle.x += 1;
		rectangle.width = Math.max(rectangle.width - 1, 0);
	}
	return rectangle;
}

private void drawVerticalLines(ILayer natLayer, GC gc, Rectangle rectangle) {
	int endY = rectangle.y + Math.min(natLayer.getHeight() - 1, rectangle.height);
		
	int columnPositionByX = natLayer.getColumnPositionByX(rectangle.x + rectangle.width);
	int maxColumnPosition = columnPositionByX > 0 ? Math.min(natLayer.getColumnCount(), columnPositionByX) : natLayer.getColumnCount();
	for (int columnPosition = natLayer.getColumnPositionByX(rectangle.x); columnPosition < maxColumnPosition; columnPosition++) {
		if (columnPosition == 0) {
			// draw the leftmost line
			int x = natLayer.getStartXOfColumnPosition(columnPosition);
			gc.drawLine(x, rectangle.y, x, endY);
		}
		final int size = natLayer.getColumnWidthByPosition(columnPosition);
		if (size > 0) {
			int x = natLayer.getStartXOfColumnPosition(columnPosition) + size - 1;
			gc.drawLine(x, rectangle.y, x, endY);
		}
	}
}
Re: Left border is not drawn [message #1180896 is a reply to message #1177360] Mon, 11 November 2013 08:21 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2716
Registered: July 2012
Senior Member
Hi Jan,

thanks for that! As far as I can see it looks nice and I like it as it solves the same rendering issue in case you have a simple NatTable composition without headers. Well, at least half the way.

I thought about your solution over the weekend and here are my thoughts:

1. Althought IMHO this is correct, I'm not sure if everybody shares that oppinion. That means, there might be people, projects and use cases where the left border should not be rendered. I'm not sure if it is a bug or intended that it is not drawn. So I would like to see it configurable. This can be done via ConfigRegistry or via flag in GridLineCellLayerPainter, as it is possible to set the GridLineCellLayerPainter instance to a layer. The default should stay as is, as the rendering in existing projects should not change without knowledge.

2. Like the left border, the top border is not drawn. In a grid that uses the default column header rendering you won't notice that because of the button style rendering, and of course you don't want it there as it might break the appearance (which is also true if you use a different rendering for the row header Wink ). For completeness this should be also modified and configurable.

3. The SelectionLayerPainter needs to be adjusted too. Never noticed this before, but the selection anchor (dotted border around the selected cell) is not rendered for cells at the leftmost column position at the left. Simply adding your proposed solution additionally causes a white line to the left. IMHO the selection anchor should be always drawed completely and should not be configurable whether it should be rendered or not.

4. To be sure that we don't run into IP issues, the process for code contributions to a Eclipse project specifies that you should file a ticket in Bugzilla and contribute a patch.
http://eclipse.org/projects/dev_process/development_process.php
http://wiki.eclipse.org/Development_Resources#Users:_Contributing_To_A_Project
http://www.eclipse.org/projects/dev_process/ip-process-in-cartoons.php

I hope you share my opinion and are willing to contribute a modified version of your enhancement via Bugzilla. I really like the approach!

Greez,
Dirk
Re: Left border is not drawn [message #1182893 is a reply to message #1180896] Tue, 12 November 2013 13:44 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2716
Registered: July 2012
Senior Member
As I got no further feedback from you till now, I looked into it in more detail, and your solution is breaking the selection rendering in a grid.

I think I also found the reason for no left and top rendered lines. It seems this is because of rendering in a CompositeLayer (e.g. GridLayer) where attaching layers to each other would result in having double sized grid lines between the regions.

So the solution isn't that trivial and needs some further investigation.
Re: Left border is not drawn [message #1183253 is a reply to message #1182893] Tue, 12 November 2013 18:55 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi Dirk, I would look at this on the weekend.

Dirk Fauth wrote on Tue, 12 November 2013 14:44
As I got no further feedback from you till now, I looked into it in more detail, and your solution is breaking the selection rendering in a grid.

In what way?

Dirk Fauth wrote on Tue, 12 November 2013 14:44
I think I also found the reason for no left and top rendered lines. It seems this is because of rendering in a CompositeLayer (e.g. GridLayer) where attaching layers to each other would result in having double sized grid lines between the regions.

Yes, I think the GridLineCellLayerPainter should read the ConfigRegistry for settings and paint left and/or top border depending on that settings. The default would be turned off as it's now. For tables without column/row header you could switch this border painting by adding appropriate configuration to the ConfigRegistry.
Re: Left border is not drawn [message #1183325 is a reply to message #1183253] Tue, 12 November 2013 19:56 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2716
Registered: July 2012
Senior Member
Ah ok sorry, then I will wait until you get back on this topic.

Applying your code results in a white borde line at the left if you select a cell in column one.

I tried to work on that today. But unfortunately I don't have time for that now. So it would be great if you can have a look. What I've found out so far is that the offset calculation in CompositeLayerPainter simply attaches the layers. So there is more involved in the whole thing that initially thought.

BTW you removed a fix for another issue in your snippet regarding grid line painting in tables without headers on resizing. Check the comments before you delete code. Wink
Re: Left border is not drawn [message #1184155 is a reply to message #1183325] Wed, 13 November 2013 08:58 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2716
Registered: July 2012
Senior Member
To give a short summary and maybe some hints on that regarding my investigation:

It seems you need to check 3 classes:


  • CompositeLayerPainter
  • GridLineCellLayerPainter
  • SelectionLayerPainter


There are several examples you might need to check. Some of them are not yet part of the examples app. I currently work on them to create a new examples app that is related to a new documentation/tutorial. But you should find them in the sources:


  • _000_Default_NatTable - default NatTable showing a grid with headers
  • _661_ExcelExportExample - simple NatTable showing a table without headers
  • _000_Styled_grid - NatTable showing a grid with different styling


I also thought of the ConfigRegistry approach you mentioned, but adjustCellBounds() doesn't has access to it. But hopefully you find an appropriate solution. Smile

Looking forward to your contribution.

Re: Left border is not drawn [message #1200853 is a reply to message #1184155] Thu, 21 November 2013 12:51 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2716
Registered: July 2012
Senior Member
Hi,

instead of modifying the existing rendering code, I thought that it maybe easier to simply render the border afterwards on top using an IOverlayPainter.

Could you try to attach this code and see if it is working correctly for you?

		
natTable.addOverlayPainter(new IOverlayPainter() {
			
	@Override
	public void paintOverlay(GC gc, ILayer layer) {
		gc.drawLine(0, 0, 0, layer.getHeight()-1);
		gc.drawLine(0, 0, layer.getWidth()-1, 0);
	}
});


If it does I would create such a painter and commit it to NatTable core so it is possible to configure the borders easily.
Re: Left border is not drawn [message #1203627 is a reply to message #1200853] Fri, 22 November 2013 19:15 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi Dirk.

In fact, my first solution was to add a PaintListener to the NatTable. But instead of the layer height I used natTable.getSize().y which was wrong.
I noticed neither the IOverlayPainter interface nor layer.getHeight() then. Does this sentence make any sense in English? Embarrassed

It works fine for me, except the line is black whereas the rest border is gray.
Re: Left border is not drawn [message #1209553 is a reply to message #1203627] Mon, 25 November 2013 15:28 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2716
Registered: July 2012
Senior Member
I created the NatTableBorderOverlayPainter and pushed it to the repo.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=422482

So this should be a suitable workaround for the border issue.
Previous Topic:How to convert data beans to strings within cells
Next Topic:Multi Level Column Grouping
Goto Forum:
  


Current Time: Tue Sep 24 09:03:52 GMT 2019

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

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

Back to the top