Community
Participate
Working Groups
Created attachment 237640 [details] Wrong and good column wide calculation Snippet to reproduce: public int createUI() { ServerPushSession pushSession = new ServerPushSession(); Display display = PlatformUI.createDisplay(); pushSession.start(); Shell shell = new Shell(display); shell.setLayout( new GridLayout() ); TitleAreaDialog dlg = new TitleAreaDialog(shell){ @Override protected Control createDialogArea( Composite parent ) { Composite composite = (Composite)super.createDialogArea( parent ); TableViewer viewer = new TableViewer(composite, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); Table table = viewer.getTable(); table.setHeaderVisible( true ); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; gd.widthHint = 300; table.setLayoutData(gd); TableColumn column = new TableColumn(table, SWT.NONE); column.setText( "Check" ); column = new TableColumn(table, SWT.NONE, 1); column.setText( "Name" ); TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(300, true)); layout.addColumnData(new ColumnWeightData(130, true)); table.setLayout(layout); return composite; } @Override protected Control createContents( Composite parent ) { Control content = super.createContents( parent ); setErrorMessage( "Error" ); return content; } }; shell.setSize( 500, 400 ); shell.open(); dlg.open(); while( !shell.isDisposed() ) { if( !display.readAndDispatch() ) { display.sleep(); } } pushSession.stop(); display.dispose(); return 0; } Executing setErrorMessage( "Error" ) in createContents method leads to wrong size calculation of table columns (see the attached picture). Not a critical issue, but a root problem could be a cause of other bugs (seems to me a problem is with FormData layouting of TitleAreaDialog.workArea).
I remember such a bug in RCP as well. Could you verify this? If I'm not mistaken the workaround was to use ColumnPixelData instead.
This works fine in RCP. We use another workaround - setErrorMessage in PaintListener attached to the dialog. ColumnPixelData is not what we need.
UPD: use ShellListener not a PaintListener.
Hi Yury, I did some debugging today. TableLayout is original SWT class. TableLayout#layout is called *only* once (see internal TableLayout#firstTime and TableLayout line 133) by design. If you set an error message the first layout is triggered by setErrorMessage with bigger dimensions and the following ("correct") layout calls are ignored. Thus, table columns are never resized to correct column data. In RAP we always have multiple resizes because of text size determination. You can prove it by commenting the return statement in TableLayout line 133. I think your workaround is correct.