Hi, man!
It seems I have found a mistake in your code (just check it).
Here it is:
http://www.vogella.de/articles/EclipseJFaceTable/article.html
public class View extends ViewPart {
//...
private void createColumns(final Composite parent, final TableViewer
viewer) {
//...
tableSorter.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);
//..
}
}
This is an example of poor design, as you have already changed the
direction right inside the sorter class. That is why it works
incorrectly.
Instead of the above I have written a public function in the sorter
class:
public int getDirection(){
return direction== 1 ? SWT.DOWN : SWT.UP;
}
Now the code is more clear (and hopefully works, arrow shows the
correct direction of the sort):
tableSorter.setColumn(index);
int dir = tableSorter.getDirection();
viewer.getTable().setSortDirection(dir);
Anyway thank you for the Tutorial!