Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 303454

Summary: [table] [SWT.CHECK] SWT.CHECK on a table does not behave consistently
Product: [Eclipse Project] Platform Reporter: Ketan Padegaonkar <KetanPadegaonkar>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: alexey.v.romanov, grant_gayed, skovatch, vivek.prahlad
Version: 3.5   
Target Milestone: 3.7 M2   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:

Description Ketan Padegaonkar CLA 2010-02-22 01:45:42 EST
A table with SWT.CHECK does not render the column label correctly. On a macosx/carbon, the first column header("foo") appears on the second column which is not the checkbox.

On gtk and even win32, the column "foo" is the same as column as the checkbox.

Testcase:

public class Main {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));

		Table table = new Table(shell, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.H_SCROLL | SWT.CHECK);
		table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		table.setLinesVisible(true);
		table.setHeaderVisible(true);
		
		TableColumn tableColumn = new TableColumn(table, SWT.LEAD);
		tableColumn.setText("foo");
		
		TableColumn tableColumn2 = new TableColumn(table, SWT.LEAD);
		tableColumn2.setText("bar");
		
		TableColumn tableColumn3 = new TableColumn(table, SWT.LEAD);
		tableColumn3.setText("baz");
		
		new TableItem(table, SWT.NONE).setText(new String[]{ "cell-1-1", "cell-1-2", "cell-1-3"});
		new TableItem(table, SWT.NONE).setText(new String[]{ "cell-2-1", "cell-2-2", "cell-2-3"});
		
		for (int i = 0; i < table.getColumnCount(); i++) {
			table.getColumn(i).pack();
		}

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 1 Scott Kovatch CLA 2010-06-07 14:26:24 EDT
This certainly looks bad. I'll see what I can do for 3.6.1.
Comment 2 Scott Kovatch CLA 2010-07-26 14:32:07 EDT
The behavior right now is the same on Cocoa and Carbon. The checkbox is in its own column with no label.

Grant would know for sure, but I think this is just a platform difference.
Comment 3 Grant Gayed CLA 2010-07-26 15:17:32 EDT
Yes this is a result of the checkbox needing its own physical column on OS X.  This is a valid platform difference, it's not spec'd whether checkboxes are included as part of logical column 0 or not.  To assume that a column's title would span outside of the column it's set in is not valid.  Unless Cocoa/Carbon provide a way for the checkbox to share physical column 0, this seems like a wontfix.
Comment 4 Scott Kovatch CLA 2010-07-26 20:27:52 EDT
(In reply to comment #3)
> Unless Cocoa/Carbon
> provide a way for the checkbox to share physical column 0, this seems like a
> wontfix.

Looking at Table, this actually wouldn't be too hard to do in Cocoa. Just set the title of the NSButtonCell to be the string value of logical column 0, and return the checked/grayed state as the value for column 0. No need for a separate check column.

If this is important I can aim to fix it in 3.7.
Comment 5 Grant Gayed CLA 2010-07-27 10:26:39 EDT
If it's not too complicated then sure, this can be done on Cocoa.  There are a few places in Table and Tree where a column index is incremented or decremented iff SWT.CHECK is specified, to account for checkboxes having their own column.  These cases could probably go away then.
Comment 6 Scott Kovatch CLA 2010-07-27 12:09:03 EDT
Targeting for 3.7. We will not be fixing this for Carbon; I'm not sure if it can even be done.
Comment 7 Scott Kovatch CLA 2010-08-17 16:49:59 EDT
Fixed > 20100817. It wasn't as invasive as I had expected -- just needed to expand the first data column to cover the checkbox area.
Comment 8 Scott Kovatch CLA 2010-08-17 16:50:22 EDT
.