This might come in handy:
Composite tableComposite = new Composite(parent, SWT.NONE);
TableViewer xslTable = new TableViewer(tableComposite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
xslTable.getTable().setLinesVisible(true);
xslTable.getTable().setHeaderVisible(true);
TableViewerColumn stylesheetColumn = new TableViewerColumn(xslTable, SWT.NONE);
stylesheetColumn.getColumn().setText(COLUMN_NAMES[0]);
stylesheetColumn.getColumn().setResizable(false);
TableViewerColumn conceptColumn = new TableViewerColumn(xslTable, SWT.NONE);
conceptColumn.getColumn().setText(COLUMN_NAMES[1]);
conceptColumn.getColumn().setResizable(false);
TableColumnLayout tableLayout = new TableColumnLayout();
tableComposite.setLayout(tableLayout);
layoutTableColumns();
The layoutTableColumns
method
/**
* Resize table columns so the concept column is packed and the stylesheet column takes the rest of the space
*/
private void layoutTableColumns()
{
// Resize the columns to fit the contents
conceptColumn.getColumn().pack();
stylesheetColumn.getColumn().pack();
// Use the packed widths as the minimum widths
int stylesheetWidth = stylesheetColumn.getColumn().getWidth();
int conceptWidth = conceptColumn.getColumn().getWidth();
// Set stylesheet column to fill 100% and concept column to fit 0%, but with their packed widths as minimums
tableLayout.setColumnData(stylesheetColumn.getColumn(), new ColumnWeightData(100, stylesheetWidth));
tableLayout.setColumnData(conceptColumn.getColumn(), new ColumnWeightData(0, conceptWidth));
}