The first code snippet on
p342 should read "
table.setLayout(new AutoResizeTableLayout(table));" (note the additional constructor argument).
The following additional explanatory text should be included:
For each column, you will need to supply additional layout information. For Example:
// fixed width column
layout.addColumnData(new ColumnPixelData(18));
// weighted column
layout.addColumnData(new ColumnWeightData(50));
The FavoritesView can use the AutoResizeTableLayout class by modifying the code shown in Section 7.2.2, "View controls," after which the columns in the view will automatically be resized when the view is resized.
viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = viewer.getTable();
TableColumn typeColumn = new TableColumn(table, SWT.LEFT);
typeColumn.setText("");
//typeColumn.setWidth(18);
layout.addColumnData(new ColumnPixelData(18));
TableColumn nameColumn = new TableColumn(table, SWT.LEFT);
nameColumn.setText("Name");
//nameColumn.setWidth(200);
layout.addColumnData(new ColumnWeightData(200));
TableColumn locationColumn = new TableColumn(table, SWT.LEFT);
locationColumn.setText("Location");
//locationColumn.setWidth(450);
layout.addColumnData(new ColumnWeightData(200));
table.setHeaderVisible(true);
table.setLinesVisible(false);