* @param int height
* @param DJGroup group
* @return JRDesignTextField
*/
protected JRDesignTextField generateTextFieldFromColumn(AbstractColumn col, int height, DJGroup group) {
JRDesignTextField textField = new JRDesignTextField();
JRDesignExpression exp = new JRDesignExpression();
if (col.getPattern() != null && "".equals(col.getPattern().trim())) {
textField.setPattern(col.getPattern());
}
exp.setText(col.getTextForExpression());
exp.setValueClassName(col.getValueClassNameForExpression());
textField.setExpression(exp);
textField.setWidth(col.getWidth().intValue());
textField.setX(col.getPosX().intValue());
textField.setY(col.getPosY().intValue());
textField.setHeight(height);
textField.setBlankWhenNull(col.getBlankWhenNull());
textField.setPattern(col.getPattern());
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 {