package com.onaro.sanscreen.client.view.tabular; import org.apache.commons.lang3.StringUtils; import org.eclipse.core.runtime.IAdaptable; import com.onaro.client.leekui.runtime.OnaroAdapterUtils; /** * Column that retrieves a property value off of the row object using introspection. The row value is adapted to * the specified object type, then a property is retrieved off of that object. * * @param the object type the row objects will be adapted to. */ public class AdaptableTabularPropertyColumn extends TabularPropertyColumn { private static final long serialVersionUID = 1L; protected final Class adapterClass; public AdaptableTabularPropertyColumn(Class adapterClass, String propertyPath, String name) { super(getBeanInfo(adapterClass), propertyPath, name); this.adapterClass = adapterClass; } public AdaptableTabularPropertyColumn(Class adapterClass, String propertyPath, String columnId, String columnName) { this(adapterClass, propertyPath, columnName); if (StringUtils.isBlank(columnId)) throw new IllegalArgumentException("columnId"); //$NON-NLS-1$ setIdentifier(columnId); } public AdaptableTabularPropertyColumn(Class adapterClass, String propertyPath) { super(getBeanInfo(adapterClass), propertyPath); this.adapterClass = adapterClass; } @Override protected R getBean(IAdaptable row) { if (row == null) return null; R adapter = OnaroAdapterUtils.getAdapter(row, adapterClass); return adapter; } }