public static TableViewerColumn addColumn(final TableViewer viewer, String text, boolean resize, boolean sort, int width) {\r
final TableViewerColumn twc = new TableViewerColumn(viewer, SWT.NONE);\r
final TableColumn tc = twc.getColumn();\r
- //final TableColumn tc = new TableColumn(viewer.getTable(), SWT.NONE);\r
tc.setText(text);\r
tc.setResizable(resize);\r
tc.setWidth(width);\r
tc.addSelectionListener(new SelectionAdapter() {\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
- StringColumnComparator comparator = (StringColumnComparator)viewer.getComparator();\r
- //TableColumn tc = twc.getColumn();\r
+ StringColumnComparator comparator = null;\r
+ if (viewer.getComparator() instanceof StringColumnComparator) {\r
+ comparator = (StringColumnComparator)viewer.getComparator();\r
+ } else {\r
+ comparator = new StringColumnComparator();\r
+ viewer.setComparator(comparator);\r
+ }\r
TableColumn tcs[] = viewer.getTable().getColumns();\r
int index = -1;\r
for (int i = 0; i <tcs.length; i++) {\r