* @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());
}
if (col.getTruncateSuffix() != null){
textField.getPropertiesMap().setProperty(JRTextElement.PROPERTY_TRUNCATE_SUFFIX, col.getTruncateSuffix());
}
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 don't 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 = Utils.cloneStyle(jrstyle);
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 {
JRDesignStyle alternateStyle = Utils.cloneStyle(jrstyle);
alternateStyle.setName(alternateStyle.getFontName() +"_for_column_"+col.getName());
alternateStyle.getConditionalStyleList().clear();
textField.setStyle(alternateStyle);
try {
design.addStyle(alternateStyle);
} catch (JRException e) { /**e.printStackTrace(); //Already there, nothing to do **/}