public TableCollection selection() {
final int columnCount = columnCount();
return syncExec(new Result<TableCollection>() {
public TableCollection run() {
final TableCollection selection = new TableCollection();
TreeItem[] items = widget.getSelection();
for (TreeItem item : items) {
TableRow tableRow = new TableRow();
if (columnCount == 0)
tableRow.add(item.getText());
else
for (int j = 0; j < columnCount; j++)
tableRow.add(item.getText(j));
selection.add(tableRow);
}
return selection;
}
});
}