package com.onaro.sanscreen.client.view.tabular; import java.beans.BeanInfo; import java.beans.PropertyDescriptor; import java.text.MessageFormat; import java.util.List; import com.onaro.client.swing.table.functional.IFunction; import com.onaro.client.swing.table.functional.IFunctionConsumer; import com.onaro.client.swing.table.functional.IFunctionGroup; import com.onaro.client.swing.table.functional.IFunctionManager; import com.onaro.commons.swing.table.IRowDataServiceGroup; import com.onaro.sanscreen.client.view.tabular.columns.ColumnBuilder; /** * Column class that merges the capabilities of the TabularPropertyColumn with the ability to make use of IFunctions, * like AbstractFunctionalColumn. * * @param row data type for the column. * * @see AbstractFunctionalColumn * @deprecated Use {@link ColumnBuilder} instead */ public abstract class FunctionalPropertyColumn extends TabularPropertyColumn implements IFunctionConsumer { private static final long serialVersionUID = 1L; public FunctionalPropertyColumn(BeanInfo beanInfo, String propertyPath, String name) { super(beanInfo, propertyPath, name); } public FunctionalPropertyColumn(BeanInfo beanInfo, String propertyName) { super(beanInfo, propertyName); } public FunctionalPropertyColumn(Class beanClass, String propertyPath, String name) { super(beanClass, propertyPath, name); } public FunctionalPropertyColumn(Class beanClass, String propertyPath) { super(beanClass, propertyPath); } public FunctionalPropertyColumn(List propertyDescriptors, String name) { super(propertyDescriptors, name); } public FunctionalPropertyColumn(PropertyDescriptor propertyDescriptor, String name) { super(propertyDescriptor, name); } public FunctionalPropertyColumn(PropertyDescriptor propertyDescriptor) { super(propertyDescriptor); } protected final > F getRequiredFunction(Class functionInterface) { if (functionInterface == null) throw new IllegalArgumentException("functionClass"); //$NON-NLS-1$ F function = getOptionalFunction(functionInterface); if (function == null) { String msgPattern = "Function implementation not found for function: {0}"; //$NON-NLS-1$ String msg = MessageFormat.format(msgPattern, functionInterface.getName()); throw new IllegalStateException(msg); } return function; } protected final > F getOptionalFunction(Class functionInterface) { if (functionInterface == null) throw new IllegalArgumentException("functionClass"); //$NON-NLS-1$ F function = getFunctionManager().getFunction(functionInterface); return function; } @Override public void getRequiredServices(IRowDataServiceGroup group) { super.getRequiredServices(group); group.add(IFunctionManager.class); } @SuppressWarnings("unchecked") protected IFunctionManager getFunctionManager() { return getService(IFunctionManager.class); } public void getRequiredFunctions(IFunctionGroup functionGroup) { //none by default } }