1
edit
Changes
no edit summary
4.5 Add new method:<br/>
<pre>
private SelectionAdapter getSelectionAdapter(final TableColumn column, final int index) { SelectionAdapter selectionAdapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { comparator.setColumn(index); int dir = viewer.getTable().getSortDirection(); if (viewer.getTable().getSortColumn() == column) { dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; } else { dir = SWT.DOWN; } viewer.getTable().setSortDirection(dir); viewer.getTable().setSortColumn(column); viewer.refresh(); } }; return selectionAdapter; }</pre></br/>4.6 Run the application. Click on a column header, the table should be sorted according to the content of this column.<br/>There will also appear a sort-direction in the top of the column:<br/>[[Image: Create3.png | 400px]]<br/>