use of com.servoy.j2db.dataprocessing.Row in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method getListItemBgColor.
private String getListItemBgColor(ListItem<IRecordInternal> listItem, boolean isSelected, boolean asInlineCssString) {
String color = null;
final IRecordInternal rec = listItem.getModelObject();
String rowBGColorProvider = getRowBGColorScript();
Row rawData = null;
if (rec != null && (rawData = rec.getRawData()) != null) {
color = getStyleAttributeForListItem(listItem, isSelected, ISupportRowStyling.ATTRIBUTE.BGCOLOR, asInlineCssString);
if (rowBGColorProvider != null) {
Object c = color;
// TODO type and name should be get somehow if this is possible, we have to know the specific cell/column for that.
// (renderer instanceof IScriptBaseMethods) ? ((IScriptBaseMethods)renderer).js_getElementType() : null;
String type = null;
// (renderer instanceof IScriptBaseMethods) ? ((IScriptBaseMethods)renderer).js_getName() : null;
String cellName = null;
if (rawData.containsCalculation(rowBGColorProvider)) {
// TODO this should be done better....
// isEdited is always false
Record.VALIDATE_CALCS.set(Boolean.FALSE);
try {
c = rec.getParentFoundSet().getCalculationValue(rec, rowBGColorProvider, Utils.arrayMerge(new Object[] { new Integer(listItem.getIndex()), new Boolean(isSelected), type, cellName, Boolean.FALSE }, Utils.parseJSExpressions(getRowBGColorArgs())), null);
} finally {
Record.VALIDATE_CALCS.set(null);
}
} else {
try {
FormController currentForm = dal.getFormController();
c = currentForm.executeFunction(rowBGColorProvider, Utils.arrayMerge(new Object[] { new Integer(listItem.getIndex()), new Boolean(isSelected), type, cellName, currentForm.getName(), rec, Boolean.FALSE }, Utils.parseJSExpressions(getRowBGColorArgs())), false, null, true, null);
} catch (Exception ex) {
Debug.error(ex);
}
}
if (asInlineCssString) {
String bgColor = null;
if (c instanceof String)
bgColor = (String) c;
else if (c instanceof Color)
bgColor = PersistHelper.createColorString((Color) c);
if (bgColor != null)
color = new StringBuilder(CSS.Attribute.BACKGROUND_COLOR.toString()).append(':').append(color).append(';').toString();
}
}
}
return color;
}
Aggregations