textField.setPrintRepeatedValues(col.getPrintRepeatedValues().booleanValue());
textField.setPrintWhenDetailOverflows(true);
Style columnStyle = col.getStyle();
if (columnStyle == null)
columnStyle = report.getOptions().getDefaultDetailStyle();
applyStyleToElement(columnStyle, textField);
JRDesignStyle jrstyle = (JRDesignStyle) textField.getStyle();
if (group != null) {
int index = getReport().getColumnsGroups().indexOf(group);
// JRDesignGroup previousGroup = (JRDesignGroup) getDesign().getGroupsList().get(index);
JRDesignGroup previousGroup = getJRGroupFromDJGroup(group);
textField.setPrintWhenGroupChanges(previousGroup);
/**
* Since a group column can share the style with non group columns, if oddRow coloring is enabled,
* we modified this shared style to have a colored background on odd rows. We dont want that for group
* columns, that's why we create our own style from the existing one, and remove proper odd-row conditional
* style if present
*/
JRDesignStyle groupStyle = new JRDesignStyle();
try {
if (jrstyle != null)
BeanUtils.copyProperties(groupStyle, jrstyle);
} catch (Exception e) {
throw new DJException("Could not copy properties for shared group style: " + e.getMessage(),e);
}
groupStyle.setName(groupStyle.getFontName() +"_for_group_"+index);
textField.setStyle(groupStyle);
try {
design.addStyle(groupStyle);
} catch (JRException e) { /**e.printStackTrace(); //Already there, nothing to do **/}
} else {
if (getReport().getOptions().isPrintBackgroundOnOddRows() &&
(jrstyle.getConditionalStyles() == null || jrstyle.getConditionalStyles().length == 0)) {
// No group column so this is a detail text field
JRDesignExpression expression = new JRDesignExpression();
expression.setValueClass(Boolean.class);
expression.setText(EXPRESSION_TRUE_WHEN_ODD);
Style oddRowBackgroundStyle = getReport().getOptions().getOddRowBackgroundStyle();
JRDesignConditionalStyle condStyle = new JRDesignConditionalStyle();
condStyle.setBackcolor(oddRowBackgroundStyle.getBackgroundColor());
condStyle.setMode(JRDesignElement.MODE_OPAQUE);
condStyle.setConditionExpression(expression);
jrstyle.addConditionalStyle(condStyle);
}