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

Bug 402270

Summary: [Table][Tree] Column header with zero size become visible
Product: [RT] RAP Reporter: Markus Duft <markus.duft>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: tbuschto
Version: 2.0   
Target Milestone: 2.1 M1   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Markus Duft CLA 2013-03-04 03:01:47 EST
as reported here: http://www.eclipse.org/forums/index.php/t/457760/

this can be used to reproduce it (the last column header ("Fixed") is shown even though column size is zero - it seems to work for the "Identifier" column. in the real world this has also sizing issues)

	@Override
	public int createUI() {
		Display dp = new Display();
		Shell shell = new Shell(dp);
		shell.setLayout(new FillLayout());
		shell.setBounds(0, 0, 500, 300);
		
		Table tb = new Table(shell, SWT.BORDER | SWT.MULTI);
		tb.setHeaderVisible(true);
		tb.setLinesVisible(true);
		
		TableColumn col1 = new TableColumn(tb, SWT.RIGHT);
		col1.setWidth(200);
		col1.setMoveable(true);
		col1.setResizable(true);
		col1.setText("Identifier");
		
		TableColumn col2 = new TableColumn(tb, SWT.RIGHT);
		col2.setWidth(100);
		col2.setMoveable(true);
		col2.setResizable(true);
		col2.setText("Name");
		
		TableColumn col3 = new TableColumn(tb, SWT.RIGHT);
		col3.setWidth(200);
		col3.setMoveable(true);
		col3.setResizable(true);
		col3.setText("Visible");
		
		TableColumn col4 = new TableColumn(tb, SWT.RIGHT);
		col4.setWidth(200);
		col4.setMoveable(true);
		col4.setResizable(true);
		col4.setText("Fixed");
		
		col1.setAlignment(SWT.LEFT);
		col2.setAlignment(SWT.LEFT);
		col3.setAlignment(SWT.CENTER);
		col4.setAlignment(SWT.CENTER);
		
		col1.setMoveable(false);
		col1.setResizable(false);
		col1.setWidth(0);
		
		col4.setMoveable(false);
		col4.setResizable(false);
		col4.setWidth(0);
		
		shell.open();
		
		while(true) {
			if(!dp.readAndDispatch()) {
				dp.sleep();
			}
		}
	}
Comment 1 Ivan Furnadjiev CLA 2013-03-04 03:38:44 EST
It's working in Firefox (tested version 19.0), but not in IE, Chrome and Opera.
Comment 2 Markus Duft CLA 2013-03-04 03:40:50 EST
at least it's reproducible - phew ;)
Comment 3 Markus Duft CLA 2013-03-04 03:43:10 EST
and i can confirm that none of the observed issues happen with firefox inside our application
Comment 4 Markus Duft CLA 2013-03-06 08:45:49 EST
i came up with this for our application:

/*
 * Override grid column header rendering to hide labels for width=0 columns
 */
rwt.qx.Mixin.define("com.wamas.TableHeaderLabelPatch", {
	members : {
		_renderLabel : function(label, column) {
			this.base(arguments, label, column);
			if(column.getWidth() == 0) {
				label.setVisibility(false);
			}
		}
	}
});

(function() {
	try {
		// force prototype to be created.
		new rwt.widgets.base.GridHeader();
	} catch(ex) {
		// ignore
	}
	rwt.qx.Class.patch(rwt.widgets.base.GridHeader, com.wamas.TableHeaderLabelPatch);
})();

i think the easy implementation for RWT could be just to do the label.setVisibility(false) in the _renderLabel of the GridHeader.

tested with chrome, firefox, ie10
Comment 5 Tim Buschtoens CLA 2013-03-14 07:47:14 EDT
Fixed with commit 0f73cd6fd59397ee96cb4b3c1251c2e402ae405f.

The general issue applied to all widgets managed by CanvasLayoutImpl.js, where the computeChildBoxWidth method ignored the fact that "0" is falsy in JavaScript. That's why using "===" is generally a good idea. However, even with that fixed the columns border was still visible, so i changed GridHeader.js to render Columns with width 0 exlicitly as not visible.
Comment 6 Ivan Furnadjiev CLA 2013-03-14 07:51:30 EDT
Is this issue bug 403049 related? Is it fixed too?