public TableCollection selection() {
final int columnCount = columnCount();
return (TableCollection) syncExec(new ObjectResult() {
public Object run() {
final TableCollection selection = new TableCollection();
TreeItem[] items = getControl().getSelection();
for (int i = 0; i < items.length; i++) {
TreeItem item = items[i];
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;
}
});
}