Source:
void updateColumn(TreeViewer viewer, final TableColumnProvider provider) { TreeColumn column = null; TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE); final DelegatingStyledCellLabelProvider styledLabelProvider = new DelegatingStyledCellLabelProvider(provider) { @Override public String getToolTipText(Object element) { return provider.getToolTipText(element); }; }; viewerColumn.setLabelProvider(styledLabelProvider); column = viewerColumn.getColumn(); column.setText(provider.getTitle()); if (!provider.isFillAvailable()) { column.setWidth(provider.getMinimumSize()); } else { int width = viewer.getTree().getClientArea().width; if (!viewer.getTree().getVerticalBar().isVisible()) { width -= viewer.getTree().getVerticalBar().getSize().x; } int allWidths = 0; for (TableColumnProvider provider2 : currentProvider.getColumnProviders()) { if (provider2 != provider) { allWidths += provider2.getMinimumSize(); } } column.setWidth((width - allWidths)); } TableLayout layout = (TableLayout) viewer.getTree().getLayout(); layout.addColumnData(new ColumnWeightData(provider.getWeight(), provider.getMinimumSize())); column.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { CommonViewer viewer = getCommonViewer(); TreeColumn column = (TreeColumn) e.getSource(); String name = column.getText(); ReviewsSorter sorter = null; if (viewer.getSorter() != null && viewer.getSorter() instanceof ReviewsSorter) { sorter = (ReviewsSorter) viewer.getSorter(); } else { sorter = new ReviewsSorter(); viewer.setSorter(sorter); } if (name.equals("Last Change")) { sorter.reverseDate(); } else if (name.equals("Author")) { sorter.reverseAuthor(); } else if (name.equals("Item")) { sorter.reverseItem(); } else if (name.equals("Comment")) { sorter.reverseComment(); } else if (name.equals("Artifact")) { sorter.reverseArtifact(); } updateTreeViewer(viewer); getCommonViewer().refresh(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); }

Target:
void updateColumn(TreeViewer viewer, final TableColumnProvider provider) { TreeColumn column = null; TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE); final DelegatingStyledCellLabelProvider styledLabelProvider = new DelegatingStyledCellLabelProvider(provider) { @Override public String getToolTipText(Object element) { return provider.getToolTipText(element); }; }; viewerColumn.setLabelProvider(styledLabelProvider); column = viewerColumn.getColumn(); column.setText(provider.getTitle()); if (!provider.isFillAvailable()) { column.setWidth(provider.getMinimumSize()); } else { int width = viewer.getTree().getClientArea().width; if (!viewer.getTree().getVerticalBar().isVisible()) { width -= viewer.getTree().getVerticalBar().getSize().x; } int allWidths = 0; for (TableColumnProvider provider2 : currentProvider.getColumnProviders()) { if (provider2 != provider) { allWidths += provider2.getMinimumSize(); } } column.setWidth((width - allWidths)); } TableLayout layout = (TableLayout) viewer.getTree().getLayout(); layout.addColumnData(new ColumnWeightData(provider.getWeight(), provider.getMinimumSize())); column.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CommonViewer viewer = getCommonViewer(); TreeColumn column = (TreeColumn) e.getSource(); String columnName = column.getText(); if (viewer.getSorter() != null && viewer.getSorter() instanceof ReviewsSorter) { ReviewsSorter sorter = (ReviewsSorter) viewer.getSorter(); sorter.setColumnName(columnName); updateTreeViewer(viewer); getCommonViewer().refresh(); } } }); }