boolean usePropertySourceProviderIfItHasNicerRenderers = false;
if (usePropertySourceProviderIfItHasNicerRenderers) {
SortedMap<String, TableViewerColumn> headers = new TreeMap<String, TableViewerColumn>();
for (Object object : list) {
final IPropertySource propertySource = PropertySources.asPropertySource(object);
IPropertyDescriptor[] descriptors = propertySource.getPropertyDescriptors();
if (descriptors != null) {
for (final IPropertyDescriptor descriptor : descriptors) {
final Object id = descriptor.getId();
String header = PropertyDescriptors.getReadablePropertyName(descriptor);
TableViewerColumn col = headers.get(header);
if (col == null) {
col = createTableViewerColumn(header, bounds, column++);
headers.put(header, col);
IPropertySourceProvider propertySourceProvider = new IPropertySourceProvider() {
@Override
public IPropertySource getPropertySource(Object object) {
return PropertySources.asPropertySource(object);
}
};
col.setLabelProvider(new PropertyColumnLabelProvider(propertySourceProvider, id));
}
}
}
}
}
else {
SortedMap<String, Function1> headers = new TreeMap<String, Function1>();
for (Object object : list) {
final IPropertySource propertySource = PropertySources.asPropertySource(object);
IPropertyDescriptor[] descriptors = propertySource.getPropertyDescriptors();
if (descriptors != null) {
for (final IPropertyDescriptor descriptor : descriptors) {
final Object id = descriptor.getId();
String name = PropertyDescriptors.getReadablePropertyName(descriptor);
Function1 function = new Function1WithReturnType() {
@Override
public Object apply(Object object) {
IPropertySource property = PropertySources.asPropertySource(object);
if (property != null) {
return property.getPropertyValue(id);
}
return null;
}
@Override