for (int i = 0; i < columnTitles.length; i++) {
TableColumn column = new TableColumn(vendorInfo.getTable(), SWT.NULL);
column.setWidth(columnWidths[i]);
column.setText(columnTitles[i]);
final int columnIndex = i;
column.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (columnIndex == comparator.getSortColumn()) {
comparator.setAscending(!comparator.isAscending());
}
comparator.setSortColumn(columnIndex);