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);
return;
}
if (Utils.isEmpty(column.getConditionalStyles()))
return;
for (Iterator iterator = column.getConditionalStyles().iterator(); iterator.hasNext();) {
ConditionalStyle condition = (ConditionalStyle) iterator.next();
if (getReport().getOptions().isPrintBackgroundOnOddRows()
&& JRDesignElement.MODE_TRANSPARENT == jrstyle.getMode().byteValue() ){//condition style + odd row (only if original background is transparent)
JRDesignExpression expressionForConditionalStyle = getExpressionForConditionalStyle(condition, column);
String expStr = JRExpressionUtil.getExpressionText(expressionForConditionalStyle);
//ODD
JRDesignExpression expressionOdd = new JRDesignExpression();
expressionOdd.setValueClass(Boolean.class);
expressionOdd.setText("new java.lang.Boolean(" +EXPRESSION_TRUE_WHEN_ODD+".booleanValue() && ((java.lang.Boolean)" + expStr + ").booleanValue() )");
Style oddRowBackgroundStyle = getReport().getOptions().getOddRowBackgroundStyle();
JRDesignConditionalStyle condStyleOdd = new JRDesignConditionalStyle();
Utils.copyProperties(condStyleOdd, condition.getStyle().transform());
condStyleOdd.setBackcolor(oddRowBackgroundStyle.getBackgroundColor());
condStyleOdd.setMode(JRDesignElement.MODE_OPAQUE);
condStyleOdd.setConditionExpression(expressionOdd);
jrstyle.addConditionalStyle(condStyleOdd);
//EVEN
JRDesignExpression expressionEven = new JRDesignExpression();
expressionEven.setValueClass(Boolean.class);
expressionEven.setText("new java.lang.Boolean(" +EXPRESSION_TRUE_WHEN_EVEN+".booleanValue() && ((java.lang.Boolean)" + expStr + ").booleanValue() )");
JRDesignConditionalStyle condStyleEven = new JRDesignConditionalStyle();
Utils.copyProperties(condStyleEven, condition.getStyle().transform());
condStyleEven.setBackcolor(jrstyle.getBackcolor());
condStyleEven.setMode(jrstyle.getMode());
condStyleEven.setConditionExpression(expressionEven);
jrstyle.addConditionalStyle(condStyleEven);
} else { //No odd row, just the conditional style
JRDesignExpression expression = getExpressionForConditionalStyle(condition, column);
JRDesignConditionalStyle condStyle = new JRDesignConditionalStyle();
condStyle.setConditionExpression(expression);
jrstyle.addConditionalStyle(condStyle);
}
}
//The last condition is the basic one
//ODD
JRDesignExpression expressionOdd = new JRDesignExpression();
expressionOdd.setValueClass(Boolean.class);
expressionOdd.setText(EXPRESSION_TRUE_WHEN_ODD);
Style oddRowBackgroundStyle = getReport().getOptions().getOddRowBackgroundStyle();
JRDesignConditionalStyle condStyleOdd = new JRDesignConditionalStyle();
condStyleOdd.setBackcolor(oddRowBackgroundStyle.getBackgroundColor());
condStyleOdd.setMode(JRDesignElement.MODE_OPAQUE);
condStyleOdd.setConditionExpression(expressionOdd);
jrstyle.addConditionalStyle(condStyleOdd);
//EVEN
JRDesignExpression expressionEven = new JRDesignExpression();
expressionEven.setValueClass(Boolean.class);
expressionEven.setText(EXPRESSION_TRUE_WHEN_EVEN);
JRDesignConditionalStyle condStyleEven = new JRDesignConditionalStyle();
condStyleEven.setBackcolor(jrstyle.getBackcolor());
condStyleEven.setMode(jrstyle.getMode());
condStyleEven.setConditionExpression(expressionEven);
jrstyle.addConditionalStyle(condStyleEven);
}