Which approach to use to have ability to hide/delete columns in the table in SWT (in Eclipse plugin in particular)?
So should I
We do that on many of our tables here.
First, we make sure the user does not see what we're doing.
table.setRedraw( false );
Then we remove all columns.
while ( table.getColumnCount() > 0 ) {
table.getColumns()[ 0 ].dispose();
}
And then we add the needed ones.
ArrayList<Column> columns = getShownColumns();
for ( Column column : columns ) {
TableColumn tableColumn = new TableColumn( table, column.getStyle() );
tableColumn.setText( column.getTitle() );
tableColumn.setWidth( column.getWidth() );
}
And finally we let the user see what we did.
table.setRedraw( true );